blob: 72309b7701e0e6a12beb77a18b60b2954f3c61f8 (
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
44
45
46
47
|
//DISABLE_TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain -zero-initialize
//DISABLE_TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain -zero-initialize
// HLSL-NOT: RayQuery{{.*}} {{.*}} =
// GLSL-NOT: rayQueryEXT {{.*}} =
uniform RaytracingAccelerationStructure scene;
RWStructuredBuffer<float> outputBuffer;
bool traceRayClosestHit(
float3 rayOrigin,
float3 rayDir,
out float t)
{
RayDesc ray;
ray.Origin = rayOrigin;
ray.TMin = 0.01f;
ray.Direction = rayDir;
ray.TMax = 1e4f;
RayQuery<RAY_FLAG_NONE> q;
let rayFlags = RAY_FLAG_NONE;
q.TraceRayInline(
scene,
rayFlags,
0xff,
ray);
q.Proceed();
if(q.CommittedStatus() == COMMITTED_TRIANGLE_HIT)
{
t = q.CommittedRayT();
return true;
}
unused(t);
return false;
}
[shader("compute")]
[numthreads(1,1,1)]
void computeMain(
uint3 threadIdx : SV_DispatchThreadID)
{
float t = 0.0;
traceRayClosestHit(float3(0.1, 0.1, 0.0), float3(0,0,1), t);
outputBuffer[threadIdx.x] = t;
}
|