gfx-rs/wgpu

Setting max_compute_workgroups for each dimension separately

TimothyBergstrom opened this issue · 1 comments

Hello,

I am looking into setting the workgroup count for each dimension separately.

From the docs here

max_compute_workgroups_per_dimension: [u32]
The maximum value for each dimension of a ComputePass::dispatch(x, y, z) operation. Defaults to 65535.

It seems I can only set the max_workgroup_count for all dimensions at a time and not independently.

However, with vulkaninfo, have the following:

maxComputeWorkGroupCount: count = 3
  2147483647
  65535
  65535
maxComputeWorkGroupInvocations = 1536
maxComputeWorkGroupSize: count = 3
  1536
  1024
  6

On the x dispatch, I have the maximum of 2147483647, while the other dimensions I have 65535 as a maximum.

However, if I would set max_compute_workgroups_per_dimension to 2147483647, I get:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RequestDeviceError { inner: Core(LimitsExceeded(FailedLimit { name: "max_compute_workgroups_per_dimension", requested: 2147483647, allowed: 65535 })) }', examples\hello-compute\src/main.rs:78:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Which limits the x dimension.

Is this a design choice or some other limitations why the max_compute_workgroups_per_dimension are not separated by each dimension?

I believe the issue is that amd stores each dimension in a u16 internally, so on amd cards, you'll get 65535 for all dimensions. So your code should deal with this weird limitation, as annoying as it is.