naga_oil icon indicating copy to clipboard operation
naga_oil copied to clipboard

Handle naga's SpecialTypes

Open JMS55 opened this issue 1 year ago • 5 comments

Ray tracing APIs do not currently work with naga_oil. DerivedModule throws out special_type info.

JMS55 avatar Sep 08 '23 00:09 JMS55

a minimal example would be really useful - just the wgsl.

robtfm avatar Sep 10 '23 23:09 robtfm

Try calling this function from a different module.

@group(0) @binding(0) var tlas: acceleration_structure;

fn trace_ray(ray_origin: vec3<f32>, ray_direction: vec3<f32>, ray_t_min: f32, ray_t_max: f32) -> RayIntersection {
    let ray_flags = RAY_FLAG_NONE;
    let ray_cull_mask = 0xFFu;
    let ray = RayDesc(ray_flags, ray_cull_mask, ray_t_min, ray_t_max, ray_origin, ray_direction);

    var rq: ray_query;
    rayQueryInitialize(&rq, tlas, ray);
    rayQueryProceed(&rq);
    return rayQueryGetCommittedIntersection(&rq);
}

JMS55 avatar Sep 11 '23 01:09 JMS55

If I understood what's going on correctly when experimenting, naga can interpret acceleration_structure type, but it cannot write it again in WGSL.

MiniaczQ avatar Jan 19 '24 13:01 MiniaczQ

@robtfm I modified naga to support writing out acceleration_structure. However we still need to populate the RT SpecialTypes. I worked around it by hardcoding them: https://github.com/JMS55/naga_oil/commit/9bcdd3b90d3f2d78efcdde84b02332db2acb4668

JMS55 avatar Feb 18 '24 04:02 JMS55

The fix for being unable to write the acceleration structure binding is https://github.com/gfx-rs/wgpu/pull/5261, but using RayIntersection across modules and stuff is still and issue and needs to be fixed by populating the special types.

JMS55 avatar Feb 18 '24 04:02 JMS55