Skip to content

NonUniform decoration support #756

Open
@expenses

Description

@expenses

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 as usize)
};
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.

Metadata

Metadata

Assignees

Labels

s: qptr may fixThis might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)t: enhancementA new feature or improvement to an existing one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions