From 499b44a193444eea9af8363dd9d22b2a12241c18 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Wed, 10 Apr 2024 20:18:24 -0400 Subject: [PATCH] tests: Test default values for uniform variables. --- Makefile.am | 1 + tests/hlsl/default-values.shader_test | 143 ++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/hlsl/default-values.shader_test diff --git a/Makefile.am b/Makefile.am index f901a84d..b3288b50 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,6 +89,7 @@ vkd3d_shader_tests = \ tests/hlsl/cross.shader_test \ tests/hlsl/d3dcolor-to-ubyte4.shader_test \ tests/hlsl/ddxddy.shader_test \ + tests/hlsl/default-values.shader_test \ tests/hlsl/depth-out.shader_test \ tests/hlsl/determinant.shader_test \ tests/hlsl/discard.shader_test \ diff --git a/tests/hlsl/default-values.shader_test b/tests/hlsl/default-values.shader_test new file mode 100644 index 00000000..6550c67b --- /dev/null +++ b/tests/hlsl/default-values.shader_test @@ -0,0 +1,143 @@ +% Note that, except for effects, default values do not affect the execution. +% The default values are intended to be obtained using reflection. + +[pixel shader todo] +float2 a = {1, 2}; +float4x2 b = {1, 2, 3, 4, 5, 6, 7, 8}; + +float4 main() : sv_target +{ + return float4(a, b[2]); +} + +[test] +if(sm<4) uniform 0 float4 10 30 50 70 +if(sm<4) uniform 4 float4 20 40 60 80 +if(sm<4) uniform 8 float4 10 20 0 0 +if(sm>=4) uniform 0 float4 10 20 0 0 +if(sm>=4) uniform 4 float4 10 30 50 70 +if(sm>=4) uniform 8 float4 20 40 60 80 +todo(sm<6) draw quad +probe all rgba (10, 20, 50, 60) + + +[pixel shader fail(sm<6) todo] +float a = 7; +float4 b = a; // initial value must be a literal expression. + +float4 main() : sv_target { return 0; } + + +[pixel shader fail(sm<6) todo] +float a = 7; +float4 b = {1, 2, a, 4}; // initial value must be a literal expression. + +float4 main() : sv_target { return 0; } + + +[pixel shader fail] +Texture2D tex; +struct +{ + Texture2D t; + float a; +} apple = {tex, 4}; // initial value must be a literal expression. + +float4 main() : sv_target +{ + return 0; +} + + +[pixel shader todo] +static const float a = 7; +float4 b = {1, 2, a, 4}; // static constant values are allowed on the initializer. + +float4 main() : sv_target { return b; } + +[test] +uniform 0 float4 10.0 20.0 30.0 40.0 +todo(sm<6) draw quad +probe all rgba (10, 20, 30, 40) + + +[pixel shader todo] +float4 a = {3, 5, float2(4, 4)}; // numeric type initializers are allowed. + +float4 main() : sv_target +{ + return 2 * a; +} + +[test] +uniform 0 float4 10.0 20.0 30.0 40.0 +todo(sm<6) draw quad +probe all rgba (20, 40, 60, 80) + + +[pixel shader todo] +int4 a[2] = {10, 20, float3x2(1, 2, 3, 4, 5, 6)}; // matrix numeric type initializers are allowed. + +float4 main() : sv_target +{ + return 2 * a[1]; +} + +[test] +if(sm<4) uniform 0 float4 10 20 30 40 +if(sm<4) uniform 4 float4 50 60 70 80 +if(sm>=4) uniform 0 int4 10 20 30 40 +if(sm>=4) uniform 4 int4 50 60 70 80 +todo(sm<6) draw quad +probe all rgba (100, 120, 140, 160) + + +[pixel shader todo] +struct apple +{ + float3 a[2]; + int2x2 b; +} ap = {1, 2, 3, 4, 5, 6, 7.5, 8, 9, 10}; + +float4 main() : sv_target +{ + return float4(ap.b); +} + +[test] +uniform 0 float4 10 20 30 0 +uniform 4 float4 40 50 60 0 +if(sm<4) uniform 8 float4 70 90 0 0 +if(sm<4) uniform 12 float4 80 100 0 0 +if(sm>=4) uniform 8 int4 70 90 0 0 +if(sm>=4) uniform 12 int4 80 100 0 0 +todo(sm<6) draw quad +probe all rgba (70, 80, 90, 100) + + +[require] +shader model >= 5.0 + + +% Default values for doubles don't seem to be saved properly. +[pixel shader todo] +double2 m = {1, 2}; +// double2 m; // Offset: 0 Size: 16 +// = 0x00000000 0x00000000 0x40000000 0x00000000 + +float4 main() : sv_target +{ + return m.y; +} + + +[pixel shader todo] +static const float3x2 mat = {10, 20, 30, 40, 50, 60}; +static const float4 array[2] = {1, 2, 3, 4, 5, 6, 7, 8}; +static const int idx = 1; +float3 u = {array[idx].xwwz.xy, mat._m21_m01.x}; // = {5, 8, 60} + +float4 main() : sv_target +{ + return u.y; +}