From 8a3d01505097e25912d837e1dd29a0ed23dc7cd4 Mon Sep 17 00:00:00 2001 From: Alexander Johnston Date: Thu, 20 Nov 2025 16:56:46 +0000 Subject: [PATCH 1/3] Add Graphics tests for ddx/y_fine --- test/Graphics/ddx_fine.test | 95 +++++++++++++++++++++++++++++++++++++ test/Graphics/ddy_fine.test | 95 +++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 test/Graphics/ddx_fine.test create mode 100644 test/Graphics/ddy_fine.test diff --git a/test/Graphics/ddx_fine.test b/test/Graphics/ddx_fine.test new file mode 100644 index 000000000..4d0aac2e4 --- /dev/null +++ b/test/Graphics/ddx_fine.test @@ -0,0 +1,95 @@ +#--- vertex.hlsl +struct PSInput +{ + float4 position : SV_POSITION; +}; + +PSInput main(float4 position : POSITION) +{ + PSInput result; + + result.position = position; + + return result; +} + + +#--- pixel.hlsl + +// Offset into the image of our circle +#define offset 128.0 +// Radius of our circle +#define radius 32.0 +// Blur intensity +#define intensity 5.0 + +struct PSInput +{ + float4 position : SV_POSITION; +}; + +float4 main(PSInput input) : SV_TARGET +{ + float4 c1 = float4(1.0, 1.0, 1.0, 1.0); + float4 c2 = float4(0.0, 0.0, 0.0, 1.0); + + float2 coord = input.position.xy - offset; + + float dist = length(coord) - radius; + float ddx = abs(ddx_fine(dist)); + float effect = clamp(dist / ddx / intensity, 0.0, 1.0); + + float result = lerp(c1, c2, effect); + + return float4(result, result, result, 1.0); +} +#--- pipeline.yaml +--- +Shaders: + - Stage: Vertex + Entry: main + - Stage: Pixel + Entry: main +Buffers: + - Name: VertexData + Format: Float32 + Stride: 12 # 16 bytes per vertex + Data: [ -1.0, -1.0, 0.0, + -1.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 1.0, -1.0, 0.0, + -1.0, -1.0, 0.0 ] + - Name: Output + Format: Float32 + Channels: 4 + FillSize: 1048576 # 256x256 @ 16 bytes per pixel + OutputProps: + Height: 256 + Width: 256 + Depth: 16 +Bindings: + VertexBuffer: VertexData + VertexAttributes: + - Format: Float32 + Channels: 3 + Offset: 0 + Name: POSITION + RenderTarget: Output +DescriptorSets: [] +... +#--- rules.yaml +--- +- Type: PixelPercent + Val: 0.2 # No more than 0.2% of pixels may be visibly different. +... +#--- end + +# UNSUPPORTED: Clang +# REQUIRES: goldenimage + +# RUN: split-file %s %t +# RUN: %dxc_target -T vs_6_0 -Fo %t-vertex.o %t/vertex.hlsl +# RUN: %dxc_target -T ps_6_0 -Fo %t-pixel.o %t/pixel.hlsl +# RUN: %offloader %t/pipeline.yaml %t-vertex.o %t-pixel.o -r Output -o %t/Output.png +# RUN: imgdiff %t/Output.png %goldenimage_dir/hlsl/Graphics/DdxFine.png -rules %t/rules.yaml diff --git a/test/Graphics/ddy_fine.test b/test/Graphics/ddy_fine.test new file mode 100644 index 000000000..39b488d64 --- /dev/null +++ b/test/Graphics/ddy_fine.test @@ -0,0 +1,95 @@ +#--- vertex.hlsl +struct PSInput +{ + float4 position : SV_POSITION; +}; + +PSInput main(float4 position : POSITION) +{ + PSInput result; + + result.position = position; + + return result; +} + + +#--- pixel.hlsl + +// Offset into the image of our circle +#define offset 128.0 +// Radius of our circle +#define radius 32.0 +// Blur intensity +#define intensity 5.0 + +struct PSInput +{ + float4 position : SV_POSITION; +}; + +float4 main(PSInput input) : SV_TARGET +{ + float4 c1 = float4(1.0, 1.0, 1.0, 1.0); + float4 c2 = float4(0.0, 0.0, 0.0, 1.0); + + float2 coord = input.position.xy - offset; + + float dist = length(coord) - radius; + float ddx = abs(ddy_fine(dist)); + float effect = clamp(dist / ddx / intensity, 0.0, 1.0); + + float result = lerp(c1, c2, effect); + + return float4(result, result, result, 1.0); +} +#--- pipeline.yaml +--- +Shaders: + - Stage: Vertex + Entry: main + - Stage: Pixel + Entry: main +Buffers: + - Name: VertexData + Format: Float32 + Stride: 12 # 16 bytes per vertex + Data: [ -1.0, -1.0, 0.0, + -1.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 1.0, 1.0, 0.0, + 1.0, -1.0, 0.0, + -1.0, -1.0, 0.0 ] + - Name: Output + Format: Float32 + Channels: 4 + FillSize: 1048576 # 256x256 @ 16 bytes per pixel + OutputProps: + Height: 256 + Width: 256 + Depth: 16 +Bindings: + VertexBuffer: VertexData + VertexAttributes: + - Format: Float32 + Channels: 3 + Offset: 0 + Name: POSITION + RenderTarget: Output +DescriptorSets: [] +... +#--- rules.yaml +--- +- Type: PixelPercent + Val: 0.2 # No more than 0.2% of pixels may be visibly different. +... +#--- end + +# UNSUPPORTED: Clang +# REQUIRES: goldenimage + +# RUN: split-file %s %t +# RUN: %dxc_target -T vs_6_0 -Fo %t-vertex.o %t/vertex.hlsl +# RUN: %dxc_target -T ps_6_0 -Fo %t-pixel.o %t/pixel.hlsl +# RUN: %offloader %t/pipeline.yaml %t-vertex.o %t-pixel.o -r Output -o %t/Output.png +# RUN: imgdiff %t/Output.png %goldenimage_dir/hlsl/Graphics/DdyFine.png -rules %t/rules.yaml From 5140b87f418839f875566f106d66d77fe2b9c1a4 Mon Sep 17 00:00:00 2001 From: Alexander Johnston Date: Thu, 11 Dec 2025 15:02:49 +0000 Subject: [PATCH 2/3] Update supported test matrix now that SV_TARGET is supported --- test/Graphics/ddx_fine.test | 4 +++- test/Graphics/ddy_fine.test | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/Graphics/ddx_fine.test b/test/Graphics/ddx_fine.test index 4d0aac2e4..663efcd4c 100644 --- a/test/Graphics/ddx_fine.test +++ b/test/Graphics/ddx_fine.test @@ -85,7 +85,9 @@ DescriptorSets: [] ... #--- end -# UNSUPPORTED: Clang +# Bug https://github.com/llvm/wg-hlsl/issues/145 +# Bug https://github.com/llvm/wg-hlsl/issues/146 +# XFAIL: Clang && DirectX # REQUIRES: goldenimage # RUN: split-file %s %t diff --git a/test/Graphics/ddy_fine.test b/test/Graphics/ddy_fine.test index 39b488d64..484c34136 100644 --- a/test/Graphics/ddy_fine.test +++ b/test/Graphics/ddy_fine.test @@ -85,7 +85,9 @@ DescriptorSets: [] ... #--- end -# UNSUPPORTED: Clang +# Bug https://github.com/llvm/wg-hlsl/issues/145 +# Bug https://github.com/llvm/wg-hlsl/issues/146 +# XFAIL: Clang && DirectX # REQUIRES: goldenimage # RUN: split-file %s %t From 506c48220ea1c14480c9283ddc2b01ce1613335b Mon Sep 17 00:00:00 2001 From: Alexander Johnston Date: Thu, 11 Dec 2025 19:53:19 +0000 Subject: [PATCH 3/3] Update style and formatting --- test/Graphics/ddx_fine.test | 46 +++++++++++++++++-------------------- test/Graphics/ddy_fine.test | 46 +++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 50 deletions(-) diff --git a/test/Graphics/ddx_fine.test b/test/Graphics/ddx_fine.test index 663efcd4c..a0a707664 100644 --- a/test/Graphics/ddx_fine.test +++ b/test/Graphics/ddx_fine.test @@ -1,48 +1,44 @@ #--- vertex.hlsl -struct PSInput -{ - float4 position : SV_POSITION; +struct PSInput { + float4 position : SV_POSITION; }; -PSInput main(float4 position : POSITION) -{ - PSInput result; +PSInput main(float4 position : POSITION) { + PSInput result; - result.position = position; + result.position = position; - return result; + return result; } - #--- pixel.hlsl // Offset into the image of our circle -#define offset 128.0 +#define OFFSET 128.0 // Radius of our circle -#define radius 32.0 +#define RADIUS 32.0 // Blur intensity -#define intensity 5.0 +#define INTENSITY 5.0 -struct PSInput -{ - float4 position : SV_POSITION; +struct PSInput { + float4 position : SV_POSITION; }; -float4 main(PSInput input) : SV_TARGET -{ - float4 c1 = float4(1.0, 1.0, 1.0, 1.0); - float4 c2 = float4(0.0, 0.0, 0.0, 1.0); +float4 main(PSInput input) : SV_TARGET { + float4 c1 = float4(1.0, 1.0, 1.0, 1.0); + float4 c2 = float4(0.0, 0.0, 0.0, 1.0); - float2 coord = input.position.xy - offset; + float2 coord = input.position.xy - OFFSET; - float dist = length(coord) - radius; - float ddx = abs(ddx_fine(dist)); - float effect = clamp(dist / ddx / intensity, 0.0, 1.0); + float dist = length(coord) - RADIUS; + float ddx = abs(ddx_fine(dist)); + float effect = clamp(dist / ddx / INTENSITY, 0.0, 1.0); - float result = lerp(c1, c2, effect); + float result = lerp(c1, c2, effect); - return float4(result, result, result, 1.0); + return float4(result, result, result, 1.0); } + #--- pipeline.yaml --- Shaders: diff --git a/test/Graphics/ddy_fine.test b/test/Graphics/ddy_fine.test index 484c34136..8d9dbd459 100644 --- a/test/Graphics/ddy_fine.test +++ b/test/Graphics/ddy_fine.test @@ -1,48 +1,44 @@ #--- vertex.hlsl -struct PSInput -{ - float4 position : SV_POSITION; +struct PSInput { + float4 position : SV_POSITION; }; -PSInput main(float4 position : POSITION) -{ - PSInput result; +PSInput main(float4 position : POSITION) { + PSInput result; - result.position = position; + result.position = position; - return result; + return result; } - #--- pixel.hlsl // Offset into the image of our circle -#define offset 128.0 +#define OFFSET 128.0 // Radius of our circle -#define radius 32.0 +#define RADIUS 32.0 // Blur intensity -#define intensity 5.0 +#define INTENSITY 5.0 -struct PSInput -{ - float4 position : SV_POSITION; +struct PSInput { + float4 position : SV_POSITION; }; -float4 main(PSInput input) : SV_TARGET -{ - float4 c1 = float4(1.0, 1.0, 1.0, 1.0); - float4 c2 = float4(0.0, 0.0, 0.0, 1.0); +float4 main(PSInput input) : SV_TARGET { + float4 c1 = float4(1.0, 1.0, 1.0, 1.0); + float4 c2 = float4(0.0, 0.0, 0.0, 1.0); - float2 coord = input.position.xy - offset; + float2 coord = input.position.xy - OFFSET; - float dist = length(coord) - radius; - float ddx = abs(ddy_fine(dist)); - float effect = clamp(dist / ddx / intensity, 0.0, 1.0); + float dist = length(coord) - RADIUS; + float ddx = abs(ddy_fine(dist)); + float effect = clamp(dist / ddx / INTENSITY, 0.0, 1.0); - float result = lerp(c1, c2, effect); + float result = lerp(c1, c2, effect); - return float4(result, result, result, 1.0); + return float4(result, result, result, 1.0); } + #--- pipeline.yaml --- Shaders: