Skip to content

Allow shader containers to be loaded in parallel. - #119123

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
blueskythlikesclouds:group-task-for-shader-cache-load
Jun 19, 2026
Merged

Allow shader containers to be loaded in parallel.#119123
Repiteo merged 1 commit into
godotengine:masterfrom
blueskythlikesclouds:group-task-for-shader-cache-load

Conversation

@blueskythlikesclouds

Copy link
Copy Markdown
Member

Improves #116228.

re-spirv parsing happens when loading shader containers. Previously, this operation happened completely sequentially, even when compiling shaders in multiple threads.

The following changes are done to allow it happen in parallel:

  • Spawn multiple tasks for loading cached variants.
  • Put RDD shader container load function outside the rendering device global mutex, so the calls can overlap.
  • Allow ZSTD data to be decompressed by multiple threads.

Testing the MRP from the issue with cached shaders and pipelines. Comparing RendererSceneRenderImplementation::RenderForwardClustered::_render_scene:

Before: 200 ms
After: 25 ms

@DarioSamo DarioSamo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes seem ok in general. There's no thread safety concerns as far as I can tell because all vectors are resized and initialized before any thread access happens. The existing compilation task system is also reused to load these variants from the cache, so generally this seems like it should unblock parallel loading even further.

Comment thread servers/rendering/renderer_rd/shader_rd.cpp Outdated

@Ivorforce Ivorforce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I authored the zstd caches to reduce RAM churn. Making it thread_local should be fine.
Can't comment on the rendering changes.

@blueskythlikesclouds
blueskythlikesclouds force-pushed the group-task-for-shader-cache-load branch from 58a98cd to d751f5b Compare May 4, 2026 15:10
@Repiteo
Repiteo merged commit 9700abd into godotengine:master Jun 19, 2026
20 checks passed
@Repiteo

Repiteo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Thanks!

@nikitalita

Copy link
Copy Markdown
Contributor

This is causing crashes on MacOS when using Metal: #120504

nikitalita added a commit to nikitalita/godot that referenced this pull request Jun 22, 2026
…ds/group-task-for-shader-cache-load"

This reverts commit 9700abd, reversing
changes made to fcfc285.
@blueskythlikesclouds
blueskythlikesclouds deleted the group-task-for-shader-cache-load branch June 30, 2026 11:47
BendyLand pushed a commit to BendyLand/voltaire that referenced this pull request Aug 2, 2026
…-task-for-shader-cache-load

Allow shader containers to be loaded in parallel.
pirey0 pushed a commit to Bippinbits/pvkk-godot that referenced this pull request Aug 8, 2026
…-task-for-shader-cache-load

Allow shader containers to be loaded in parallel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants