summaryrefslogtreecommitdiff
path: root/tests/pipeline/ray-tracing/ray-tracing-paramblock-regression.slang
blob: 657618ce3866306c61abe32b7174b6dfbf90a45b (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
// ray-tracing-paramblock-regression.slang

// Regression test for fix to segfault when using ParameterBlock with generics
// in ray tracing shaders

//TEST:SIMPLE(filecheck=CHECK): -target spirv

interface IMatData {}

struct PerDrawSubmesh<T> where T : IMatData
{
    T* p_mat_data;
}

struct RtUbo<T> where T : IMatData
{
    PerDrawSubmesh<T>* p_per_dsm_buff;
}

struct RtPayload
{
    float3 emission = float3(0);
}

struct RtParams<T> where T : IMatData
{
    RtUbo<T> ubo;
};

struct MatData : IMatData
{
    float4 emission;
}

// This used to cause a segfault before the fix
[shader("closesthit")]
void chit_main_with_paramblock(uniform ParameterBlock<RtParams<MatData>> params, in BuiltInTriangleIntersectionAttributes attr, out RtPayload payload)
{
    payload = {};
    payload.emission = float3(1, 0, 0);
}

// CHECK: OpEntryPoint