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

fix: avoid unnecessary window.makeCurrent() calls #7362

Merged
merged 1 commit into from
May 27, 2024

Conversation

McMurat
Copy link
Contributor

@McMurat McMurat commented Mar 10, 2024

This fixes the issue as discussed here

Copy link
Member

@tommyettinger tommyettinger left a comment

Choose a reason for hiding this comment

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

I'm just commenting to try to bring some eyes to this; I don't personally feel like I can adequately review the code for correctness. I can review it for performance in a little while. I've had my suspicions about LWJGL3 not running as fast as it could for a while, but it's hard to compare different versions for speed. GL30 is much slower than GL20 on my machine, when using LWJGL3, which is odd, but I'm not sure if that's related to this.

@crykn crykn added this to the 1.12.3 milestone Apr 20, 2024
@casid
Copy link
Contributor

casid commented May 14, 2024

I tried this patch with my game on windows and on mac.

It worked on both and subjectively the game felt a little smoother than before.

I have vsync activated and I'm profiling how long rendering the scene takes. Before the patch, on windows the rendering took a few us, now it takes roughly 16ms. Seems like this change made vsync work properly. On mac on the other hand no changes after the patch, rendering is still a few us.

@tommyettinger
Copy link
Member

@casid That seems odd that Mac still takes just a few microseconds -- if a frame took 1 millisecond, that would put you at about 1000 FPS, and if it's even less than 1ms/frame, the framerate would be... certainly it could be much higher than I can get with VSync off. Does it seem like your game is using more CPU or GPU time than expected on Mac?

@Tom-Ski Tom-Ski merged commit 3339cda into libgdx:master May 27, 2024
2 checks passed
@casid
Copy link
Contributor

casid commented May 28, 2024

@tommyettinger sorry for the confusion. I'm measuring the time it takes for the SpriteBatch to complete (that's my rendered scene), not the entire render method. I did some more profiling today, and the first call to flush() seems to block until rendering is possible again. Only after this change and only on windows. Probably before this, the makeCurrent call had to block instead.

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.

None yet

5 participants