Skip to content

Allow shader containers to be loaded in parallel.#119123

Open
blueskythlikesclouds wants to merge 1 commit into
godotengine:masterfrom
blueskythlikesclouds:group-task-for-shader-cache-load
Open

Allow shader containers to be loaded in parallel.#119123
blueskythlikesclouds wants to merge 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

Copy link
Copy Markdown
Contributor

@DarioSamo DarioSamo left a comment

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
Copy link
Copy Markdown
Member

@Ivorforce Ivorforce left a comment

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
jak6jak added a commit to jak6jak-experiment/godot that referenced this pull request May 19, 2026
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.

6 participants