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 KiB51 linesraw
1// Tests generating dynamic dispatch code for a function
2// with existential-struct-typed param by specializing it
3// with __Dynamic. This verifies that the handling of
4// "partially" specializing an existential type is correct.
5
6//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj
7//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
8
9[anyValueSize(8)]
10interface IInterface
11{
12    uint eval();
13}
14
15export struct Impl : IInterface
16{
17    uint val;
18    uint eval()
19    {
20        return val;
21    }
22};
23
24struct Params
25{
26    StructuredBuffer<IInterface> obj;
27};
28
29//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer
30RWStructuredBuffer<uint> gOutputBuffer;
31
32void compute(uint tid, Params p)
33{
34    gOutputBuffer[tid] = p.obj[0].eval();
35}
36
37//TEST_INPUT: entryPointExistentialType __Dynamic
38
39[numthreads(4, 1, 1)]
40void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID,
41
42//TEST_INPUT:begin_buffer(stride=8):name=params.obj
43//TEST_INPUT:begin_object(type=Impl)
44//TEST_INPUT:uniform(data=[1]):name=val
45//TEST_INPUT:end
46//TEST_INPUT:end
47    uniform Params params)
48{
49	uint tid = dispatchThreadID.x;
50	compute(tid, params);
51}