summaryrefslogtreecommitdiffstats
path: root/tests/bugs/gh-1990.slang
blob: 885c37ee6ce27935075923367fcad9357e4c5512 (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
// Stack overflow bug in type checking when using auto type deduction in a generic method.

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute  -output-using-type

[anyValueSize(12)]
interface IBSDF
{
    uint getLobes();
}

[anyValueSize(16)]
interface IMaterial
{
    associatedtype BSDF : IBSDF;
    BSDF setupBSDF();
}

struct StandardBSDF : IBSDF
{
    uint getLobes()
    {
        return 0;
    }
}

struct StandardMaterial : IMaterial
{
    typedef StandardBSDF BSDF;
    StandardBSDF setupBSDF() { StandardBSDF g; return g; }
};

//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
RWStructuredBuffer<float> gOutputBuffer;

//TEST_INPUT: type_conformance StandardMaterial:IMaterial = 0

interface IInterface
{
    void randomStuff();
};
struct Impl : IInterface
{
    void randomStuff(){}
};

void test<R : IInterface>(R r, int id)
{
    float result = 0.0;
    // Use of auto type deduction from a generic method leads to stack overflow during
    // type checking for `bsdf.getLobes`.
    let bsdf = createDynamicObject<IMaterial, int>(id, 0).setupBSDF();
    result = bsdf.getLobes();
    gOutputBuffer[0] = float(result);
}

[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    Impl impl;
    test(impl, int(dispatchThreadID.x));
}