Repository navigation
Conversation
apply_scissor_rect clamped the flipped y and the height into the pass one at a time. A rect reaching past both the top and the bottom of the pass clamped to the whole pass, so it didn't clip at all along that axis, and one starting left of the pass kept its full width from x = 0. OpenGL clips both to the part of the rect inside the target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
On Metal, a scissor rect that reaches past the top or the bottom of the pass doesn't clip at all along that axis, where OpenGL clips to the part of the rect inside the target.
apply_scissor_rectflipped the rect to Metal's top-left origin, then clamped the flipped y and the height into the pass one at a time. For a rect taller than the pass,pass_height - (y + h)is negative, so y clamps to 0, and the height clamps to the whole pass.For example, macroquad clipping an 804×1748 px frame to everything above y = 1312 sends
y = 436, h = 8304after its flip. OpenGL keeps the top 1312 px; Metal kept all 1748. The x axis had a milder form of it: a rect starting left of the pass kept its full width from x = 0.Change
scissor_within_passflips the rect's edges against the pass and clamps each into it, so the scissor is the rect's intersection with the pass: still never past it, which Metal validation requires, and the same region OpenGL keeps. It's a free function so its unit tests run without a device.