forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc-cbuffer-param.slang
44 lines (33 loc) · 1.26 KB
/
func-cbuffer-param.slang
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
// func-cbuffer-param.slang
// Test that passing a `ConstantBuffer<X>` parameter
// into a function works across all target.
// This has a compatibility issue on Windows 10.0.10586 on Dx12 - dxcompiler will crash (can remove form tests with -exclude compatibility-issue)
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan, compatibility-issue):COMPARE_COMPUTE_EX:-dx12 -compute -use-dxil -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
struct Data
{
int4 val[4];
}
//TEST_INPUT:cbuffer(data=[0 1 2 3 16 17 18 19 32 33 34 35 48 49 50 51]):name=a
ConstantBuffer<Data> a;
//TEST_INPUT:cbuffer(data=[16 17 18 19 32 33 34 35 48 49 50 51 64 65 66 67]):name=b
ConstantBuffer<Data> b;
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
int helper(ConstantBuffer<Data> buffer, int index)
{
return buffer.val[index].x;
}
int test(int val)
{
return val + helper(a, val) + helper(b, val);
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int inVal = (int) dispatchThreadID.x;
int outVal = test(inVal);
outputBuffer[dispatchThreadID.x] = outVal;
}