forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry-point-uniform-params.slang
56 lines (44 loc) · 1.26 KB
/
entry-point-uniform-params.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
45
46
47
48
49
50
51
52
53
54
55
56
// entry-point-uniform-params.slang
// Confirm that `uniform` parameters on
// entry points are allowed, and work as expected.
//DISABLE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp
//TEST(compute):COMPARE_COMPUTE: -dx12 -shaderobj
//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj
//TEST(compute):COMPARE_COMPUTE: -dx11 -shaderobj
//TEST(compute):COMPARE_COMPUTE: -cuda -shaderobj
//TEST(compute):COMPARE_COMPUTE: -cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE: -metal -shaderobj
struct Signs
{
int a;
}
struct Stuff
{
int b;
}
struct Things
{
int c;
}
// A shader parameter at global scope should be assigned
// a register/binding before any related to the entry point.
//TEST_INPUT:cbuffer(data=[1 0 0 0]):name=signs
ConstantBuffer<Signs> signs;
[numthreads(4, 1, 1)]
void computeMain(
//TEST_INPUT:uniform(data=[2]):name=stuff
uniform Stuff stuff,
//TEST_INPUT:uniform(data=[3]):name=things
uniform Things things,
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
uniform RWStructuredBuffer<int> outputBuffer,
int3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
int val = 0;
val = val*16 + signs.a;
val = val*16 + stuff.b;
val = val*16 + things.c;
val = val*16 + tid;
outputBuffer[tid] = val;
}