Skip to content

Skip pre-baked atlas variants the gpu shaders already cover - #88720

Merged
Maleclypse merged 6 commits into
CleverRaven:masterfrom
dobbry-vechur:feat/atlas-bake-plan
Sep 19, 2026
Merged

Maleclypse merged 6 commits into
CleverRaven:masterfrom
dobbry-vechur:feat/atlas-bake-plan

Conversation

@dobbry-vechur

Copy link
Copy Markdown
Contributor

Summary

Performance "Use less VRAM on the gpu renderer by not pre-baking atlas variants the shaders draw"

Purpose of change

Every tileset atlas is uploaded 6 times. On the gpu renderer sprite shaders already draw shadow, night vision, overexposed, memory from normal atlas, so those 4 copies just sit in VRAM. #87787 and #88270 are VRAM running out on D3D12 and Vulkan.

Describe the solution

Each upload now picks which variants to bake. With the shader path live it bakes normal and silhouette, plus memory for the custom overlay (no shader). Other renderers bake all six, same as before.

Upload first probes shaders. Probe/bind failure leaves a sticky fault, and every subsequent upload bakes all six.

Skipped tilesets go stale when shaders are gone or memory overlay switches to custom. Tilesets record what they were baked with, and the present gate holds frames until recovery replay rebakes them.

Saved memory map overlay and scaling mode changes are now done via that replay, so no need to restart the custom overlay anymore.

CATA_FORCE_ATLAS_VARIANTS=1 bakes all six anyway, CATA_DISABLE_SPRITE_SHADERS=1 turns sprite shaders off. Added some logging for this process.

Describe alternatives you've considered

Dropping the baked variants for good. The opengl, direct3d and software renderers still draw from them, and Android can pick software.

Testing

Loaded a save with ultica on local nvidia dgpu, several runs in each direction. VRAM usage dropped from 654 MiB to ~240 MiB. Atlas upload time dropped from ~1.45 s to 0.84 s.

New unit tests cover bake plan, probe states, options repair and recovery paths.

Additional context

N/A

@github-actions github-actions Bot added <Documentation> Design documents, internal info, guides and help. [C++] Changes (can be) made in C++. Previously named `Code` [Markdown] Markdown issues and PRs Code: Performance Performance boosting code (CPU, memory, etc.) Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Sep 19, 2026
- added compute_atlas_bake_plan and bake_plan_summary
- added classify_bundle and bundle_needs_repair
- added tiles gpu unit tests for both
- added probe_state and variant_pass::ensure_probed
- added sticky shader_fault_ and boundary_lost_ flags
- flush and try_begin refuse while the boundary is lost
- selected the memory preset when the pass is created
- added probe, flush and bind-failure test seams and tests
- added bake plan and filter fingerprint to tileset
- upload_atlases takes a fingerprint and a bake plan
- skipped variants get empty candidate vectors
- added shader_boundary_lost to atlas_upload_interrupt
- handled shader_boundary_lost at all three dispatch sites
…play

- added apply_tile_atlas_options and on_tiles_options_changed
- the replay uploads under the applied configuration and re-keys
- added a present gate that refuses frames until repair
- the scale default follows SCALING_MODE on save
- dropped the restart note from the MEMORY_MAP_MODE help text
- added resolve_atlas_bake_plan
- tileset load, replay and synthetic install use the resolver
- an unsafe probe aborts the upload with shader_boundary_lost
- a sticky shader fault forces a full bake
- added a shader availability override test seam and tests
- added an atlas upload log line and GetGPUBackendName
- documented the runtime shader switches
@github-actions github-actions Bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 19, 2026
@Maleclypse
Maleclypse merged commit e3e319c into CleverRaven:master Sep 19, 2026
27 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants