Repository navigation
Conversation
Contributor
Author
|
The Android check failed before it checked out the code: Docker Hub refused to pull the |
The Metal backend left `texture_read_pixels` `unimplemented!()`, so nothing drawn through Metal could be read back to the CPU. Render targets live in private storage, so the texture is blitted into a shared buffer and copied out of it. The blit joins the frame's command buffer, so it runs after whatever the frame already drew into the texture; that command buffer is committed and waited on, and a fresh one carries the rest of the frame. Render targets take the view's BGRA pixel format, so their pixels are swapped to the RGBA order `TextureFormat::RGBA8` describes, which is what OpenGL returns. As on OpenGL, rows come back in the order `texture_update` takes them. A render pass draws the top of its viewport into a texture's first row on Metal and into its last row on OpenGL, so a caller that reads back a render target flips the rows on one of the two. Verified on macOS: a texture created from bytes reads back the same bytes, and a render target cleared to red reads back as red in RGBA order in the middle of a frame, which then carries on and presents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
benface
force-pushed
the
metal-texture-read-pixels
branch
from
October 18, 2026 17:53
5e8ecc2 to
4bec0ef
Compare
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.
Why
The Metal backend leaves
texture_read_pixelsunimplemented!(), so nothing drawn through Metal can be read back to the CPU: no screenshots, recordings or frame comparisons in tests.Change
RGBA8textures come back as stored.BGRA8Unormformat, so their pixels are swapped to the orderTextureFormat::RGBA8describes, which is what GL returns.texture_updatetakes them. A render pass draws the top of its viewport into a texture's first row on Metal and into its last row on GL, so a caller that reads back a render target flips the rows on one of the two.Verification
MTL_DEBUG_LAYER=1: a texture created from bytes reads back the same bytes, and a render target cleared to red reads back as red in RGBA order in the middle of a frame, which then carries on and presents.cargo checkpasses foraarch64-apple-darwin,aarch64-apple-iosandaarch64-apple-tvos.🤖 Generated with Claude Code