Skip to content

Fix initialization tracking for the destination of copyTextureToBuffer #8099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

andyleiserson
Copy link
Contributor

@andyleiserson andyleiserson commented Aug 14, 2025

This PR is based on #8095, which is in turn based on #8085.

The main goal of this PR was to fix initialization tracking for buffers that are the destination of a copyT2B operation (#8097). This fixes some CTS tests whose intermittent failure was causing false positives with other changes. I believe it will fix #8021. There is a risk of performance regressions from this change. It would be more performant to use a shader to initialize only the padding areas instead of unnecessarily initializing the entire destination range, but this would be a more involved change.

It was easy to fix the problem with non-4B-aligned initializations (#7947) at the same time, so I did.

There is one additional tweak to the 256B alignment check bytes_per_row that was needed to get the offset_and_bytesPerRow test fully passing, at least on Linux.

Testing
Enables some CTS tests. A directed test might be reasonable too, but I wanted to go ahead and open this so I can see what CI thinks.

Squash or Rebase? Rebase (after merging #8085 and #8095)

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@andyleiserson andyleiserson requested review from crowlKats and a team as code owners August 14, 2025 03:36
@andyleiserson andyleiserson changed the title More buf tex Fix initialization tracking for the destination of copyTextureToBuffer Aug 14, 2025
@andyleiserson andyleiserson force-pushed the more-buf-tex branch 3 times, most recently from d79433f to 7aabc45 Compare August 18, 2025 00:30
Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got all the way up to the last commit, but IDK if I'm returning to this today. Submitting my feedback so far.

CHANGELOG.md Outdated
@@ -76,6 +76,7 @@ By @Vecvec in [#7913](https://github.com/gfx-rs/wgpu/pull/7913).
- The function you pass to `Device::on_uncaptured_error()` must now implement `Sync` in addition to `Send`, and be wrapped in `Arc` instead of `Box`.
In exchange for this, it is no longer possible for calling `wgpu` functions while in that callback to cause a deadlock (not that we encourage you to actually do that).
By @kpreid in [#8011](https://github.com/gfx-rs/wgpu/pull/8011).
- `wgpu` now tracks the initialization status of buffer memory correctly when `copy_texture_to_buffer` skips over padding space between rows or layers, or when the start/end of a texture-buffer transfer is not 4B aligned. By @andyleiserson in [#8099](https://github.com/gfx-rs/wgpu/pull/8099).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: It's odd to mention wgpu explicitly, because the premise of this CHANGELOG is that changes almost always apply to wgpu. It seems like we should elide that detail entirely; this would be consistent with other CHANGELOG items.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was perhaps too committed to complete sentences and avoiding passive voice. I've changed it to just say "Track the initialization status..."

@ErichDonGubler ErichDonGubler self-assigned this Aug 19, 2025
Previously, the check was skipped if the copy was a single row, which is
not correct. The check should be made whenever bytes_per_row is
specified. It is permissible not to specify bytes_per_row if the copy is
a single row, but if it is specified, it must be aligned.

Also removes a redundant check of the `offset` alignment.

Since the offset and bytesPerRow alignment checks are not part of
"validating linear texture data", I chose to remove that instance of
them. These checks are now in `validate_texture_buffer_copy`, which
does not correspond 1:1 with the spec, but has a comment explaining how
it does correspond.
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 render_pass:storeOp tests fail on Vulkan and DX12 if run together, but pass if run separately
2 participants