'Trying to pass two values to a compute shader glsl but keep getting error

I am using GLSL with vulkano, a safe rust wrapper for vulkan. I am trying to pass two values into the compute shader but keep on getting error '[' : array must be redeclared with a size before being indexed with a variable.

this is my code so far:

#version 450

layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;

layout(set = 0, binding = 0) buffer Data{
    uint itg[];
    float flt[];
} data;

void main() {
    uint idx = gl_GlobalInvocationID.x;
    data.itg[idx] *= 12;
    data.flt[idx] = sqrt(data.flt[idx]);
}

--- Update ---

I managed to pass multiple values to the shader with a Struct, but when I try to change any values, it gives garbled data if I have a vec2.

#version 450

layout(local_size_x = 64) in;

        struct Foo {
            uint a;
            float b;
            vec2 c;
            uint d;
        };

        layout(set = 0, binding = 0) buffer Data{
            Foo val[];  
        } data;

        void main() {

            uint idx = gl_GlobalInvocationID.x; 
            data.val[idx].a = 0;
            data.val[idx].b = sqrt(data.val[idx].b);
            data.val[idx].c.x = 1/sqrt(data.val[idx].c.x);
            data.val[idx].c.y = sqrt(data.val[idx].c.y);
        }

ps: I am a beginner in GLSL so please could you explain a bit of the answer and why it works.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source