gfx-rs/wgpu

support SPV_KHR_ray_tracing_position_fetch in naga

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
spirv supports SPV_KHR_ray_tracing_position_fetch which can be very useful if one does not want to keep vertex & index buffers around

Describe the solution you'd like
The feature to be supported

Describe alternatives you've considered
Not supporting it, it's only on spirv - Con: uses one or two of the (valuable) buffer spaces in a shader.

Additional context
Previous suggestion for API (see #1040 (comment))

var acc_w_vertex_return: acceleration_structure<vertex_return>;
var normal_acc: acceleration_structure;
// only allowed to be initialised by acceleration_structure<vertex_return>
var rq_w_vertex_return: ray_query<vertex_return>;
// allowed to be initialised by both
var normal_rq: ray_query;

//function to get vertices from latest hit, same conditions as rayQueryGet*Intersection
fn get{Committed/Candidate}HitVertexPositions(rq: ptr<function, ray_query<vertex_return>>) -> array<vec3<f32>, 3>

I've partially implemented this already, with getCommittedHitVertexPositions implemented

I'm not entirely sure how metal works, but looking at the metal feature set tables it seems that we can access an unlimited number of buffers from a shader if they are in an argument buffer. I think this means we could emulate this on metal since we can go around the maximum requirements here. I may be wrong though as I have no metal experience.