yum-mirror/slang

Making it easier to work with shaders

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

Yong HeSupport visibility control and default to `internal`. (#3380)11111e573

master
1.2 KiB67 linesraw
1//DISABLE_TEST:SIMPLE:-target dxil -entry computeMain -profile cs_6_2
2
3/* Fails with:
4
5(0): internal error 99999: unimplemented feature in Slang compiler: unexpected IR opcode during code emit
6*/
7
8// Dynamic dispatch with a resource type
9RWStructuredBuffer<float> outputBuffer;
10
11interface IGetTexture
12{
13    Texture2D<float> getTexture();
14};
15
16struct SomeData : IGetTexture
17{
18    Texture2D<float> getTexture() { return tex; }
19    Texture2D<float> tex;
20};
21
22interface IInterface
23{
24    associatedtype Type;
25    IGetTexture getType();
26};
27
28// Need public to make these conformances available
29export struct A : IInterface
30{
31    typedef SomeData Type;
32    IGetTexture getType() { Type t = { gTexA }; return t; }
33};
34
35export struct B : IInterface
36{
37    typedef SomeData Type;
38    IGetTexture getType() { Type t = { gTexB }; return t; }
39};
40
41Texture2D<float> gTexA, gTexB;
42
43
44[numthreads(4, 1, 1)]
45void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
46{
47	uint tid = dispatchThreadID.x;
48
49    A a;
50    B b;
51    
52    IInterface intf;
53    
54    if (tid & 1)
55    {
56        intf = a;
57    }
58    else
59    {
60        intf = b;
61    }
62    
63    var getTex = intf.getType();
64    let tex = getTex.getTexture();
65    
66	outputBuffer[tid] = tex.Load(int3(tid, tid, 0));
67}