Skip to content

[Migrated] Malformed SPIR-V when compiling a simple loop #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rust-gpu-bot opened this issue Nov 13, 2024 · 2 comments
Open

[Migrated] Malformed SPIR-V when compiling a simple loop #81

rust-gpu-bot opened this issue Nov 13, 2024 · 2 comments

Comments

@rust-gpu-bot
Copy link

Issue automatically imported from old repo: EmbarkStudios/rust-gpu#1076
Old labels: t: bug
Originally creatd by Patryk27 on 2023-06-16T15:19:59Z


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
@rust-gpu-bot
Copy link
Author

Comment from Patryk27 on 2023-06-17T08:51:31Z


fwiw, an assignment after (or before) the loop triggers this error as well:

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

    while i < 10 {
        i += 1;
    }

    val = val;

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

@rust-gpu-bot
Copy link
Author

Comment from schell on 2023-07-29T22:53:49Z


@Patryk27 I think there's something up with while loops and loops with loop { if ... { break; } } because I have a number of shaders that work with for i in range that won't work with any other looping mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant