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 framerate throttling in Emscripten builds #672

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

jdarpinian
Copy link

Default com_maxfps to 0 under Emscripten. Under Emscripten the browser handles throttling the frame rate. Manual framerate throttling interacts poorly with Emscripten's browser-driven event loop.

Default com_maxfps to 0 under Emscripten. Under Emscripten the browser handles throttling the frame rate. Manual framerate throttling interacts poorly with Emscripten's browser-driven event loop.
@zturtleman
Copy link

This commit should also set r_swapInterval to 1 to ensure V-sync is enabled otherwise com_maxfps 0 runs as fast as possible after vid_restart (135 FPS for me). Please use #ifdef __EMSCRIPTEN__ as it's more consistent with platform defines.

I think it would be good to not use V-sync by default and improve handling of com_maxfps itself but that a larger change and this PR would be fine for now (with the above things fixed). #675

@jdarpinian
Copy link
Author

Done, thanks for the feedback

@zturtleman
Copy link

You can remove the two "See here for discussion: #675" in the source code. I don't think it adds value for future reference.

You can leave r_swapInterval as two separate lines so the original case is unchanged (and matches the opengl1 renderer).

#ifdef __EMSCRIPTEN__
	// Under Emscripten we don't throttle framerate with com_maxfps by default, so enable
	// vsync by default instead.
	r_swapInterval = ri.Cvar_Get( "r_swapInterval", "1",
					CVAR_ARCHIVE | CVAR_LATCH );
#else
	r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0",
					CVAR_ARCHIVE | CVAR_LATCH );
#endif

@zturtleman zturtleman merged commit e505e34 into ioquake:main Jun 25, 2024
4 checks passed
@zturtleman
Copy link

Thanks.

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