yum-mirror/slang

Making it easier to work with shaders

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

Theresa FoleySplit overloaded uses of RefType in front-end (#8427)c35b763f8

master
1.1 KiB40 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj
3
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
5RWStructuredBuffer<int> outputBuffer;
6
7// TODO(tfoley): What this test is testing seems to be outside
8// the scope of what we ever intend to support in user code.
9// Returning an `Ref<T>` is supposed to be a core-module-only
10// thing, and even then is something that we would like to do less
11// of over time.
12//
13// The only purpose of this test *seems* to be ensuring that this
14// particular function (and the `groupshared` declaration inside
15// it) "works," but the function itself is not something that we
16// intend to be supported in Slang.
17// 
18[ForceInline]
19Ref<uint> table<let n: int>(int index)
20{
21    static groupshared uint array[n];
22    return array[index];
23}
24
25struct S<let n : int>
26{
27    static const int M = n * 2;
28    int doSomething()
29    {
30        table<M>(0) = M;
31        return int(table<M>(0));
32    }
33}
34
35[numthreads(1, 1, 1)]
36void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
37{
38    S<2> s;
39    outputBuffer[0] = s.doSomething();
40}