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
1004 B42 linesraw
1// entry-point-uniform-params-implicit.slang
2
3// Test that slang can treat a compute shader parameter as `uniform` without explicit `uniform` keyword.
4
5//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj  -xslang -Wno-38040
6//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -xslang -Wno-38040
7//TEST:SIMPLE(filecheck=WARNING): -target spirv
8
9struct Data
10{
11	int a;
12	int b;
13}
14
15int test(int val, int a, int b)
16{
17	return a*(val+1) + b*(val+2);
18}
19
20[numthreads(4, 1, 1)]
21[shader("compute")]
22void computeMain(
23
24//TEST_INPUT:uniform(data=[256 1]):name=d
25// WARNING: ([[# @LINE+1]]): warning 38040
26	Data d,
27
28//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
29	uniform RWStructuredBuffer<int> outputBuffer,
30
31	int3 dispatchThreadID : SV_DispatchThreadID)
32{
33    int tid = dispatchThreadID.x;
34    int inVal = tid;
35    int outVal = test(inVal, d.a, d.b);
36    outputBuffer[tid] = outVal;
37
38    // CHECK: 102
39    // CHECK: 203
40    // CHECK: 304
41    // CHECK: 405
42}