test: use non-square asymmetric textures in coordinate-sensitive tests#9723
Open
emilk wants to merge 1 commit into
Open
test: use non-square asymmetric textures in coordinate-sensitive tests#9723emilk wants to merge 1 commit into
emilk wants to merge 1 commit into
Conversation
Square test textures make it possible to accidentally confuse width/height (and u/v) without any test failing. Convert the coordinate-sensitive tests to non-square textures whose contents are asymmetric under transpose, horizontal mirror, and vertical mirror, so such mix-ups are caught. - write_texture: 256x256 -> 256x192 (SUBSET_2D/3D, NO_OOB) - regression/issue_6827: 4x4x4 -> 4x5x6 (every axis distinct) - clip_distances: 256x256 -> 256x192, per-pixel asserts recomputed - planar_texture: 256x256 -> 256x128; plane-copy content now depends on both x and y (was row-aliased / vertically symmetric) - zero_init: 256x256 -> 256x192 (and half-res planes 128x96) width is kept a multiple of COPY_BYTES_PER_ROW_ALIGNMENT so bytes_per_row stays aligned; NV12/P010 dimensions stay even. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ErichDonGubler
approved these changes
Jun 23, 2026
ErichDonGubler
left a comment
Member
There was a problem hiding this comment.
Seems like a strict improvement to me! Is it still interesting to add square dimension coverage as, say, follow-up?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connections
create_texture#9302Summary
Use non-square asymmetric textures in tests to catch bugs like the one in #9302. No bugs were caught.
Description
Many GPU tests allocate square textures (
width == height). A square texture hides bugs: code that swaps width and height, or that confusesu/vtexture coordinates, still produces a passing test because the two dimensions are interchangeable and the contents are often symmetric.This PR converts the coordinate-sensitive tests — those that write known data, copy regions, render, or sample and then assert on per-coordinate values — to use non-square textures. Where a test asserts on texel contents, the contents are also made asymmetric under transpose, horizontal mirror, and vertical mirror, so a row/column or
u/vmix-up changes the bytes and fails the assertion. The most notable content fix isplanar_texture's plane-copy test, whose oldi as u8pattern aliased every row identically (vertically symmetric); it now depends on both axes.Tests converted:
write_texture: 256×256 → 256×320 (SUBSET_2D/3D, NO_OOB)regression/issue_6827: 4×4×4 → 4×5×6 (every axis distinct)clip_distances: 256×256 → 256×320, per-pixel asserts recomputedplanar_texture: 256×256 → 256×320; plane-copy content now depends on bothxandyzero_init: 256×256 → 256×320 (and half-res planes 128×160)Dimensions were chosen to keep all existing alignment requirements satisfied:
widthstays a multiple ofCOPY_BYTES_PER_ROW_ALIGNMENT(256) sobytes_per_rowremains aligned forcopy_texture_to_buffer, and NV12/P010 textures keep even dimensions (chroma is half-resolution).height > widthis deliberate: a backend that mistakenly sizes a texture's height from its width (the exact bug fixed in #9302, where GLEScreate_textureuseddesc.size.widthfor the height) then under-allocates, so the full-extent readback or render overruns the real storage and the test fails. Withheight < widthsuch a backend would over-allocate and every in-bounds access would still return correct data, hiding the bug — which is why the square tests never caught #9302.Tests that are not coordinate-sensitive (lifecycle, OOM, bounds-validation, 1×1, mip-array, sampler-filtering) were intentionally left unchanged.
Testing
Test-only change.
cargo check,cargo clippy, andcargo fmtpass for thewgpu-gputest target. The converted tests retain their original assertions, recomputed for the new dimensions (e.g. theclip_distancesper-pixel checks were recomputed from the shader'sy_ndc >= |x_ndc|fill region). The full GPU test suite should be run on CI across backends — in particular on a GL backend, where theheight > widthchoice is what exercises the #9302 regression.Squash or Rebase?
Single commit; ready to rebase onto
trunkas it stands.Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.