vkd3d/tests/hlsl/non-const-indexing.shader_test

350 lines
6.6 KiB
Plaintext
Raw Normal View History

[pixel shader]
uniform float4 f[3];
uniform float2 i;
float4 main() : sv_target
{
return f[i.x + i.y];
}
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 5.0 6.0 7.0 8.0
uniform 8 float4 9.0 10.0 11.0 12.0
uniform 12 float4 0 0 0 0
todo(glsl) draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
uniform 12 float4 1 0 0 0
todo(glsl) draw quad
probe (0, 0) rgba (5.0, 6.0, 7.0, 8.0)
uniform 12 float4 0 1 0 0
todo(glsl) draw quad
probe (0, 0) rgba (5.0, 6.0, 7.0, 8.0)
uniform 12 float4 1 1 0 0
todo(glsl) draw quad
probe (0, 0) rgba (9.0, 10.0, 11.0, 12.0)
[pixel shader]
uniform float i;
float4 main() : SV_TARGET
{
float4 arr = float4(11.0, 12.0, 13.0, 14.0);
return arr[i];
}
[test]
uniform 0 float 0
draw quad
probe (0, 0) rgba (11.0, 11.0, 11.0, 11.0)
uniform 0 float 1
draw quad
probe (0, 0) rgba (12.0, 12.0, 12.0, 12.0)
uniform 0 float 2
draw quad
probe (0, 0) rgba (13.0, 13.0, 13.0, 13.0)
uniform 0 float 3
draw quad
probe (0, 0) rgba (14.0, 14.0, 14.0, 14.0)
[pixel shader]
float i;
float4 main() : sv_target
{
float a[4] = {1, 2, 3, 4};
return a[i];
}
[test]
uniform 0 float 2.3
todo(glsl) draw quad
probe (0, 0) rgba (3, 3, 3, 3)
[pixel shader todo(sm<4)]
uniform float i;
float4 main() : SV_TARGET
{
int4 arr_i = int4(21, 22, 23, 24);
bool4 arr_b = bool4(true, false, true, false);
return float4(arr_i[i], arr_b[i], arr_i[3 - i], arr_b[3 - i]);
}
[test]
uniform 0 float 0
todo(sm<4) draw quad
probe (0, 0) rgba (21.0, 1.0, 24.0, 0.0)
uniform 0 float 1
todo(sm<4) draw quad
probe (0, 0) rgba (22.0, 0.0, 23.0, 1.0)
uniform 0 float 2
todo(sm<4) draw quad
probe (0, 0) rgba (23.0, 1.0, 22.0, 0.0)
uniform 0 float 3
todo(sm<4) draw quad
probe (0, 0) rgba (24.0, 0.0, 21.0, 1.0)
2023-05-04 15:12:29 -07:00
[pixel shader]
2023-05-04 15:12:29 -07:00
uniform float2 i;
float4 main() : sv_target
{
float4 f[3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
return f[i.x + i.y];
}
[test]
uniform 0 float4 0 0 0 0
todo(glsl) draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
2023-05-04 15:12:29 -07:00
uniform 0 float4 1 0 0 0
todo(glsl) draw quad
probe (0, 0) rgba (5.0, 6.0, 7.0, 8.0)
2023-05-04 15:12:29 -07:00
uniform 0 float4 0 1 0 0
todo(glsl) draw quad
probe (0, 0) rgba (5.0, 6.0, 7.0, 8.0)
2023-05-04 15:12:29 -07:00
uniform 0 float4 1 1 0 0
todo(glsl) draw quad
probe (0, 0) rgba (9.0, 10.0, 11.0, 12.0)
[pixel shader]
float4 a;
float4 main() : sv_target
{
float4 arr[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120};
float4 tmp = float4(1, 2, 3, 4);
tmp.yz = arr[a.z].wx;
return tmp;
}
[test]
uniform 0 float4 0 0 2.4 0
todo(glsl) draw quad
probe (0, 0) rgba (1.0, 120.0, 90.0, 4.0)
[pixel shader]
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(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(glsl) draw quad
probe (0, 0) rgba (10, 10, 10, 10)
[pixel shader]
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(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(glsl) draw quad
probe (0, 0) rgba (70, 71, 72, 73)
[pixel shader]
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(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(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
[pixel shader]
int i, j;
float4 main() : sv_target
{
float mut1[4] = {1, 2, 3, 4};
float mut2[4] = {5, 6, 7, 8};
mut1[i] = 100;
mut2[j] = mut1[j];
return float4(mut2[0], mut2[1], mut2[2], mut2[3]);
}
[test]
uniform 0 int 0
uniform 1 int 0
todo(glsl) draw quad
probe (0, 0) rgba (100, 6, 7, 8)
uniform 0 int 2
uniform 1 int 2
todo(glsl) draw quad
probe (0, 0) rgba (5, 6, 100, 8)
uniform 0 int 1
uniform 1 int 3
todo(glsl) draw quad
probe (0, 0) rgba (5, 6, 7, 4)
[pixel shader]
float a, b, c, d;
float e, f, g, h;
int i, j;
float4 main() : sv_target
{
float arr1[8] = {a, a, b, b, c, c, d, d};
float arr2[8] = {e, e, f, f, g, g, h, h};
arr1[i] = arr2[i];
arr2[j] = arr1[j];
return 1000 * float4(arr1[0], arr1[4], arr2[0], arr2[4])
+ 100 * float4(arr1[1], arr1[5], arr2[1], arr2[5])
+ 10 * float4(arr1[2], arr1[6], arr2[2], arr2[6])
+ 1 * float4(arr1[3], arr1[7], arr2[3], arr2[7]);
}
[test]
uniform 0 float4 1 2 3 4
uniform 4 float4 5 6 7 8
uniform 8 int 3
uniform 9 int 4
todo(glsl) draw quad
probe (0, 0) rgba (1126, 3344, 5566, 3788)
[pixel shader]
uint i, j;
float4 main() : sv_target
{
float mut1[4] = {1, 2, 3, 4};
/* dxc emits a pointer bitcast, which results in a VSIR MOV with mismatched data types. */
mut1[i] = asfloat(j);
return float4(mut1[0], mut1[1], mut1[2], mut1[3]);
}
[test]
uniform 0 uint 1
uniform 1 uint 0x40a00000
todo(glsl) draw quad
probe (0, 0) rgba (1, 5, 3, 4)
[require]
% reset requirements
[pixel shader]
uniform float4 f[4];
uniform uint4 u;
uniform uint4 v;
float4 main() : sv_target
{
float temp[4];
temp[0] = f[u.x].x;
temp[1] = f[u.y].x;
temp[2] = f[u.z].x;
temp[3] = f[u.w].x;
return float4(temp[v.x], temp[v.y], temp[v.z], temp[v.w]);
}
% FXC is incapable of compiling this correctly, but results differ for SM1-3 vs SM4-5.
[test]
uniform 0 float 1.0
uniform 4 float 2.0
uniform 8 float 3.0
uniform 12 float 4.0
uniform 16 uint4 3 1 0 2
uniform 20 uint4 0 3 1 2
todo(glsl) draw quad
if(sm<4) probe (0,0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=4 & sm<6) todo probe (0,0) rgba (4.0, 4.0, 4.0, 4.0)
if(sm>=6) probe (0,0) rgba (4.0, 3.0, 2.0, 1.0)
[require]
shader model >= 4.0
[pixel shader]
float4 f[2];
float4 main(uint index : INDEX) : sv_target
{
return f[index];
}