Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL GPU: Intersect scissor with viewport #244

Merged
merged 2 commits into from
Apr 3, 2025

Conversation

kiddkaffeine
Copy link
Contributor

No description provided.

Copy link
Member

@flibitijibibo flibitijibibo left a comment

Choose a reason for hiding this comment

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

The idea makes sense, so we just have to expand on this a bit - let's update the scissor rect whenever the viewport changes too; for example we may have a scissor bigger than the viewport, but when the viewport gets larger we need to tell SDL_GPU that the scissor rect intersection is also larger now.

Comment on lines 308 to 312
SDL_Rect newRect;
newRect.x = MAX(x1, x2);
newRect.y = MAX(y1, y2);
newRect.w = MIN(x1 + w1, x2 + w2) - newRect.x;
newRect.h = MIN(y1 + h1, y2 + h2) - newRect.y;
Copy link
Member

Choose a reason for hiding this comment

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

SDL_min and SDL_max should cover these macros; we may want to rip off SDL_rect to get a full picture (and catch the weird scenario where there is no intersection):

https://github.com/libsdl-org/SDL/blob/main/src/video/SDL_rect_impl.h#L86

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to SDL_min/max macros, and added a warning when rects do not overlap.

Regarding updating scissor afterwards, it seems like SetRenderTargets actually resets the scissor afterwards:
https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/GraphicsDevice.cs#L1029

If we wanted to sanity check the scissor rect beforehand, wouldn't it be better to do that in the C# side too?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think you're right - the only place where we update the viewport without updating the scissor is inside FNA3D_SetViewport itself, so I think it'd be a whole separate FNA3D issue if we needed to update the scissor rect while in that function.

@flibitijibibo flibitijibibo merged commit 0d339ea into FNA-XNA:master Apr 3, 2025
11 checks passed
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.

2 participants