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