Skip to content

Fix separate depth stencil read-only state#9763

Open
beicause wants to merge 14 commits into
gfx-rs:trunkfrom
beicause:separate-depth-stencil-read-only
Open

Fix separate depth stencil read-only state#9763
beicause wants to merge 14 commits into
gfx-rs:trunkfrom
beicause:separate-depth-stencil-read-only

Conversation

@beicause

@beicause beicause commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Connections
Fixes #5231.
Fixes #8705.

Description
Fix separate depth stencil read-only state on vulkan and dx12 (metal seems already works).

Splits DEPTH_STENCIL_READ/DEPTH_STENCIL_WRITE TextureUses into separate depth and stencil states. On vulkan, it needs VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL and VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL which requires vulkan 1.1 or VK_KHR_maintenance2.

Additionally, we internally use VK_ATTACHMENT_STORE_OP_NONE (or its variants provided by extensions) to avoid the SYNC_HAZARD_WRITE_AFTER_WRITE validation error. If VK_ATTACHMENT_STORE_OP_NONE is not supported, we have to insert barrier with write access flag for readonly depth stencil to avoid that error.

Testing

cargo xtask cts 'webgpu:api,operation,memory_sync,texture,readonly_depth_stencil:*'
cargo r -p wgpu-examples water

Squash or Rebase?

Squash

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

TODO:

  • Fix dx12

@beicause beicause force-pushed the separate-depth-stencil-read-only branch 2 times, most recently from e6bc7cd to 37466b4 Compare June 29, 2026 17:08
@beicause beicause force-pushed the separate-depth-stencil-read-only branch from 37466b4 to 81a1ea0 Compare June 29, 2026 17:13
@beicause beicause marked this pull request as ready for review June 29, 2026 17:35
@cwfitzgerald cwfitzgerald self-assigned this Jun 30, 2026
@beicause beicause force-pushed the separate-depth-stencil-read-only branch from 841df8a to def3cf3 Compare July 1, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTS failures in depth_stencil_attachment_and_bind_group Fix synchronization validation error in water example on Vulkan

2 participants