这是indexloc提供的服务,不要输入任何密码
Skip to content

Copy Validation of Depth/Stencil textures #997

@austinEng

Description

@austinEng

WebGPU currently has the restriction for copyTextureToTexture that:

If source.texture.[[format]] is a depth-stencil format:

  • The copy with source, destination and copySize is a copy of the whole subresource.

See https://gpuweb.github.io/gpuweb/#dom-gpucommandencoder-copytexturetotexture

This comes from a D3D12 restriction for D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL:

The following restrictions and interactions apply:

Either the texture format must support depth stencil capabilities at the current feature level. Or, when the format is a typeless format, a format within the same typeless group must support depth stencil capabilities at the current feature level.

Cannot be used with D3D12_RESOURCE_DIMENSION_BUFFER, 4KB alignment, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS, D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, nor used with heaps that have D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES or D3D12_HEAP_FLAG_ALLOW_DISPLAY.

Precludes usage of WriteToSubresource and ReadFromSubresource.

Precludes GPU copying of a subregion. CopyTextureRegion must copy a whole subresource to or from resources with this flag.

WebGPU is wrong in a few ways:

  1. This validation must be on the tuple (GPUCopyTextureView, GPUExtent3D) so that it applies to copyTextureToBuffer, copyBufferToTexture, and writeTexture as well.

  2. The validation is more strict than the D3D12 restriction. D3D12 only enforces this if the resource is created using D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL. In WebGPU, this means that the format is both a Depth/Stencil format and it has usage GPUTextureUsage.OUTPUT_ATTACHMENT.
    We could consider making WebGPU's validation match this which would allow partial copies of depth/stencil textures which are not used as output attachments. However, I'm not sure how useful this is since actually using the partially-copied data in a depth/stencil attachment would require an intermediate full-subresource copy (via another buffer or texture) anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions