Skip to content

Vulkano does not detect correct work group sizes #2745

@zwang20

Description

@zwang20

The following code adapted from the vulkano book works

mod cs {
    vulkano_shaders::shader! {
        ty: "compute",
        src: r"
            #version 460

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

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

            void main() {
                buf.data[gl_GlobalInvocationID.x] *= 12;
            }
        ",
    }
}

However, the following code fails to compile

mod cs {
    vulkano_shaders::shader! {
        ty: "compute",
        src: r"
            #version 460

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

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

            void main() {
                buf.data[gl_GlobalInvocationID.z] *= 12;
            }
        ",
    }
}
error: compilation error:
       shader.glsl:4: error: 'local_size' : too large; see gl_MaxComputeWorkGroupSize
       
  --> src/main.rs:6:14
   |
 6 |           src: r"
   |  ______________^
 7 | |             #version 460
 8 | |
 9 | |             layout(local_size_x = 1, local_size_y = 1, local_size_z = 1024) in;
...  |
18 | |         ",
   | |_________^

From https://docs.vulkan.org/glsl/latest/chapters/builtins.html:

The following built-in constants are declared in all shaders. The actual values used are implementation-dependent, but must be at least the value shown.

const ivec3 gl_MaxComputeWorkGroupSize = { 1024, 1024, 64 };

However, the local device reports the following

physical_device.properties().max_compute_work_group_size
[1024, 1024, 1024]

It seems that vulkano-shaders is not correctly detecting the max compute work group size of the physical device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions