Skip to content

Texture with multisample imposes too strict limits on depth_or_array_layers #8565

@LaylBongers

Description

@LaylBongers

I am working on an OpenXR application that has to render to a multiview swapchain. I am attempting to support MSAA rendering, and have to create a framebuffer for doing this. To do this, I create a textures with depth_or_array_layers set to 2 (for multiview) and sample_count set to 4 (for multisample).

Currently, in WGPU, this will fail with a InvalidDimension, MultisampledDepthOrArrayLayer error.

if desc.size.depth_or_array_layers != 1 {

However, the WebGPU standard does not impose this limitation. Instead the WebGPU standard specifies only "3D" (TextureDimension::D3) textures can't be multisampled:
https://www.w3.org/TR/webgpu/#gputexturedescriptor

"2d" Specifies a texture that has a width and height, and may have layers.
"3d" Specifies a texture that has a width, height, and depth. "3d" textures cannot be multisampled, and their format must support 3d textures (all plain color formats and some packed/compressed formats).

In fact, the limitations for 2D images says:
https://www.w3.org/TR/webgpu/#abstract-opdef-validating-gputexturedescriptor

descriptor.size.depthOrArrayLayers must be ≤ limits.maxTextureArrayLayers.

Thus, the limits should be extended to be restricted by Limits::max_texture_array_layers, instead of to a flat value of 1. Additionally, there should be a check that a multisampled texture cannot be 3D, which is not currently present.


Edited for context:

I overlooked the part of the spec that does enforce this, here:
https://www.w3.org/TR/webgpu/#texture-creation

If descriptor.sampleCount > 1:
descriptor.size.depthOrArrayLayers must be 1.

Regardless, I do have a need for this feature, maybe as an extension similar to how multiview is supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions