From cf4ed988d0fddd2031d95a4341a8db57243d8a54 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Mon, 29 Jan 2024 14:46:50 +1000 Subject: [PATCH] tests/shader-runner: Add shader model 6 texture UAV tests. The UAV default register allocation rules changed with SM 5.1. --- Makefile.am | 1 + tests/hlsl/sm6-uav-rwtexture.shader_test | 208 +++++++++++++++++++++++ tests/hlsl/uav-rwtexture.shader_test | 31 ++-- 3 files changed, 227 insertions(+), 13 deletions(-) create mode 100644 tests/hlsl/sm6-uav-rwtexture.shader_test diff --git a/Makefile.am b/Makefile.am index 1687d9a0..d9db8eec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,6 +170,7 @@ vkd3d_shader_tests = \ tests/hlsl/sign.shader_test \ tests/hlsl/single-numeric-initializer.shader_test \ tests/hlsl/sm6-ternary.shader_test \ + tests/hlsl/sm6-uav-rwtexture.shader_test \ tests/hlsl/smoothstep.shader_test \ tests/hlsl/sqrt.shader_test \ tests/hlsl/state-block-syntax.shader_test \ diff --git a/tests/hlsl/sm6-uav-rwtexture.shader_test b/tests/hlsl/sm6-uav-rwtexture.shader_test new file mode 100644 index 00000000..78fbb385 --- /dev/null +++ b/tests/hlsl/sm6-uav-rwtexture.shader_test @@ -0,0 +1,208 @@ +[require] +shader model >= 6.0 + +[uav 0] +format r32 float +size (2, 2) + +0.1 0.2 +0.3 0.4 + +[uav 1] +size (1, 1) + +0.5 0.6 0.7 0.8 + +[pixel shader] +RWTexture2D u : register(u1); + +float4 main() : sv_target +{ + /* Unlike SM < 6.0, all four components are not required to be written in a single statement. */ + u[uint2(0, 0)].xy = float2(1, 2); + u[uint2(0, 0)].zw = float2(3, 4); + return 0; +} + +[test] +todo draw quad +probe uav 1 (0, 0) rgba (1.0, 2.0, 3.0, 4.0) + +[pixel shader fail] +Texture2D u; + +float4 main() : sv_target +{ + /* SRVs are not writable. */ + u[uint2(0, 0)].xyzw = float4(1, 2, 3, 4); + return 0; +} + +[pixel shader] +RWTexture2D u; +RWTexture2D v; + +float4 main() : sv_target +{ + u[uint2(0, 0)] = 0.5; + u[uint2(0, 1)].x = 0.6; + u[uint2(1, 1)] = 0.7; + v[uint2(0, 0)].yxwz = float4(1, 2, 3, 4); + return 0; +} + +[test] +todo draw quad +probe uav 0 (0, 0) r (0.5) +probe uav 0 (0, 1) r (0.6) +probe uav 0 (1, 0) r (0.2) +probe uav 0 (1, 1) r (0.7) +probe uav 1 (0, 0) rgba (2.0, 1.0, 4.0, 3.0) + + +[uav 2] +size (1, 1) + +0.1 0.2 0.3 0.4 + +[pixel shader] +RWTexture2D u : register(u2); + +float4 main() : sv_target1 +{ + u[uint2(0, 0)] = float4(0.9, 0.8, 0.7, 0.6); + return 0; +} + +[test] +todo draw quad +probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) + +% Uppercase register set name +[pixel shader] +RWTexture2D u : register(U2); + +float4 main() : sv_target1 +{ + u[uint2(0, 0)] = float4(0.9, 0.8, 0.7, 0.6); + return 0; +} + +[test] +todo draw quad +probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) + +% Test that we can declare and use an array of UAVs. + +[uav 1] +size (1, 1) + +0.1 0.2 0.3 0.4 + +[uav 2] +size (1, 1) + +0.5 0.6 0.7 0.8 + +[pixel shader] +RWTexture2D u[2] : register(u1); + +float4 main() : sv_target1 +{ + u[0][uint2(0, 0)] = float4(1.1, 1.2, 1.3, 1.4); + u[1][uint2(0, 0)] = float4(2.1, 2.2, 2.3, 2.4); + return 0; +} + +[test] +todo draw quad +probe uav 1 (0, 0) rgba (1.1, 1.2, 1.3, 1.4) +probe uav 2 (0, 0) rgba (2.1, 2.2, 2.3, 2.4) + +% RWTexture1D types +[pixel shader] + +RWTexture1D u : register(u1); +RWTexture1D u0; + +float4 main() : sv_target1 +{ + u[0] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% RWTexture1DArray types +[pixel shader] + +RWTexture1DArray u : register(u1); +RWTexture1DArray u0; + +float4 main() : sv_target1 +{ + u[int2(0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% RWTexture2D types +[pixel shader] + +RWTexture2D u : register(u1); +RWTexture2D u0; + +float4 main() : sv_target1 +{ + u[int2(0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% RWTexture2DArray types +[pixel shader] + +RWTexture2DArray u : register(u1); +RWTexture2DArray u0; + +float4 main() : sv_target1 +{ + u[int3(0, 0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% RWTexture3D types +[pixel shader] + +RWTexture3D u : register(u1); +RWTexture3D u0; + +float4 main() : sv_target1 +{ + u[int3(0, 0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% Structs are invalid in SM 6. +[pixel shader fail] +struct s +{ + float4 a; +}; + +RWTexture2D u : register(u1); +RWTexture2D u0; + +float4 main() : sv_target1 +{ + u[int2(0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} + +% Matrices are invalid in SM 6. +[pixel shader fail] + +RWTexture2D u : register(u1); +RWTexture2D u0; + +float4 main() : sv_target1 +{ + u[int2(0, 0)] = float4(11.1, 12.2, 13.3, 14.4); + return 0; +} diff --git a/tests/hlsl/uav-rwtexture.shader_test b/tests/hlsl/uav-rwtexture.shader_test index 76535bd5..5cfd969f 100644 --- a/tests/hlsl/uav-rwtexture.shader_test +++ b/tests/hlsl/uav-rwtexture.shader_test @@ -1,7 +1,8 @@ [require] shader model >= 5.0 +shader model < 6.0 -[pixel shader fail(sm<6)] +[pixel shader fail] RWTexture2D u; float4 main() : sv_target @@ -49,7 +50,7 @@ float4 main() : sv_target } [test] -todo(sm>=6) draw quad +draw quad probe uav 1 (0, 0) r (0.5) probe uav 1 (0, 1) r (0.6) probe uav 1 (1, 0) r (0.2) @@ -71,7 +72,7 @@ size (1, 1) 0.1 0.2 0.3 0.4 -[pixel shader fail(sm<6)] +[pixel shader fail] RWTexture2D u : register(u0); float4 main() : sv_target1 @@ -80,7 +81,7 @@ float4 main() : sv_target1 return 0; } -[pixel shader fail(sm<6)] +[pixel shader fail] RWTexture2D u : register(u1); float4 main() : sv_target1 @@ -99,7 +100,7 @@ float4 main() : sv_target1 } [test] -todo(sm>=6) draw quad +draw quad probe uav 2 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) @@ -118,7 +119,7 @@ float4 main() : sv_target1 } [test] -todo(sm>=6) draw quad +draw quad probe uav 3 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) % Uppercase register set name @@ -132,7 +133,7 @@ float4 main() : sv_target1 } [test] -todo(sm>=6) draw quad +draw quad probe uav 3 (0, 0) rgba (0.9, 0.8, 0.7, 0.6) % Test that we can declare and use an array of UAVs. @@ -158,12 +159,12 @@ float4 main() : sv_target1 } [test] -todo(sm>=6) draw quad +draw quad probe uav 2 (0, 0) rgba (1.1, 1.2, 1.3, 1.4) probe uav 3 (0, 0) rgba (2.1, 2.2, 2.3, 2.4) % RWTexture1D types -[pixel shader fail(sm>=6)] +[pixel shader] struct s { float3 a; @@ -181,7 +182,7 @@ float4 main() : sv_target1 } % RWTexture1DArray types -[pixel shader fail(sm>=6)] +[pixel shader] struct s { float3 a; @@ -199,7 +200,7 @@ float4 main() : sv_target1 } % RWTexture2D types -[pixel shader fail(sm>=6)] +[pixel shader] struct s { float3 a; @@ -217,7 +218,7 @@ float4 main() : sv_target1 } % RWTexture2DArray types -[pixel shader fail(sm>=6)] +[pixel shader] struct s { float3 a; @@ -235,7 +236,7 @@ float4 main() : sv_target1 } % RWTexture3D types -[pixel shader fail(sm>=6)] +[pixel shader] struct s { float3 a; @@ -252,6 +253,10 @@ float4 main() : sv_target1 return 0; } + +[require] +shader model >= 5.0 + % Type is too wide [pixel shader fail] struct s