yum-mirror/slang

Making it easier to work with shaders

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

Yong HeVarious WGSL fixes. (#5490)7c2ff5475

master
842 B25 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE_EX: -wgpu -compute -output-using-type
4
5//TEST_INPUT: set g_texture = Texture2D(size=8, content = one)
6//TEST_INPUT: set g_sampler = Sampler
7//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
8
9Texture2D g_texture;
10SamplerState g_sampler;
11RWStructuredBuffer<float> outputBuffer;
12
13float4 sample(float2 uv, constexpr int2 ofs )
14{
15    return g_texture.SampleLevel(g_sampler, uv, 0.0, ofs); 
16}
17
18[numthreads(1, 1, 1)]
19void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
20{
21    float4 result = 0;
22    for (int i = 0; i < 3; i++)
23        result += sample(float2(1.0), int2(i, i));
24    outputBuffer[dispatchThreadID.x] = result.x;
25}