Skip to content

[SPIR-V] Emit OpacityMicromapIdKHR execution mode for OMM-enabled RayQuery #8889

Description

Description

SPIR-V's equivalent for DXIL's RAYQUERY_FLAG_ALLOW_OPACITY_MICROMAPS on inline ray traces seems to be an execution mode with OpacityMicromapIdKHR 1 referencing an OpSpecConstantTrue (default-true spec constant). Is this something DXC can emit for us? It seems to be cumbersome to use https://github.com/microsoft/DirectXShaderCompiler/wiki/Inline-SPIR%E2%80%90V to emit a vk::ext_execution_mode_id(OpacityMicromapIdKHR, true) via a custom wrapper while still keeping the original constant working for DXIL.

And there's a further limitation linked there:

If using a lib_6_x target profile with multiple entry points, it will only be applied to one of them.

We have multiple entrypoints for RTPSO shaders that all use ray queries, so a possible workaround would need to apply to all of them.

And note that any shader containing OpExtension SPV_KHR_opacity_micromap in current DXC does not get properly deadstripped until the SPIRV-Tools submodule is updated to include KhronosGroup/SPIRV-Tools#6833.

Attributes on constants

As an aside I'd been quite happy to learn that extension and capability attributes can be applied on constants like so:

[[vk::ext_extension("SPV_KHR_opacity_micromap")]]
[[vk::ext_capability(RayTracingOpacityMicromapExecutionModeKHR)]]
static const uint OpacityMicromapIdKHR = 6031;

But these are emitted in the final SPIR-V even if the constant itself is clearly never referenced: https://godbolt.org/z/xc3aPrvad

Is that intended?

Actual Behavior

No OpExecutionModeId OpacityMicromapIdKHR %true is emitted for RayQuery shaders with RAYQUERY_FLAG_ALLOW_OPACITY_MICROMAPS.

Likely complications live in the fact that this execution mode can be a spec constant, likely mimicking the host-settable behaviour for RTPSOs via VK_PIPELINE_CREATE_RAY_TRACING_OPACITY_MICROMAP_BIT_KHR. Unlike DXIL, SPIR-V users might want the ability to actually configure the spec constant instead of hardcoding it based on the presence of RAYQUERY_FLAG_ALLOW_OPACITY_MICROMAPS?

Environment

Footnotes

  1. Using https://github.com/KhronosGroup/Vulkan-Docs/issues/2810 to clarify that this exclusively applies to inline ray tracing, while ray tracing pipelines use the VK_PIPELINE_CREATE_RAY_TRACING_OPACITY_MICROMAP_BIT_KHR host flag. Ray tracing pipeline shaders which perform inline ray queries with OMMs do need the execution mode though.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triagespirvWork related to SPIR-V

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions