Issue automatically imported from old repo: EmbarkStudios/rust-gpu#756
Old labels: t: enhancement,s: qptr may fix
Originally creatd by expenses on 2021-09-25T11:44:25Z
Occasionally, a shader variable requires the NonUniform decoration. One example of this is when doing a texture lookup in a ray-tracing shader, where the texture index might not be uniform with the neighbouring rays. See: https://github.com/expenses/ray-tracing-gallery/blob/cb0cb06cc60a5632150e606261a02ba26862ac09/shaders/closesthit.glsl#L136-L138.
I've attempted to do this with asm!:
#[spirv(descriptor_set = 0, binding = 1)] textures:&RuntimeArray<SampledImage<
Image!(2D,type=f32, sampled=true),
>>,
...
unsafe{asm!{"OpDecorate {} NonUniform",
in(reg)&texture_index
}};let uv = Vec2::splat(0.0);let texture = unsafe{
textures.index(texture_index asusize)};let colour:Vec4 = unsafe{ texture.sample_by_lod(uv,0.0)};but the decoration wasn't included in the final SPIR-V module. Perhaps it was optimized out? The u32 -> usize conversion that is needed for accessing indexing RuntimeArrays could be a problem as well.
Issue automatically imported from old repo: EmbarkStudios/rust-gpu#756
Old labels: t: enhancement,s: qptr may fix
Originally creatd by expenses on 2021-09-25T11:44:25Z
Occasionally, a shader variable requires the
NonUniformdecoration. One example of this is when doing a texture lookup in a ray-tracing shader, where the texture index might not be uniform with the neighbouring rays. See: https://github.com/expenses/ray-tracing-gallery/blob/cb0cb06cc60a5632150e606261a02ba26862ac09/shaders/closesthit.glsl#L136-L138.I've attempted to do this with
asm!:but the decoration wasn't included in the final SPIR-V module. Perhaps it was optimized out? The
u32->usizeconversion that is needed for accessing indexingRuntimeArrays could be a problem as well.