Skip to content

Commit

Permalink
feat: FX 支持 USE 指令
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Jan 7, 2025
1 parent e5bbb25 commit bae66e7
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 92 deletions.
13 changes: 7 additions & 6 deletions src/Effects/ACNet.hlsl
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// ACNet
// 移植自 https://github.com/TianZerL/ACNetGLSL/blob/f20a6b6b7327f4caf588b06c6b21f18e40dae1ce/glsl/ACNet.glsl


//!MAGPIE EFFECT
//!VERSION 4
//!USE_FP16
//!USE FP16

#include "StubDefs.hlsli"

Expand Down Expand Up @@ -40,7 +39,6 @@ Texture2D tex3;
//!FORMAT R16G16B16A16_FLOAT
Texture2D tex4;


//!SAMPLER
//!FILTER POINT
SamplerState sam;
Expand All @@ -49,9 +47,12 @@ SamplerState sam;
//!FILTER LINEAR
SamplerState sam1;


//!COMMON

#ifdef MP_DEBUG
#pragma warning(disable: 4714) // X4714: sum of temp registers and indexable temp registers times 256 threads exceeds the recommended total 16384. Performance may be reduced
#endif

#define RELU(x) max(x, 0)

MF4 MulAdd(MF3 x, MF3x4 y, MF4 a) {
Expand Down Expand Up @@ -2542,15 +2543,15 @@ void Pass9(uint2 blockStart, uint3 threadId) {
uint2 destPos = gxy + uint2(i, j);

uint index = j * 2 + i;
MF luma = clamp(
MF luma = saturate(
target1.x * kernelsL10[0 + index] +
target1.y * kernelsL10[4 + index] +
target1.z * kernelsL10[8 + index] +
target1.w * kernelsL10[12 + index] +
target2.x * kernelsL10[16 + index] +
target2.y * kernelsL10[20 + index] +
target2.z * kernelsL10[24 + index] +
target2.w * kernelsL10[28 + index], 0.0, 1.0);
target2.w * kernelsL10[28 + index]);

MF2 originUV = mul(rgb2uv, INPUT.SampleLevel(sam1, (destPos + 0.5f) * outputPt, 0).rgb);
OUTPUT[destPos] = MF4(mul(yuv2rgb, MF3(luma, originUV)), 1);
Expand Down
2 changes: 1 addition & 1 deletion src/Effects/Anime4K/Anime4K_Restore_L.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Restore_2
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/Anime4K/Anime4K_Restore_Soft_UL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Restore_Soft_4
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/Anime4K/Anime4K_Restore_UL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Restore_4
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/Anime4K/Anime4K_Upscale_Denoise_UL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Upscale_Denoise_3
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
3 changes: 1 addition & 2 deletions src/Effects/Anime4K/Anime4K_Upscale_L.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Upscale_1
//!USE_FP16
//!USE FP16, MulAdd

#include "..\StubDefs.hlsli"


//!TEXTURE
Texture2D INPUT;

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/Anime4K/Anime4K_Upscale_VL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME Anime4K_Upscale_2
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/CRT/CRT_Geom.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

//!MAGPIE EFFECT
//!VERSION 4
//!USE_DYNAMIC
//!USE Dynamic


//!PARAMETER
Expand Down
2 changes: 1 addition & 1 deletion src/Effects/CuNNy/CuNNy-16x16C-NVL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME CuNNy-D16N16
//!USE_FP16
//!USE FP16

#include "..\StubDefs.hlsli"

Expand Down
2 changes: 1 addition & 1 deletion src/Effects/CuNNy/CuNNy-6x8C-NVL.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//!MAGPIE EFFECT
//!VERSION 4
//!SORT_NAME CuNNy-D08N06
//!USE_FP16
//!USE FP16


//!TEXTURE
Expand Down
2 changes: 1 addition & 1 deletion src/Effects/FSRCNNX/FSRCNNX.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//!MAGPIE EFFECT
//!VERSION 4
//!USE_FP16
//!USE FP16


//!TEXTURE
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie.Core/DirectXHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool DirectXHelper::CompileComputeShader(
flags |= D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_DEBUG;
#else
flags |= D3DCOMPILE_OPTIMIZATION_LEVEL3;
#endif // _DEBUG
#endif

std::unique_ptr<D3D_SHADER_MACRO[]> mc(new D3D_SHADER_MACRO[macros.size() + 1]);
for (UINT i = 0; i < macros.size(); ++i) {
Expand Down
4 changes: 2 additions & 2 deletions src/Magpie.Core/EffectCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void serialize(Archive& ar, EffectSamplerDesc& o) {

template<typename Archive>
void serialize(Archive& ar, EffectPassDesc& o) {
ar& o.cso& o.inputs& o.outputs& o.numThreads[0] & o.numThreads[1] & o.numThreads[2] & o.blockSize& o.desc& o.isPSStyle;
ar& o.cso& o.inputs& o.outputs& o.numThreads[0] & o.numThreads[1] & o.numThreads[2] & o.blockSize& o.desc& o.flags;
}

template<typename Archive>
Expand All @@ -76,7 +76,7 @@ static constexpr uint32_t MAX_CACHE_COUNT = 127;

// 缓存版本
// 当缓存文件结构有更改时更新它,使旧缓存失效
static constexpr uint32_t EFFECT_CACHE_VERSION = 14;
static constexpr uint32_t EFFECT_CACHE_VERSION = 15;


static std::wstring GetLinearEffectName(std::wstring_view effectName) {
Expand Down
Loading

0 comments on commit bae66e7

Please sign in to comment.