vulkano icon indicating copy to clipboard operation
vulkano copied to clipboard

A struct with an aray in a glsl shader will crash vulkano-shaders

Open pac85 opened this issue 4 years ago • 7 comments

= help: message: called `Option::unwrap()` on a `None` value

happens on src/structs.rs:526

pac85 avatar Aug 26 '21 00:08 pac85

is this a fixed length array? Can you provide the binding code used in your shader with the struct declaration.

AustinJ235 avatar Aug 26 '21 01:08 AustinJ235

Yes sorry I should have said that. It was a fixed length array, I can easily reproduce the bug by pasting the following comment in the vulkan-shaders documentation and running cargo test:

mod vs {
    vulkano_shaders::shader!{
        ty: "vertex",
        src: "
#version 450
                                       
layout(location = 0) in vec3 position;
                                       
struct A {
    vec3 ar[3];
};
                                       
void main() {
    A a;
    gl_Position = vec4(a.ar[0], 1.0);
}"
    }
}
# fn main() {}

The struct has to be used in order for the error to appear.

pac85 avatar Sep 04 '21 14:09 pac85

@AustinJ235 any idea?

Rua avatar Sep 30 '21 13:09 Rua

If it were a vec4 instead would it work? Might be a stride issue.

AustinJ235 avatar Sep 30 '21 22:09 AustinJ235

I've tried a vec4 array with 4 elements and the same happens

pac85 avatar Oct 06 '21 22:10 pac85

Does this problem still occur with the newest version of Vulkano?

Rua avatar May 14 '22 13:05 Rua

Does this problem still occur with the newest version of Vulkano?

I'm able to reproduce it in the latest version cloned from master

pac85 avatar May 16 '22 17:05 pac85

This was fixed in #1945.

marc0246 avatar Jul 07 '23 04:07 marc0246