blob: 630efb1e0b04ff87fad3f75e72d66220f98d33ac (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// struct-bit-cast.slang
//TEST(compute):COMPARE_COMPUTE: -shaderobj
// Test that bit_cast works for bit-reinterpreting one struct type as another.
struct Foo
{
uint a;
float b;
float2 fvec;
}
struct Inner
{
int v;
uint s;
}
struct Bar
{
int u;
Inner i;
uint t;
}
int test0(int val)
{
Bar b;
b.u = val;
b.i.v = asint(2.0f);
b.i.s = asuint(1.25);
b.t = asuint(0.25);
Foo f = bit_cast<Foo, Bar>(b);
return int(f.a) + (int)f.b + int(float(f.fvec.x / f.fvec.y)); // val + 2 + 5
}
struct Smaller
{
int s;
}
struct Larger
{
int x, y;
}
int test1()
{
return 1;
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
int inVal = tid;
int outVal = test0(inVal) + test1();
outputBuffer[tid] = outVal;
}
|