forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc-resource-param.slang
36 lines (28 loc) · 1.07 KB
/
func-resource-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
// func-resource-param.slang
// Test that a function with a resource parameter that
// requires non-trivial legalization can be compiled
// to work on GLSL-based targets.
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-dx12 -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//NO_TEST:SIMPLE:-target glsl -entry computeMain -stage compute -validate-ir -dump-ir
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
//TEST_INPUT:ubuffer(data=[0 16 32 48], stride=4):name=inputBuffer
RWStructuredBuffer<int> inputBuffer;
int helper(RWStructuredBuffer<int> buffer, int index)
{
return buffer[index];
}
int test(int val)
{
return helper(inputBuffer, val) + val;
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int inVal = (int) dispatchThreadID.x;
int outVal = test(inVal);
outputBuffer[dispatchThreadID.x] = outVal;
}