yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeFix WGSL parameter block binding. (#5500)2533125cb

master
921 B38 linesraw
1// entry-point-uniform-params.slang
2//TEST(compute):COMPARE_COMPUTE:-wgpu -shaderobj
3//TEST(compute):COMPARE_COMPUTE: -shaderobj
4//TEST(compute):COMPARE_COMPUTE:-cuda -shaderobj
5//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
6//TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
7// Test that a shader can be written that
8// only uses entry point `uniform` parameters,
9// without any global parameters.
10
11struct Data
12{
13	int a;
14	int b;
15}
16
17int test(int val, int a, int b)
18{
19	return a*(val+1) + b*(val+2);
20}
21
22[numthreads(4, 1, 1)]
23[shader("compute")]
24void computeMain(
25
26//TEST_INPUT:uniform(data=[256 1]):name=d
27	uniform Data d,
28
29//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
30	uniform RWStructuredBuffer<int> outputBuffer,
31
32	int3 dispatchThreadID : SV_DispatchThreadID)
33{
34    int tid = dispatchThreadID.x;
35    int inVal = tid;
36    int outVal = test(inVal, d.a, d.b);
37    outputBuffer[tid] = outVal;
38}