From 41c593ef46159645a5b34189952a97283aa05326 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Mon, 3 Nov 2025 10:55:07 -0300 Subject: [PATCH] tests/hlsl: Test clip/cull distance semantics as arrays. Arrays are allowed for clip/cull distance semantics. Their maximum size is 2 since that's the maximum amount of registers allowed for clip/cull distances. Indirect addressing of these arrays is allowed on shader model 6. These tests are introduced after the transformation of clip/cull input/outputs into arrays in vsir since otherwise they segfault. --- Makefile.am | 3 +- ..._test => clip-cull-distance-1.shader_test} | 0 tests/hlsl/clip-cull-distance-2.shader_test | 90 +++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) rename tests/hlsl/{clip-cull-distance.shader_test => clip-cull-distance-1.shader_test} (100%) create mode 100644 tests/hlsl/clip-cull-distance-2.shader_test diff --git a/Makefile.am b/Makefile.am index 1f53f25d8..d9e06dba0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,7 +89,8 @@ vkd3d_shader_tests = \ tests/hlsl/ceil.shader_test \ tests/hlsl/cf-cond-types.shader_test \ tests/hlsl/clamp.shader_test \ - tests/hlsl/clip-cull-distance.shader_test \ + tests/hlsl/clip-cull-distance-1.shader_test \ + tests/hlsl/clip-cull-distance-2.shader_test \ tests/hlsl/clip-planes.shader_test \ tests/hlsl/clip.shader_test \ tests/hlsl/combined-samplers.shader_test \ diff --git a/tests/hlsl/clip-cull-distance.shader_test b/tests/hlsl/clip-cull-distance-1.shader_test similarity index 100% rename from tests/hlsl/clip-cull-distance.shader_test rename to tests/hlsl/clip-cull-distance-1.shader_test diff --git a/tests/hlsl/clip-cull-distance-2.shader_test b/tests/hlsl/clip-cull-distance-2.shader_test new file mode 100644 index 000000000..e341a690d --- /dev/null +++ b/tests/hlsl/clip-cull-distance-2.shader_test @@ -0,0 +1,90 @@ +[require] +shader model >= 4.0 + +[vertex shader todo(sm<6)] +struct vertex +{ + float4 pos : SV_POSITION; + float2 clip[2] : SV_CLIPDISTANCE; +}; + +void main(float4 pos : POSITION, out vertex vertex) +{ + vertex.pos = pos; + // Only pixels closer to the center should remain. + vertex.clip[0] = float2(0.5 + pos.x, 0.5 - pos.x); + vertex.clip[1] = float2(0.5 + pos.y, 0.5 - pos.y); +} + +[pixel shader todo(sm<6)] +struct vertex +{ + float4 pos : SV_POSITION; + float2 clip[2] : SV_CLIPDISTANCE; +}; + +float4 main(in vertex vert) : SV_TARGET +{ + return round(10000 * float4(vert.clip[0], vert.clip[1])); +} + +% clip[1] is ignored on WARP on SM6, this is probably a bug. +[test] +clear rtv 0 0.0 0.0 0.0 1.0 +todo(sm<6 | msl) draw quad + probe ( 80, 60) f32(0.0, 0.0, 0.0, 1.0) + probe ( 80, 180) f32(0.0, 0.0, 0.0, 1.0) + probe ( 80, 300) f32(0.0, 0.0, 0.0, 1.0) + probe ( 80, 420) f32(0.0, 0.0, 0.0, 1.0) +if(!warp | sm<6) probe (240, 60) f32(0.0, 0.0, 0.0, 1.0) + probe (240, 180) f32(2516, 7484, 7479, 2521) + probe (240, 300) f32(2516, 7484, 2479, 7521) +if(!warp | sm<6) probe (240, 420) f32(0.0, 0.0, 0.0, 1.0) +if(!warp | sm<6) probe (400, 60) f32(0.0, 0.0, 0.0, 1.0) + probe (400, 180) f32(7516, 2484, 7479, 2521) + probe (400, 300) f32(7516, 2484, 2479, 7521) +if(!warp | sm<6) probe (400, 420) f32(0.0, 0.0, 0.0, 1.0) + probe (560, 60) f32(0.0, 0.0, 0.0, 1.0) + probe (560, 180) f32(0.0, 0.0, 0.0, 1.0) + probe (560, 300) f32(0.0, 0.0, 0.0, 1.0) + probe (560, 420) f32(0.0, 0.0, 0.0, 1.0) + +[pixel shader] +float4 main() : SV_TARGET +{ + return float4(1.0, 1.0, 1.0, 1.0); +} + +[vertex shader fail(sm<6)] +unsigned int i; + +struct vertex +{ + float4 pos : SV_POSITION; + float clip[2] : SV_CLIPDISTANCE; +}; + +void main(float4 pos : POSITION, out vertex vertex) +{ + vertex.pos = pos; + vertex.clip[0] = pos.x; + vertex.clip[1] = pos.y; + vertex.clip[i] = 1.0; +} + +% clip[1] is ignored on WARP on SM6, this is probably a bug. +[test] +uniform 0 int 0 +clear rtv 0 0.0 0.0 0.0 1.0 +todo(sm<6 | msl) draw quad + probe (160, 120) f32(1.0, 1.0, 1.0, 1.0) +if(!warp) probe (160, 360) f32(0.0, 0.0, 0.0, 1.0) + probe (480, 120) f32(1.0, 1.0, 1.0, 1.0) +if(!warp) probe (480, 360) f32(0.0, 0.0, 0.0, 1.0) +uniform 0 int 1 +clear rtv 0 0.0 0.0 0.0 1.0 +todo(sm<6 | msl) draw quad + probe (160, 120) f32(0.0, 0.0, 0.0, 1.0) + probe (160, 360) f32(0.0, 0.0, 0.0, 1.0) + probe (480, 120) f32(1.0, 1.0, 1.0, 1.0) + probe (480, 360) f32(1.0, 1.0, 1.0, 1.0)