Skip to content

Compile combiner shader programs asynchronously to avoid stuttering. - #2978

Merged
gonetz merged 3 commits into
masterfrom
async_shaders_compile_new
Jul 26, 2026
Merged

Compile combiner shader programs asynchronously to avoid stuttering.#2978
gonetz merged 3 commits into
masterfrom
async_shaders_compile_new

Conversation

@gonetz

@gonetz gonetz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

If GL_ARB/KHR_parallel_shader_compile is supported, compilation of a new combiner program is issued without waiting for the result: the driver compiles it in background threads while the current program is used as a substitute. Ready programs are added to the combiners map when the display list is finished, see gDPFullSync().

New config option: asyncShaderCompilation (enabled by default on Android).

gonetz added 3 commits July 18, 2026 18:03
If GL_ARB/KHR_parallel_shader_compile is supported, compilation of a new
combiner program is issued without waiting for the result: the driver
compiles it in background threads while the current program is used as
a substitute. Ready programs are added to the combiners map when the
display list is finished, see gDPFullSync().

New config option: asyncShaderCompilation (enabled by default on Android).
Call glMaxShaderCompilerThreadsARB/KHR with count 0xFFFFFFFF at context
init to request an implementation-specific maximum of background threads
for parallel shader compilation.
@gonetz

gonetz commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

It is the second attempt to solve "stuttering" problem caused by synchronous compilation of heavy GLideN64 shaders.
When display list calls gDPSetCombine with completely new parameters, compilation of the corresponding shader is started but the result is not waited, and the current shader is used instead. So, you may see a wrong shader for a frame or two, until the shader get compiled. On my desktop all pending shaders (up to 50 per frame) were ready to the end of the display list, so wrong shader was used for only one frame.
I think this is the best I can do. It should eliminate all stuttering caused by shader compilation, so the plugin should run as smoothly as other plugins, provided your hardware is powerful enough to run GLideN64 shaders.

@gonetz
gonetz merged commit b71e4b7 into master Jul 26, 2026
28 checks passed
@gonetz
gonetz deleted the async_shaders_compile_new branch July 26, 2026 04:44
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