Repository navigation
Cache RT shader table state and skip unused RT work - #123
Open
JohnGreenFC wants to merge 1 commit into
Open
JohnGreenFC wants to merge 1 commit into
JohnGreenFC wants to merge 1 commit into
Conversation
…sed RT work Cache per-shader technique and per-library hit-group state in RT shader table preparation. Reuse per-back-buffer shader table buffers and cache shader info in RT shader table creation. Skip TransformMeshes when no skinned or morphed geometry was added this frame. Skip RT material data application for shader-table entries whose library adds no records.
JohnGreenFC
marked this pull request as ready for review
October 16, 2026 13:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Goal: stop redoing raytraced-shadow setup work every frame when its result has not changed. The RT shader table is rebuilt from scratch each frame from every RT geometry entry, even though the set of shaders, libraries and hit groups is the same from one frame to the next, and some of its passes run even when they have nothing to do. This change caches what is stable, reuses GPU buffers instead of recreating them, and skips passes early when there is no work, so the main-thread cost of raytraced shadows stops scaling with object count in busy scenes.
The new cache has two halves:
Shader table description (
PrepareShaderTableDescription). While walking the RT geometry entries, two small maps are kept: one keyed by shader (RtShaderState: the resolved RT shadow technique index and a pointer to the library state) and one keyed by raytracing library handle (RtLibraryState: the library, its hit-group name per raycaster, the material index it was first assigned, whether it has been seen yet, and whether its local root signature declares any registers, i.e. whether it adds per-entry records). The first entry that uses a shader resolves its technique and library once; the first entry that uses a library registers its hit group with each pipeline manager once; every later entry is two lookups. Before, each entry re-resolved the technique index and searched a per-raycaster map of maps, copying hit-group name strings as it went. An entry whose library has already been seen and adds no local records now takes the library's material index and skips building and applying a material description altogether, which is where the remaining per-entry cost sat.Shader table buffers (
Tr2RtShaderTableAL, DX12). Instead of creating a committed upload resource, mapping it and releasing it every frame, the table keeps one persistent mapped upload buffer per back buffer (TableBuffer: resource, mapped pointer, capacity). The table is assembled in a CPU staging vector and copied in; a buffer is only recreated when the table outgrows it, with 25 % headroom rounded up to 64 KB. Shader identifiers are resolved from the pipeline once per distinct raygen, miss or hit-group name per table build rather than once per record.Linked issue (optional)
Testing
Windows, DX12, release build. Measured in the EVE Frontier client on the QA Megastructure route (1080p, low preset) against origin/main: about -1.0 ms frame mean with raytraced shadows, neutral with cascaded shadows (single flights, ~0.5 ms noise band). Smoke test of this branch alone: full route flown with raytraced shadows, no frames over 100 ms, no crash dumps. Not built on Mac.
AI assistance
AI testing, investigation and CL explanation