yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.4 KiB63 linesraw
1// Stack overflow bug in type checking when using auto type deduction in a generic method.
2
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -output-using-type
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -output-using-type
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute  -output-using-type
6
7[anyValueSize(12)]
8interface IBSDF
9{
10    uint getLobes();
11}
12
13[anyValueSize(16)]
14interface IMaterial
15{
16    associatedtype BSDF : IBSDF;
17    BSDF setupBSDF();
18}
19
20struct StandardBSDF : IBSDF
21{
22    uint getLobes()
23    {
24        return 0;
25    }
26}
27
28struct StandardMaterial : IMaterial
29{
30    typedef StandardBSDF BSDF;
31    StandardBSDF setupBSDF() { StandardBSDF g; return g; }
32};
33
34//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer
35RWStructuredBuffer<float> gOutputBuffer;
36
37//TEST_INPUT: type_conformance StandardMaterial:IMaterial = 0
38
39interface IInterface
40{
41    void randomStuff();
42};
43struct Impl : IInterface
44{
45    void randomStuff(){}
46};
47
48void test<R : IInterface>(R r, int id)
49{
50    float result = 0.0;
51    // Use of auto type deduction from a generic method leads to stack overflow during
52    // type checking for `bsdf.getLobes`.
53    let bsdf = createDynamicObject<IMaterial, int>(id, 0).setupBSDF();
54    result = bsdf.getLobes();
55    gOutputBuffer[0] = float(result);
56}
57
58[numthreads(1, 1, 1)]
59void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
60{
61    Impl impl;
62    test(impl, int(dispatchThreadID.x));
63}