8000 metal: intersect the scissor rect with the pass by benface · Pull Request #690 · not-fl3/miniquad · GitHub
[go: up one dir, main page]

Skip to content

metal: intersect the scissor rect with the pass - #690

Open
benface wants to merge 1 commit into
not-fl3:masterfrom
benface:metal-scissor-within-pass
Open

benface wants to merge 1 commit into
not-fl3:masterfrom
benface:metal-scissor-within-pass

Conversation

@benface
@benface benface commented Oct 14, 2026
Copy link
Copy Markdown
Contributor

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_rect flipped 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 = 8304 after 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_pass flips 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.

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>
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

0