vulkano icon indicating copy to clipboard operation
vulkano copied to clipboard

Support for `VK_KHR_ray_tracing_pipeline`

Open Ivan-Kudryavtsev opened this issue 1 year ago • 11 comments

I'm interested in contributing towards adding support for VK_KHR_ray_tracing_pipeline, but I don't 100% understand what would be required to make this happen.

VK_KHR_acceleration_structure is already supported, and it's obvious that a RayTracingPipeline struct would be required. Would anyone be able to advise what other work would need to be done for pipelined ray-tracing support?

Many thanks!

Ivan-Kudryavtsev avatar Jan 19 '24 14:01 Ivan-Kudryavtsev

This is something I've been thinking about as well. My current plan is to split this into two separate PRs, each of which implements a subset of the features. First, implement the RayTracingPipeline type and its vkGetRayTracing* methods. Then, in the next PR, implement all the command buffer commands.

Of course, the ray tracing pipeline object is useless without any commands to use it. Splitting the PRs is only to make the problem a bit more manageable, so that the additions are more self-contained and easier to check and test. Divide and conquer, in other words. It also means that the whole thing doesn't have to be added by one person, the work can be divided too.

Rua avatar Jan 19 '24 14:01 Rua

That sounds very sensible to me.

To clarify - the vkGetRayTracing* methods are these?

  • vkGetRayTracingShaderGroupStackSizeKHR
  • vkGetRayTracingShaderGroupHandlesKHR
  • vkGetRayTracingCaptureReplayShaderGroupHandlesKHR

I've done a bit more digging - I'm not clear on if the AccelerationStructure is suitable for use at the moment - indeed, in coverage it says "Host acceleration structure operations" are not supported but I'm not clear on what that means precisely.

The shader binding table-related items are also a bit esoteric but I think I should be able to get to work on this soon.

Ivan-Kudryavtsev avatar Jan 23 '24 13:01 Ivan-Kudryavtsev

I'm also noticing that the Ash PipelineBindPoint enum does not contain RAY_TRACING_KHR - is this likely to be a problem?

Ivan-Kudryavtsev avatar Jan 23 '24 13:01 Ivan-Kudryavtsev

To clarify - the vkGetRayTracing* methods are these?

* `vkGetRayTracingShaderGroupStackSizeKHR`

* `vkGetRayTracingShaderGroupHandlesKHR`

* `vkGetRayTracingCaptureReplayShaderGroupHandlesKHR`

Yes.

indeed, in coverage it says "Host acceleration structure operations" are not supported but I'm not clear on what that means precisely.

The acceleration structure operations come in two forms: the vkCmd* prefixed ones, which are recorded onto command buffers and then executed on the device, and the vk* prefixed ones, which are executed by the host rather than device. The latter kind is not very well supported by Vulkan drivers, so they were skipped for the moment.

I'm also noticing that the Ash PipelineBindPoint enum does not contain RAY_TRACING_KHR - is this likely to be a problem?

It's listed in the Ash documentation: https://docs.rs/ash/latest/ash/vk/struct.PipelineBindPoint.html. Where were you looking for it?

Rua avatar Jan 23 '24 13:01 Rua

Ah thank you, that's my mistake. I was looking in the enums where the graphics and compute enums are defined - slipped my mind it's an extension.

Ivan-Kudryavtsev avatar Jan 23 '24 13:01 Ivan-Kudryavtsev

EDIT: I've just realised it's device features which are distinct from device extensions!

I'm testing creating a pipeline and I've run into a bit of a roadblock with shader compilation: trying to load a shader module with GL_EXT_ray_tracing : enable is panicking:

called `Result::unwrap()` on an `Err` value: a validation error occurred

Caused by:
    create_info.code: uses the SPIR-V capability `RayTracingKHR`

Requires one of:
    feature `ray_tracing_pipeline`

Vulkan VUIDs:
    VUID-VkShaderModuleCreateInfo-pCode-08742

I'm having some trouble tracking down what kind of "feature" is meant here - khr_ray_tracing_pipeline is enabled on the device. I assume it relates to SPIR-V in some way but I've not been able to track it down.

Ivan-Kudryavtsev avatar Feb 03 '24 13:02 Ivan-Kudryavtsev

You're not the first person to be confused about "features", so I'm wondering if naming them "device features" here would help make it clear.

Rua avatar Feb 03 '24 14:02 Rua

That seems like a good idea to me.

Ivan-Kudryavtsev avatar Feb 03 '24 15:02 Ivan-Kudryavtsev

Yep, someone else just came to the Vulkano discord confused about the same thing! Clearly a rename is in order, haha

Rua avatar Feb 03 '24 18:02 Rua

What's the status on this? Can I help?

spapinistarkware avatar Jul 11 '24 19:07 spapinistarkware

I have a working fork, but it's not feature complete. I'll get it on the main repo soon.

Ivan-Kudryavtsev avatar Jul 11 '24 19:07 Ivan-Kudryavtsev