Skip to content

Multiview pipelines on vulkan have hidden instance limit #8333

@inner-daemons

Description

@inner-daemons

THIS ISSUE IS EXCEPTIONALLY UNPLEASANT IN MY OPINION

See this comment.

VkPhysicalDeviceMultiviewProperties has a field maxMultiviewInstanceIndex. This is probably for feature emulation using instancing. Normally, all backends have a instance limit of u32::MAX (except perhaps metal), due to taking a u32 argument for instances. The fact that this limit in vulkan exists probably means that some drivers out there actually have a more restricted limit. An implementation could in theory give a limit as low as $2^{27}-1=134217727$, or about 1/32 of u32::MAX. Webgpu normally doesn't have an instance other than the implicit u32::MAX. There is no pleasant way to expose this limit to the user.

The current strategy is to at draw call time, check the max instance index against a private capability, and then panic if it is violated (this can't be predicted so breaks wgpu-hal's contract).

Automatic splitting into multiple draw calls could be done in theory, but this would at best still have no solution for indirect draws, and would make errors there unpredictable.

We could just not expose multiview on devices that expose a limit lower than u32::MAX.

Also, one final thing to note: this is the instance index, and not the instance count, so it is possible to break wgpu by specifying a ridculous range of indices that is still short (e.g. 134217728..134217729).

Describe the solution you'd like
Honest to god I'm not sure

Describe alternatives you've considered
We could expose this limit. But that is extraordinarily shitty and nobody would ever pay attention to it anyway, because it would almost never cause actual problems, and on most devices the limit would probably be u32::MAX anyway.

Additional context
#8206

Metadata

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