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
1.2 KiB33 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type
3//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-mtl -compute -shaderobj -output-using-type -render-features argument-buffer-tier-2
4
5struct TestStruct<Format:__BuiltinIntegerType, let count : int>
6{
7    Format f;
8};
9
10Format testFunction<Format : __BuiltinIntegerType, let count : int>(TestStruct<Format, count> data)
11{
12    return data.f + __int_cast<Format>(count);
13}
14
15//TEST_INPUT: set testBlock = new TestStruct<int, 12>{1}
16ParameterBlock<TestStruct<int, 12>> testBlock;
17
18//TEST_INPUT: set testBlock2 = new TestStruct<int, 12>{2}
19ConstantBuffer<TestStruct<int, 2>> testBlock2;
20
21//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
22RWStructuredBuffer<int> outputBuffer;
23
24[numthreads(1, 1, 1)]
25void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
26{
27    // CHECK: 13
28    outputBuffer[0] = testFunction(testBlock);
29    // CHECK: 13
30    outputBuffer[1] = testFunction<int, 12>(testBlock);
31    // CHECK: 4
32    outputBuffer[2] = testFunction(testBlock2);
33}