DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] Feature request: Allow constructing RaytracingAccelerationStructure from physical device address

Open natevm opened this issue 3 years ago • 0 comments

Hello,

GLSL allows users to construct a accelerationStructureEXT from a physical device address, which under the hood uses the OpConvertUToAccelerationStructureKHR SPIR-V instruction to convert the address into a ray tracing handle. But currently, HLSL does not specify any constructors to a RaytracingAccelerationStructure.

This is beneficial, as the 64 bit address (obtainable from vkGetAccelerationStructureDeviceAddressKHR) has a defined size. If I want to store acceleration structures in a ray generation SBT record, I need to memcpy some bytes of data into that SBT record, and I can memcpy over a 64 bit address, whereas cannot memcpy over a blackbox RaytracingAccelerationStructure.

At the moment, I have the following code which allows me to actually use that address device side, but I feel like it would be a nice more official feature in the "vk::" namespace that doesn't require emitting SPIR-V instructions in order to enable this GLSL capability in HLSL as well.

[[vk::ext_instruction(4447)]] //  translates to OpConvertUToAccelerationStructureKHR
RaytracingAccelerationStructure getAccelHandle(uint64_t address);

natevm avatar Aug 13 '22 17:08 natevm