yum-mirror/slang

Making it easier to work with shaders

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

venkataram-nvWarnings function parameters (#4626)05547e253

master
936 B42 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2
3[Specialize]
4interface IAssoc
5{
6    int getInner();
7}
8
9interface IFoo
10{
11    associatedtype Assoc : IAssoc;
12    Assoc getValue();
13}
14
15struct Impl : IFoo
16{
17    struct Assoc : IAssoc { int getInner() { return 1; } }
18    Assoc getValue() { Assoc r; return r; }
19}
20
21struct GenType<T : IFoo> : IDefaultInitializable
22{
23    T obj;
24    int doThing()
25    {
26        IAssoc soc = obj.getValue(); // "boxing" into an existential
27
28        // a specialized version of this function should call specialized method instead of going through dynamic dispatch.
29        return soc.getInner();
30    }
31}
32
33//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
34RWStructuredBuffer<int> gOutputBuffer;
35
36[numthreads(4, 1, 1)]
37void computeMain(int3 dispatchThreadID: SV_DispatchThreadID)
38{
39    int tid = dispatchThreadID.x;
40    GenType<Impl> val;
41    gOutputBuffer[tid] = val.doThing();
42}