From e0cfd8f86a45d8dce65f662578205c30b7913085 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Mon, 8 Jul 2024 17:51:04 -0400 Subject: [PATCH] tests: Add additional non-constant array indexing tests. --- tests/hlsl/non-const-indexing.shader_test | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/hlsl/non-const-indexing.shader_test b/tests/hlsl/non-const-indexing.shader_test index 4e5eb8fc..f8901ffe 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -134,6 +134,95 @@ todo(sm<4 | glsl) draw quad probe (0, 0) rgba (1.0, 120.0, 90.0, 4.0) +[pixel shader todo(sm<4)] +float i, j; + +float4 main() : sv_target +{ + float arr[6][2] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + + return arr[i][j]; +} + +[test] +if(sm<4) uniform 0 float 3 +if(sm<4) uniform 4 float 1 +if(sm>=4) uniform 0 float4 3 1 0 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (7, 7, 7, 7) +if(sm<4) uniform 0 float 5 +if(sm<4) uniform 4 float 0 +if(sm>=4) uniform 0 float4 5 0 0 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (10, 10, 10, 10) + + +[pixel shader todo(sm<4)] +float i, j; +float k; + +float4 main() : sv_target +{ + float4 arr[4][3] = { + 0, 1, 2, 3, + 10, 11, 12, 13, + 20, 21, 22, 23, + 30, 31, 32, 33, + 40, 41, 42, 43, + 50, 51, 52, 53, + 60, 61, 62, 63, + 70, 71, 72, 73, + 80, 81, 82, 83, + 90, 91, 92, 93, + 100, 101, 102, 103, + 110, 111, 112, 113, + }; + + return arr[i + k][j + k]; +} + +[test] +if(sm<4) uniform 0 float 2 +if(sm<4) uniform 4 float 1 +if(sm<4) uniform 8 float -1 +if(sm>=4) uniform 0 float4 2 1 -1 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (30, 31, 32, 33) +if(sm<4) uniform 0 float 1 +if(sm<4) uniform 4 float 0 +if(sm<4) uniform 8 float 1 +if(sm>=4) uniform 0 float4 1 0 1 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (70, 71, 72, 73) + + +[pixel shader todo(sm<4)] +float i, j; + +float4 main() : sv_target +{ + struct + { + float a; + float b[3]; + } apples[4] = {42, 0, 1, 2, 42, 3, 4, 5, 42, 6, 7, 8, 42, 9, 10, 11}; + + return apples[i - 10].b[j - 10]; +} + +[test] +if(sm<4) uniform 0 float 11 +if(sm<4) uniform 4 float 12 +if(sm>=4) uniform 0 float4 11 12 0 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (5, 5, 5, 5) +if(sm<4) uniform 0 float 13 +if(sm<4) uniform 4 float 10 +if(sm>=4) uniform 0 float4 13 10 0 0 +todo(sm<4 | glsl) draw quad +probe (0, 0) rgba (9, 9, 9, 9) + + % SM1 doesn't support relative addressing if it is used in a l-value. [require] shader model >= 4.0