Skip to content

Cannot set array length with Specialization Constants #1956

Closed
@KeKsBoTer

Description

Hey,

I am trying to set an array length with a specialization constant.
This is the shader code:

#version 460
layout(constant_id=0) const uint my_array_length = 25;
struct Vertex{
    vec3 pos;
    vec4 data[my_array_length];
};
layout(set = 1, binding = 1) buffer VertexData{
    Vertex vertices[];
};
...

This should work but I get the following error:

error: proc macro panicked
   --> src/main.rs:259:5
    |
259 | /     vulkano_shaders::shader! {
260 | |         ty: "vertex",
261 | |         path: "path/to/shader.vert",
262 | |
...   |
266 | |         }
267 | |     }
    | |_____^
    |
    = help: message: failed to find array length

I think this is due to vulkano's array length checking that cannot handle const variables (see here)

Info

  • Version of vulkano: 0.30
  • OS: Linux
  • GPU (the selected PhysicalDevice): AMD Radeon R9 380 Series
  • GPU Driver: amdgpu

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions