yum-mirror/slang

Making it easier to work with shaders

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

Harsh Aggarwal (NVIDIA)Fix intrinsic LoadLocalRootTableConstant for optix (#7949)e595743b5

master
1.1 KiB40 linesraw
1// optix-ignore-hit.slang
2//TEST:SIMPLE(filecheck=CHECK): -target cuda -entry anyHitShader
3//TEST:SIMPLE(filecheck=CHECK-PTX): -target ptx -Xnvrtc -I"./external/optix-dev/include/"
4//CHECK: HitBuffer_insert_0(((HitBuffer_0 *)getOptiXRayPayloadPtr()), hit_0.t_0);
5//CHECK: optixIgnoreIntersection
6
7//CHECK-PTX: _optix_get_ray_tmax
8
9struct HitBuffer
10{
11    float last;
12    [mutating]
13    void insert(float t) { last = t; }
14}
15
16struct RayHit 
17{
18    float t;
19    int instanceID;
20}
21
22[shader("anyhit")]
23void anyHitShader(inout HitBuffer rayHitBuffer)
24{
25    // Create a hit with current intersection data
26    float currentT = RayTCurrent();
27    int instanceID = InstanceID();
28    RayHit hit = { currentT, instanceID };
29    
30    // Modify the inout parameter
31    rayHitBuffer.insert(hit.t);
32    
33    // CHECK-PTX: _optix_ignore_intersection
34    // Early exit - should not lose the modification to inout rayHitBuffer
35    if (hit.t < rayHitBuffer.last)
36        IgnoreHit();
37    
38    // This line should never execute if IgnoreHit() is called,
39    // but parameter changes should still propagate back
40}