From 969d101aff074675de32bdbe6b97baf744634f78 Mon Sep 17 00:00:00 2001 From: Dario Mylonopoulos <32958057+ramenguy99@users.noreply.github.com> Date: Fri, 21 Mar 2025 18:21:04 +0100 Subject: Support spirv ops added by multiple extensions (#6615) * spirv: add support for ops added by multiple extensions Some spirv ops are added by multiple extensions and capabilities. This commit adds support to avoid emitting unnecessary extensions and capabilities if one of the options is already required by some other op. * spirv: allow OpRaytracingAccelerationStructure to use multiple extensions This Op is provided by both SPV_KHR_ray_tracing and SPV_KHR_ray_query and the respective capabilities. Use one if already available and otherwise fall back to SPV_KHR_ray_tracing. * tests/vkray: add negative checks for RayTracingKHR and RayQueryKHR - Add new rayquery-compute.slang to test that only RayQueryKHR is needed in compute shaders. - Add checks for RayTracingKHR and RayQueryKHR capabilities and extensions in raygen.slang --------- Co-authored-by: Ellie Hermaszewska --- tests/vkray/raygen.slang | 4 ++++ tests/vkray/rayquery-compute.slang | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/vkray/rayquery-compute.slang (limited to 'tests') diff --git a/tests/vkray/raygen.slang b/tests/vkray/raygen.slang index 28bad734a..653435a65 100644 --- a/tests/vkray/raygen.slang +++ b/tests/vkray/raygen.slang @@ -117,6 +117,10 @@ void main() outputImage[int2(gl_LaunchIDNV.xy)] = float4(color, 1.0); } +// CHECK_SPV: OpCapability RayTracingKHR +// CHECK_SPV-NOT: OpCapability RayQueryKHR +// CHECK_SPV: OpExtension "SPV_KHR_ray_tracing" +// CHECK_SPV-NOT: OpExtension "SPV_KHR_ray_query" // CHECK_SPV: %{{.*}} = OpVariable %_ptr_RayPayload{{NV|KHR}}_ReflectionRay{{.*}} RayPayload // CHECK_SPV: OpTraceRayKHR // CHECK_SPV: OpTraceRayKHR diff --git a/tests/vkray/rayquery-compute.slang b/tests/vkray/rayquery-compute.slang new file mode 100644 index 000000000..2de53cdcc --- /dev/null +++ b/tests/vkray/rayquery-compute.slang @@ -0,0 +1,19 @@ +// rayquery-compute.slang +//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry main -target spirv-assembly -emit-spirv-directly + +RaytracingAccelerationStructure accelerationStructure; + +[numthreads(1, 1, 1)] +void main(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + RayQuery rayQuery; + + uint instanceInclusionMask = 0x00; + RayDesc rayDesc; + rayQuery.TraceRayInline(accelerationStructure, RAY_FLAG_NONE, instanceInclusionMask, rayDesc); +} + +// CHECK: OpCapability RayQueryKHR +// CHECK-NOT: OpCapability RayTracingKHR +// CHECK: OpExtension "SPV_KHR_ray_query" +// CHECK-NOT: OpExtension "SPV_KHR_ray_tracing" -- cgit v1.2.3