Rust-GPU / Rust-GPU/rust-gpu

[Migrated] Incorrect array stride for arrays of vector types

Open
#128 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/573
Old labels: t: bug,c: rustc_codegen_spirv,s: qptr may fix
Originally creatd by msiglreith on 2021-03-31T18:36:48Z


const QUAD_CLIP: [f32x2; 4] = [
    f32x2 { x: -1.0, y: -1.0 },
    f32x2 { x: 1.0, y: -1.0 },
    f32x2 { x: -1.0, y: 1.0 },
    f32x2 { x: 1.0, y: 1.0 },
];

#[spirv(vertex)]
pub fn quad_vs(#[spirv(vertex_id)] vert_id: i32, #[spirv(position)] a_position: &mut f32x4) {
    let idx = vert_id as usize;
    let pos_clip = QUAD_CLIP[idx];
    *a_position = vec4(pos_clip.x, pos_clip.y, idx as f32, 1.0);
}

QUAD_CLIP type will be generated with an ArrayStride of 8 which is incorrect as in this case all array elements should be treated as vec4 types, requiring a stride of 16.

Generated:

OpDecorate %_arr_v2float_uint_4 ArrayStride 8

Expected:

OpDecorate %_arr_v2float_uint_4 ArrayStride 16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rust reproducer for QUAD_CLIP and inspect the generated SPIR-V decoration for its array type. Compare the emitted ArrayStride with the expected value of 16, and consider the issue complete when arrays of vector types receive the correct stride.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.