Skip to content

Fix WebGPU compressed texture uploads and mip chains - #4204

Merged
ibgreen merged 2 commits into
masterfrom
codex/webgpu-compressed-textures
Dec 5, 2026
Merged

ibgreen merged 2 commits into
masterfrom
codex/webgpu-compressed-textures

Conversation

@ibgreen

@ibgreen ibgreen commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Goals

Make compressed texture uploads consistent and expose the WebGPU opt-in for non-block-aligned textures.

Changes

  • Add texture-compression-unaligned to the typed device feature list and document it alongside 3D BC and ASTC.
  • Validate compressed strides in block rows and pad WebGPU buffer-copy extents to full blocks.
  • Preserve supplied mips down to 1×1 when their dimensions and formats form a valid chain.
  • Add regression coverage for feature selection, block layout, buffer uploads, and small mips.

Verification

  • yarn lint fix, yarn build, yarn bundle-size, and yarn test-node (5,544 passed)
  • Chrome 158 uploaded a 7×5 BC1 texture and 3D BC1/ASTC textures. A 1×1 BC1 buffer upload read back the exact eight encoded bytes.

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no outstanding findings remain.

Summary

Fixes compressed texture uploads and preserves valid supplied mip chains down to 1×1.

  • Compressed texture writes use full block rows and copy extents.
  • Compressed mip chains can keep valid levels down to 1×1.
  • WebGPU callers can request unaligned compressed textures by name.

Reviews (3) · Last reviewed commit: "Use valid ASTC blocks in the mip regress..." · Reviewed by Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 75dca1e. Configure here.

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keep physical mip-edge rounding without widening interior buffer updates.

},
{width, height, depthOrArrayLayers}
{
width: Math.ceil(width / blockWidth) * blockWidth,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unconditional rounding silently widens an interior region: BC1 8×4 at origin (0,0), writeBuffer({width: 5, height: 4}) now submits 8×4 instead of failing native block validation on 5×4, so a valid submission can overwrite the three columns outside the documented region. I captured the base/head encoder arguments with the exact method bodies and normalized-options stubs. The intended 7×4 logical edge → 8×4 physical, 1×1 mip → 4×4, and aligned 4×4 → 4×4 controls also behaved as expected. No GPU readback.

Please reject an unaligned extent unless origin + extent equals the logical mip size on that axis. Then round only the valid logical edge. writeData already rounds this way without the interior guard, so a shared check can keep both paths consistent.

@ibgreen
ibgreen added this pull request to the merge queue Dec 5, 2026
Merged via the queue into master with commit d72163e Dec 5, 2026
21 checks passed
@ibgreen
ibgreen deleted the codex/webgpu-compressed-textures branch December 5, 2026 16:32
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.

1 participant