Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Malformed SPIR-V when compiling a simple loop #1076

@Patryk27

Description

@Patryk27

Hi,

Compiling this code:

#[spirv(compute(threads(8, 8)))]
pub fn main(#[spirv(descriptor_set = 0, binding = 0)] out: TexRgba32f) {
    let mut value = vec3(0.1, 0.2, 0.3);
    let mut i = 0;

    loop {
        if i >= 32 {
            break;
        }

        i += 1;
    }

    unsafe {
        out.write(uvec2(0, 0), value.extend(1.0));
    }
}

... will work, but adding a seemingly no-op value = value into that loop:

loop {
    value = value;

    if i >= 32 {
        break;
    }

    i += 1;
}

... will panic the compiler, saying:

error: malformed SPIR-V (in OpCompositeExtract: undefined ID %4547)

Meta:

rustc 1.71.0-nightly (1a5f8bce7 2023-05-26)
SPIRV-Tools v2023.2 unknown hash, 1980-01-01T00:00:00

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions