blob: 891ead9606c56b4eb0301c010aadb61d14e2f72d (
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
|
// optix-ignore-hit.slang
//TEST:SIMPLE(filecheck=CHECK): -target cuda -entry anyHitShader
//TEST:SIMPLE(filecheck=CHECK-PTX): -target ptx -Xnvrtc -I"./external/optix-dev/include/"
//CHECK: HitBuffer_insert_0(((HitBuffer_0 *)getOptiXRayPayloadPtr()), hit_0.t_0);
//CHECK: optixIgnoreIntersection
//CHECK-PTX: _optix_get_ray_tmax
struct HitBuffer
{
float last;
[mutating]
void insert(float t) { last = t; }
}
struct RayHit
{
float t;
int instanceID;
}
[shader("anyhit")]
void anyHitShader(inout HitBuffer rayHitBuffer)
{
// Create a hit with current intersection data
float currentT = RayTCurrent();
int instanceID = InstanceID();
RayHit hit = { currentT, instanceID };
// Modify the inout parameter
rayHitBuffer.insert(hit.t);
// CHECK-PTX: _optix_ignore_intersection
// Early exit - should not lose the modification to inout rayHitBuffer
if (hit.t < rayHitBuffer.last)
IgnoreHit();
// This line should never execute if IgnoreHit() is called,
// but parameter changes should still propagate back
}
|