blob: 38366242069132f3a3bc12bf1a01c81bbaa16c40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// cast-zero-to-struct.slang
// Test that HLSL legacy syntax for casting from literal zero
// to a `struct` type works.
//TEST(compute):COMPARE_COMPUTE: -shaderobj
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
struct S
{
int2 a;
int2 b;
int2 c;
}
int test(int val)
{
S s = (S) 0;
s.a.x = val;
s.b.y = val;
s.c.x = val;
int2 t = s.a + s.b*256 + s.c*65536;
return t.x + t.y*16;
}
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<int> gOutputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 tid : SV_DispatchThreadID)
{
int inVal = tid.x;
int outVal = test(inVal);
gOutputBuffer[tid.x] = outVal;
}
|