gfx
gfx copied to clipboard
RTX Extensions for DX12, Vulkan and OpenGL
I'm not sure what the protocol is for extension support, but with Nvidia's newest GPUs they have also helped to add ray-tracing extensions to DirectX 12, Vulkan ~~and even OpenGL~~. These three extensions are very similar, so adding them to the HAL would be nice to have.
Quick links: VK_NV_raytracing GLSL_NV_raytracing SPV_NV_raytracing
Additionally, I found that Metal supports some ray-tracing acceleration via the Metal Performance Shaders.
Any progress on this?
Whatever we expose will likely be based on Khronos efforts, and there isn't anything yet to target, see https://github.com/KhronosGroup/Vulkan-Docs/issues/686
Nvidia's newest GPUs they have also helped to add ray-tracing extensions to DirectX 12, Vulkan and even OpenGL
Actually there is no OpenGL support. The VK/GLSL/SPV are all part of the Vulkan extension (which is now called VK_NV_ray_tracing btw).
Ah, I see. Slightly unfortunate but understandable. I've updated the links as well, which seemed to have rotted due to the name change.
and even OpenGL
Can be opted by OptiX, but may have some problems with shaders compilation. Can be used Vulkan interop (but better use Vulkan itself).
For DirectX 12 can be used DXR. For Vulkan API can be used VK_NV_ray_tracing. For shading language can be used HLSL with DXC (for both API).
Let me expand on the previous answer. Surely, there are many targets that support some way of raytracing. However, Vulkan itself doesn't have a vendor-independent API for this, and we are modelling gfx-rs API after Vulkan. So it's not clear how to expose this now. Whatever we implement today would have to be changed (possibly, in a major way) when/if Vulkan comes up with a standard API for raytracing.
Saying that, any ideas and PRs on rolling out the initial implementation here are welcome!
Hi @kvark! I'm interested in learning about ray tracing APIs and would love to take a stab at this. Do you think an API in gfx shaped like VK_NV_ray_tracing (i.e. allocating and filling acceleration structures, compiling shaders, and launching initial rays) would be a reasonable starting point?
This, like you've mentioned, could only be implemented on Vulkan for NVIDIA cards, but I think there'd be a reasonable mapping from DX12's DXR and Metal ray tracing. A polyfill might be possible for other devices/APIs (built on a non-raytracing subset of gfx-hal, based on D3D12RaytracingFallback?). I wonder also if it'd be reasonable to (for now) ask gfx-hal users to query the backend/system/etc for ray tracing support (like the GL backend does with e.g. compute support) and giving them the burden of switching on support while there's no vendor-independent API.
@tangmi thank you for the interest! We definitely can get something today (compatible with Metal, DX12, and VK NVidia), but we'll potentially have to rewrite this later when https://github.com/KhronosGroup/Vulkan-Docs/issues/686 is done in order to fit the Vulkan API.
So if you want to work on this - great! We'll accept the PRs delivering this function, but beware of the future change please.
Is this gaining any traction, now that ray tracing is officially part of the Vulkan specification?
@BrandonDyer64 it would be great to expose this Vulkan API, but also it's very important to look at how it will map to DX12 and Metal. As far as I know, nobody has started looking at this yet.
The Vulkan extension is out of the provisional status - https://www.khronos.org/blog/vulkan-ray-tracing-final-specification-release. Edit: here is some code to help us writing DX12 backend for this - https://github.com/maierfelix/dawn-ray-tracing/blob/master/src/dawn_native/d3d12/RayTracingPipelineD3D12.cpp