yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix type checking on generic extensions. (#5316)c97166aed

master
1.1 KiB45 linesraw
1import fcpw;
2
3#define UNDEFINED_BVH_TYPE 0
4#define LINE_SEGMENT_BVH 1
5#define TRIANGLE_BVH 2
6#define LINE_SEGMENT_SNCH 3
7#define TRIANGLE_SNCH 4
8
9#ifndef _BVH_TYPE
10#define _BVH_TYPE UNDEFINED_BVH_TYPE
11#endif
12
13#if _BVH_TYPE == LINE_SEGMENT_BVH
14uniform ParameterBlock<Bvh<BvhNode, LineSegment, NoSilhouette>> gBvh;
15
16#elif _BVH_TYPE == TRIANGLE_BVH
17uniform ParameterBlock<Bvh<BvhNode, Triangle, NoSilhouette>> gBvh;
18
19#elif _BVH_TYPE == LINE_SEGMENT_SNCH
20uniform ParameterBlock<Bvh<SnchNode, LineSegment, Vertex>> gBvh;
21
22#elif _BVH_TYPE == TRIANGLE_SNCH
23uniform ParameterBlock<Bvh<SnchNode, Triangle, Edge>> gBvh;
24
25#else
26// Compile time error
27#error _BVH_TYPE is not set to a supported type
28#endif
29
30[shader("compute")]
31[numthreads(256, 1, 1)]
32void refit(uint3 threadId: SV_DispatchThreadID,
33           uniform StructuredBuffer<uint> nodeIndices,
34           uniform uint firstNodeOffset,
35           uniform uint nodeCount)
36{
37    uint index = threadId.x;
38    if (index >= nodeCount)
39    {
40        return;
41    }
42
43    uint nodeIndex = nodeIndices[firstNodeOffset + index];
44    gBvh.refit(nodeIndex);
45}