-
Notifications
You must be signed in to change notification settings - Fork 345
Description
The WebGPU API allows creating a texture view which selects a single aspect of a combined depth stencil texture using aspect "depth-only" or "stencil-only".
Such a view can be set as the depthStencilAttachment of GPURenderPassEncoder.
The expectation would be that the render pass would execute as-if there were depth attachment if the view were stencil-only, or as-if there were no stencil attachment if the view were depth-only.
This is not directly implementable on Vulkan and D3D12.
On Vulkan, an image view can be created of a VKImage with a particular aspectMask, but the aspectMask is ignored for depth-stencil attachments.
https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkImageSubresourceRange.html
When an image view of a depth/stencil image is used as a depth/stencil framebuffer attachment, the aspectMask is ignored and both depth and stencil image subresources are used.
On D3D12, D3D12_DEPTH_STENCIL_VIEW_DESC, does not contain any members to select just the depth or the stencil aspect.
The consequence of the limitation means that the depth/stencil data is still both readable and writable by the depth/stencil loadOp and storeOp, and by any depth/stencil test on Vulkan/D3D12.
I think there are at least two possible options:
- Disallow depth stencil attachments unless they select all of the texture aspects. This would be a validation error on beginRenderPass
- Have a single aspect depth-stencil view imply depthReadOnly/stencilReadOnly=true for the other unselected aspect, AND require the pipeline does not read or write the aspect (the depth/stencil test is disabled). This would be additional validation on setPipeline, similar to validation that we have for depthReadOnly/stencilReadOnly.