Plat 9853 resource descriptor set removal - #89
Closed
JohnGreenFC wants to merge 27 commits into
Closed
Conversation
…veturretset and update clang format to never wrap
# Conflicts: # trinity/Eve/Turret/EveTurretSet.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…scriptor-set-removal # Conflicts: # trinity/Eve/SpaceObject/Children/EveChildTurret.cpp # trinity/Eve/SpaceObject/Children/EveChildTurret.h # trinity/Eve/Turret/EveTurretAiming.h # trinity/Eve/Turret/EveTurretSet.cpp # trinity/Eve/Turret/EveTurretSet.h # trinity/Tr2GrannyAnimation.h
Bindless sampler handles appear as fake sampler registers (100+) in the effect description. Binding them failed and stopped the remaining static bindings, including the bindless texture heap view, from being applied, so shaders like specialfx/ubershader read the wrong textures.
There was a problem hiding this comment.
🟡 Changes recommended
It contains at least one incorrect resource binding (texture UAV cleared via buffer overload) and a broken include path that can prevent compilation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR removes the cross-platform “resource descriptor set” abstraction that was retaining GPU resource references across scene transitions, and replaces it with direct per-frame resource binding on the render context (DX11/DX12/Metal) to prevent large GPU memory leaks.
Changes:
- Removed
Tr2ResourceSetALandTr2ResourceSetDescriptionAL(and platform implementations), introducingTr2RegisterMapALandTr2StaticResourceBindingsALfor lightweight static (sampler/heap-view) bindings. - Added direct binding APIs on render contexts (
SetSrv,SetUav,SetSampler, heap-view setters, andResetResourceBindings) and updated engine code and tests to use them. - Updated DX12/Metal/DX11 binding/transition logic to commit pending bindings at draw/dispatch time and to track used resources for barrier flushing.
File summaries
| File | Description |
|---|---|
| trinityal/tests/Rendering.cpp | Updates rendering tests to bind SRVs/samplers directly instead of resource sets. |
| trinityal/tests/Raytracing.cpp | Updates raytracing tests to bind SRV/UAV and sampler directly; removes resource-set setup. |
| trinityal/tests/Compute.cpp | Updates compute tests to bind SRV/UAV directly and reset bindings via ResetResourceBindings(). |
| trinityal/stub/Tr2ShaderProgramALStub.h | Replaces resource-set include with register-map include for stub builds. |
| trinityal/stub/Tr2ResourceSetALStub.h | Deletes stub resource-set implementation (no longer used). |
| trinityal/stub/Tr2ResourceSetALStub.cpp | Deletes stub resource-set implementation (no longer used). |
| trinityal/stub/Tr2RenderContextStub.h | Replaces SetResourceSet with direct binding APIs and ResetResourceBindings() in the stub context. |
| trinityal/stub/Tr2RenderContextStub.cpp | Implements stub no-op versions of the new binding/reset APIs. |
| trinityal/src/upscaling/Tr2Fsr1Upscaling.cpp | Switches FSR1 compute dispatch to direct SRV/UAV/sampler bindings. |
| trinityal/src/Tr2StaticResourceBindingsAL.cpp | Adds implementation for reusable static bindings (samplers/heap views). |
| trinityal/src/Tr2ResourceSetAL.cpp | Removes core Tr2ResourceSetAL implementation. |
| trinityal/src/Tr2RegisterMapAL.cpp | Adds standalone implementation for shader register mapping. |
| trinityal/metal/Tr2ShaderProgramALMetal.mm | Removes Metal dummy-resource binding function formerly tied to resource sets. |
| trinityal/metal/Tr2ShaderProgramALMetal.h | Removes resource-set dependencies/friendship; switches to register-map include. |
| trinityal/metal/Tr2ShaderALMetal.h | Replaces resource-set include with MetalWorkQueue include. |
| trinityal/metal/Tr2RtPipelineStateALMetal.h | Removes resource-set include dependency. |
| trinityal/metal/Tr2ResourceSetALMetal.mm | Deletes Metal resource-set implementation. |
| trinityal/metal/Tr2ResourceSetALMetal.h | Deletes Metal resource-set header. |
| trinityal/metal/Tr2RenderContextMetal.mm | Implements pending-binding collection/commit, replaces resource-set binding, and applies dummy resources during commit. |
| trinityal/metal/Tr2RenderContextMetal.h | Adds pending-binding state to Metal render context; removes resource-set member. |
| trinityal/include/upscaling/Tr2Fsr1Upscaling.h | Removes resource-set include; includes sampler state for direct binding. |
| trinityal/include/TrinityAL.h | Replaces public resource-set header exposure with register-map + static-bindings headers. |
| trinityal/include/Tr2TextureAL.h | Removes resource-set friendship/forward decl. |
| trinityal/include/Tr2StaticResourceBindingsAL.h | Adds public API for reusable static bindings (samplers/heap views). |
| trinityal/include/Tr2ShaderProgramAL.h | Removes resource-set friendship/forward decl. |
| trinityal/include/Tr2SamplerStateAL.h | Removes resource-set friendship/forward decl. |
| trinityal/include/Tr2RtShaderTableAL.h | Removes resource-set include dependency. |
| trinityal/include/Tr2RtPipelineStateAL.h | Removes resource-set friendship. |
| trinityal/include/Tr2ResourceSetAL.h | Removes public resource-set API header. |
| trinityal/include/Tr2RegisterMapAL.h | Adds new public register-map header (formerly embedded in resource-set header). |
| trinityal/include/Tr2BufferAL.h | Removes resource-set friendship/forward decl. |
| trinityal/dx12/util/DescriptorStateCacheDx12.h | Switches constants from resource-set max to register-map max size. |
| trinityal/dx12/util/DescriptorStateCacheDx12.cpp | Updates loops to use Tr2RegisterMapAL::MAX_RESOURCES_IN_STAGE. |
| trinityal/dx12/upscaling/Tr2XessUpscaling.cpp | Replaces SetResourceSet(Tr2ResourceSetAL()) with ResetResourceBindings() prior to barrier flush. |
| trinityal/dx12/Tr2TextureALDx12.h | Removes resource-set friendship/forward decl. |
| trinityal/dx12/Tr2TextureALDx12.cpp | Ensures bindings are reset and barriers flushed before mip generation work. |
| trinityal/dx12/Tr2StreamlineALDx12.h | Removes DX12 resource-set include dependency. |
| trinityal/dx12/Tr2ShaderProgramALDx12.h | Replaces resource-set include with register-map include; removes resource-set friendship. |
| trinityal/dx12/Tr2SamplerStateALDx12.h | Removes resource-set friendship. |
| trinityal/dx12/Tr2ResourceSetALDx12.h | Deletes DX12 resource-set header. |
| trinityal/dx12/Tr2ResourceSetALDx12.cpp | Deletes DX12 resource-set implementation. |
| trinityal/dx12/Tr2RenderContextDx12.h | Adds direct binding APIs and internal pending-binding state. |
| trinityal/dx12/Tr2RenderContextDx12.cpp | Implements pending binding collection/commit and transition tracking; removes resource-set binding path. |
| trinityal/dx12/Tr2PrimaryRenderContextDx12.cpp | Resets bindings prior to present instead of clearing resource set. |
| trinityal/dx12/Tr2BufferALDx12.h | Removes resource-set friendship. |
| trinityal/dx11/Tr2TextureALDx11.h | Removes resource-set friendship/forward decl. |
| trinityal/dx11/Tr2ShaderProgramALDx11.h | Replaces resource-set include with register-map include. |
| trinityal/dx11/Tr2SamplerStateALDx11.h | Removes resource-set friendship. |
| trinityal/dx11/Tr2ResourceSetALDx11.h | Deletes DX11 resource-set header. |
| trinityal/dx11/Tr2ResourceSetALDx11.cpp | Deletes DX11 resource-set implementation. |
| trinityal/dx11/Tr2RenderContextDx11.h | Adds direct binding APIs and pending-binding state; removes resource-set tracking members. |
| trinityal/dx11/Tr2BufferALDx11.h | Removes resource-set friendship. |
| trinityal/CMakeLists.txt | Removes resource-set sources and adds register-map + static-bindings sources/headers. |
| trinity/TriVariable.h | Changes effect resource binding hooks to direct render-context binding methods. |
| trinity/TriVariable.cpp | Implements direct SRV/UAV binding for TriVariable resources. |
| trinity/Tr2VolumetricsRenderer.cpp | Updates RT material binding call signature after resource-set removal. |
| trinity/Tr2LightManager.cpp | Updates RT material binding call signature after resource-set removal. |
| trinity/Sprite2d/Tr2Sprite2dScene.cpp | Switches sprite texture binding from pass resource-set desc mutation to direct SetSrv calls. |
| trinity/Sprite2d/Tr2Sprite2dDisplayList.h | Stores texture register indices and color space for replay-time direct binding. |
| trinity/Sprite2d/Tr2Sprite2dDisplayList.cpp | Applies per-entry direct SRV bindings during display-list replay. |
| trinity/Shader/Tr2Material.h | Replaces resource-set caching fields with static binding storage; updates RT apply API. |
| trinity/Shader/Tr2Material.cpp | Removes resource-set creation/caching; resets and applies bindings directly per pass/library. |
| trinity/Shader/Tr2EffectDescription.h | Replaces per-pass resource-set desc with static bindings; adds static-binding include. |
| trinity/Shader/Tr2EffectDescription.cpp | Populates static sampler/heap-view bindings from effect description data. |
| trinity/Shader/Tr2Effect.cpp | Updates sampler override rebuild and cached data rebuild to operate on static bindings. |
| trinity/Shader/Parameter/TriVariableParameter.h | Updates parameter interface to bind SRV/UAV directly via render context. |
| trinity/Shader/Parameter/TriVariableParameter.cpp | Implements new direct-binding parameter methods. |
| trinity/Shader/Parameter/TriTextureParameter.h | Updates parameter interface to bind SRV/UAV directly via render context. |
| trinity/Shader/Parameter/TriTextureParameter.cpp | Implements direct SRV/UAV bindings for texture parameters. |
| trinity/Shader/Parameter/Tr2TextureAnimationParameter.h | Updates parameter interface to bind SRV/UAV directly via render context. |
| trinity/Shader/Parameter/Tr2TextureAnimationParameter.cpp | Updates modification behavior and SRV binding to use render-context APIs. |
| trinity/Shader/Parameter/Tr2RuntimeTextureParameter.h | Updates parameter interface to bind SRV/UAV directly via render context. |
| trinity/Shader/Parameter/Tr2RuntimeTextureParameter.cpp | Implements direct SRV/UAV bindings and updates invalidation path. |
| trinity/Shader/Parameter/Tr2GeometryBufferParameter.h | Updates parameter interface to bind SRV/UAV directly via render context. |
| trinity/Shader/Parameter/Tr2GeometryBufferParameter.cpp | Implements direct SRV/UAV bindings for geometry buffers. |
| trinity/Raytracing/Tr2RaytracingManager.cpp | Updates RT material binding call signature after resource-set removal. |
| trinity/Raytracing/Tr2RaytracingGeometry.cpp | Clears bindings via ResetResourceBindings() in transform path. |
| trinity/ITr2EffectValue.h | Updates effect value interface from resource-set mutation to render-context binding. |
| trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.h | Updates effect resource parameter interface to direct binding. |
| trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.cpp | Implements direct SRV binding for cloud volume textures. |
| trinity/Eve/SpaceObject/Children/EveChildMesh.cpp | Minor logic change while adapting to new binding system (removes unused local). |
Review details
- Files reviewed: 82/82 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
8
to
12
| #include "../Tr2IndirectDrawBuffer.h" | ||
|
|
||
| #include <../trinityal/include/Tr2StaticResourceBindingsAL.h> | ||
|
|
||
| extern const BlueSharedString DEFAULT_TECHNIQUE; |
Comment on lines
88
to
91
| else | ||
| { | ||
| return resourceDesc.SetUav( stage, registerIndex, Tr2BufferAL() ); | ||
| renderContext.SetUav( stage, registerIndex, Tr2BufferAL() ); | ||
| } |
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
We have a auto register resource leak when you jump between various scenes in the game, resources that are auto registered on the GPU can "leak" and keep references around that stop it from being cleaned up resulting in larger 1GB+ memory leaks depending on the scenario. This task removed the descriptor set system that has been causing the issue and we now directly bind resources every frame.
AI assistance disclosure
AI used to take old first pass of this task that became out dated and update it based on recent trinity changes.
Type of change
Linked issue (optional)
Plat 9853
What changed
Testing
I ran probe tests and I'm game test to confirm things look correct and that the memory leak is now gone.
Platforms tested
Checklist