summaryrefslogtreecommitdiff
path: root/tests/compute/cast-zero-to-struct.slang
blob: 41bc299e53821ecd3491e3c57bfa8087ab8dd59a (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:
//TEST(compute):COMPARE_COMPUTE:-cpu

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):dxbinding(0),glbinding(0),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;
}