Skip to content

Commit e679b1d

Browse files
ustachowigcbot
authored andcommitted
Use Ray Query Return value in Compute Ray Tracing Extension
Modified intel_get_hit_candidate and intel_is_traversal_done functions.
1 parent 6a6a8a0 commit e679b1d

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

IGC/BiFModule/Headers/bif_flag_controls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ BIF_FLAG_CONTROL(int, MaxHWThreadIDPerSubDevice)
3838
BIF_FLAG_CONTROL(bool, UseAssumeInGetGlobalId)
3939
BIF_FLAG_CONTROL(int, JointMatrixLoadStoreOpt)
4040
BIF_FLAG_CONTROL(bool, UseOOBChecks)
41+
BIF_FLAG_CONTROL(bool, IsRayQueryReturnOptimizationEnabled)
4142
BIF_FLAG_CONTROL(bool, UseBindlessImage)
4243
#endif // __BIF_FLAG_CONTROL_H__

IGC/BiFModule/Languages/OpenCL/Raytracing/IBiF_intel_rt_production.cl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,23 @@ intel_float4x3 intel_get_hit_object_to_world(
375375
intel_candidate_type_t
376376
intel_get_hit_candidate(intel_ray_query_t rayquery, intel_hit_type_t hit_type)
377377
{
378+
if (BIF_FLAG_CTRL_GET(IsRayQueryReturnOptimizationEnabled))
379+
{
380+
rtfence_t fence = __builtin_IB_intel_query_rt_fence(rayquery);
381+
uintptr_t fenceInt = (uintptr_t)fence;
382+
383+
intel_candidate_type_t committedStatus = (fenceInt >> 1) & 0x3;
384+
intel_candidate_type_t candidateType = (fenceInt>> 3) & 0x1;
385+
386+
if (hit_type == intel_hit_type_committed_hit)
387+
{
388+
return committedStatus - 1;
389+
}
390+
else if (hit_type == intel_hit_type_potential_hit)
391+
{
392+
return candidateType;
393+
}
394+
}
378395
return MemHit_getLeafType(get_query_hit(rayquery, hit_type)) == NODE_TYPE_QUAD
379396
? intel_candidate_type_triangle
380397
: intel_candidate_type_procedural;
@@ -446,6 +463,16 @@ int intel_get_ray_mask(intel_ray_query_t rayquery, uint bvh_level)
446463
// a procedural leaf or a non-opaque triangle leaf, and requires shader processing.
447464
bool intel_is_traversal_done(intel_ray_query_t rayquery)
448465
{
466+
if (BIF_FLAG_CTRL_GET(IsRayQueryReturnOptimizationEnabled))
467+
{
468+
rtfence_t fence = __builtin_IB_intel_query_rt_fence(rayquery);
469+
uintptr_t fenceInt = (uintptr_t)fence;
470+
471+
bool proceedFurther = (fenceInt & 0x1) != 0;
472+
473+
474+
return !proceedFurther;
475+
}
449476
bool isTraversalDone = MemHit_getDone(get_query_hit(rayquery, intel_hit_type_potential_hit));
450477
return isTraversalDone;
451478
}

IGC/Compiler/Builtins/BIFFlagCtrl/BIFFlagCtrlResolution.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void BIFFlagCtrlResolution::FillFlagCtrl() {
9797
}
9898

9999
BIF_FLAG_CTRL_SET(UseOOBChecks, PtrCGC->platform.needsOutOfBoundsBuiltinChecks());
100+
BIF_FLAG_CTRL_SET(IsRayQueryReturnOptimizationEnabled, PtrCGC->platform.isRayQueryReturnOptimizationEnabled());
100101

101102
// NOTE: No need to check for UseLegacyBindlessMode,
102103
// as it's unrelated to images.

IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXBIFFlagCtrlResolution.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void GenXBIFFlagCtrlResolution::FillFlagCtrl() {
9494
BIF_FLAG_CTRL_SET(UseNativeFP64GlobalAtomicAdd, false);
9595
BIF_FLAG_CTRL_SET(MaxHWThreadIDPerSubDevice, 1);
9696
BIF_FLAG_CTRL_SET(UseOOBChecks, false);
97+
BIF_FLAG_CTRL_SET(IsRayQueryReturnOptimizationEnabled, false);
9798
BIF_FLAG_CTRL_SET(UseBindlessImage, false);
9899
}
99100

0 commit comments

Comments
 (0)