From 58a6db5589cfc8a6f4e3d56666e0dcb611929b8e Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 4 Apr 2024 12:09:10 -0300 Subject: [PATCH] tests: Test default values for constant buffer variables. --- tests/hlsl/default-values.shader_test | 105 ++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tests/hlsl/default-values.shader_test b/tests/hlsl/default-values.shader_test index 6550c67b..0427f659 100644 --- a/tests/hlsl/default-values.shader_test +++ b/tests/hlsl/default-values.shader_test @@ -115,6 +115,111 @@ todo(sm<6) draw quad probe all rgba (70, 80, 90, 100) +[pixel shader] +cbuffer buff +{ + 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(glsl) draw quad +probe all rgba (10, 20, 50, 60) + + +[pixel shader fail(sm<6) todo] +cbuffer buff +{ + 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] +cbuffer buff +{ + float a = 7; + float4 b = {1, 2, a, 4}; // initial value must be a literal expression. +} + +float4 main() : sv_target { return 0; } + + +[pixel shader] +static const float a = 7; + +cbuffer buff +{ + 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 20 30 40 +todo(glsl) draw quad +probe all rgba (10, 20, 30, 40) + + +[pixel shader] +cbuffer buff +{ + float2 a = {1, 2}; + float4 b = {3, 5, float2(4, 4)}; // numeric type initializers are allowed. +} + +float4 main() : sv_target +{ + return 2 * b; +} + +[test] +if(sm<4) uniform 0 float4 30 50 40 40 +if(sm>=4) uniform 0 float4 10 20 0 0 +if(sm>=4) uniform 4 float4 30 50 40 40 +todo(glsl) draw quad +probe all rgba (60, 100, 80, 80) + + +[pixel shader] +cbuffer buff +{ + 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(glsl) draw quad +probe all rgba (70, 80, 90, 100) + + [require] shader model >= 5.0