gfx icon indicating copy to clipboard operation
gfx copied to clipboard

RTX Extensions for DX12, Vulkan and OpenGL

Open novacrazy opened this issue 7 years ago • 11 comments

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.

novacrazy avatar Sep 21 '18 00:09 novacrazy

Any progress on this?

anchpop avatar Feb 07 '19 21:02 anchpop

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

kvark avatar Feb 07 '19 22:02 kvark

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).

dgkoch avatar Feb 28 '19 17:02 dgkoch

Ah, I see. Slightly unfortunate but understandable. I've updated the links as well, which seemed to have rotted due to the name change.

novacrazy avatar Feb 28 '19 18:02 novacrazy

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).

ghost avatar Apr 11 '19 07:04 ghost

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!

kvark avatar Apr 22 '19 19:04 kvark

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 avatar Jun 17 '19 23:06 tangmi

@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.

kvark avatar Jun 18 '19 18:06 kvark

Is this gaining any traction, now that ray tracing is officially part of the Vulkan specification?

bakcxoj avatar Apr 05 '20 19:04 bakcxoj

@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.

kvark avatar Apr 05 '20 19:04 kvark

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

kvark avatar Nov 23 '20 14:11 kvark