Add ray query capability if acceleration structure or ray query types declared (#2469)
* Add ray query capability if acceleration structure used
Fixes #2430
in non-ray tracing stages and the extension is enabled
* Add ray query capability if ray query declared
* Fix printing of TypeRayQueryKHR
It's no longer spelled with "Provisional"
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index 18ef64f..4a489df 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -3778,10 +3778,36 @@
spvType = builder.makeUintType(32);
break;
case glslang::EbtAccStruct:
+ switch (glslangIntermediate->getStage()) {
+ case EShLangRayGen:
+ case EShLangIntersect:
+ case EShLangAnyHit:
+ case EShLangClosestHit:
+ case EShLangMiss:
+ case EShLangCallable:
+ // these all should have the RayTracingNV/KHR capability already
+ break;
+ default:
+ {
+ auto& extensions = glslangIntermediate->getRequestedExtensions();
+ if (extensions.find("GL_EXT_ray_query") != extensions.end()) {
+ builder.addExtension(spv::E_SPV_KHR_ray_query);
+ builder.addCapability(spv::CapabilityRayQueryKHR);
+ }
+ }
+ break;
+ }
spvType = builder.makeAccelerationStructureType();
break;
case glslang::EbtRayQuery:
- spvType = builder.makeRayQueryType();
+ {
+ auto& extensions = glslangIntermediate->getRequestedExtensions();
+ if (extensions.find("GL_EXT_ray_query") != extensions.end()) {
+ builder.addExtension(spv::E_SPV_KHR_ray_query);
+ builder.addCapability(spv::CapabilityRayQueryKHR);
+ }
+ spvType = builder.makeRayQueryType();
+ }
break;
case glslang::EbtReference:
{
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index e6ad4c1..de681a8 100644
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -1380,7 +1380,7 @@
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
- case OpTypeRayQueryKHR: return "OpTypeRayQueryProvisionalKHR";
+ case OpTypeRayQueryKHR: return "OpTypeRayQueryKHR";
case OpRayQueryInitializeKHR: return "OpRayQueryInitializeKHR";
case OpRayQueryTerminateKHR: return "OpRayQueryTerminateKHR";
case OpRayQueryGenerateIntersectionKHR: return "OpRayQueryGenerateIntersectionKHR";