Repository navigation
Cache texture LOD requests per mesh across frames - #125
Open
JohnGreenFC wants to merge 5 commits into
Open
JohnGreenFC wants to merge 5 commits into
JohnGreenFC wants to merge 5 commits into
Conversation
Remove unused bounds computation in EveChildMesh::UpdateVisibility.
There was a problem hiding this comment.
Cpp-linter Review
Used clang-format v21.1.8
Click here for the full clang-format patch
diff --git a/trinity/Shader/Parameter/TriTextureParameter.h b/trinity/Shader/Parameter/TriTextureParameter.h
--- a/trinity/Shader/Parameter/TriTextureParameter.h
+++ b/trinity/Shader/Parameter/TriTextureParameter.h
@@ -33 +33 @@ public:
- void RebuildEffectHandles( Tr2Shader * effectRes );
+ void RebuildEffectHandles( Tr2Shader* effectRes );
@@ -51 +51 @@ public:
- void AddUsedTexture( Tr2BindlessResourcesAL & usedTextures ) const override;
+ void AddUsedTexture( Tr2BindlessResourcesAL& usedTextures ) const override;
@@ -60,2 +60,2 @@ public:
- void OnAddedToMaterial( Tr2Material * material ) override;
- void OnRemovedFromMaterial( Tr2Material * material ) override;
+ void OnAddedToMaterial( Tr2Material* material ) override;
+ void OnRemovedFromMaterial( Tr2Material* material ) override;
@@ -65 +65 @@ public:
- bool OnModified( Be::Var * val );
+ bool OnModified( Be::Var* val );
@@ -76,2 +76,2 @@ public:
- ICopierCustomAssignment * other,
- ICopier * copier );
+ ICopierCustomAssignment* other,
+ ICopier* copier );
@@ -80 +80 @@ public:
- void SetResource( ITr2TextureProvider * newRes );
+ void SetResource( ITr2TextureProvider* newRes );
diff --git a/trinity/Shader/Tr2Material.h b/trinity/Shader/Tr2Material.h
--- a/trinity/Shader/Tr2Material.h
+++ b/trinity/Shader/Tr2Material.h
@@ -232,3 +232,3 @@ protected:
- void ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, bool hasReroutables, Tr2RenderContext& renderContext ) const;
- void UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, bool hasReroutables, Tr2RenderContext& renderContext ) const;
- void SetResources( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, Tr2RenderContext & renderContext ) const;
+ void ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const;
+ void UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const;
+ void SetResources( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2RenderContext& renderContext ) const;
diff --git a/trinity/Tr2MeshArea.h b/trinity/Tr2MeshArea.h
--- a/trinity/Tr2MeshArea.h
+++ b/trinity/Tr2MeshArea.h
@@ -59,2 +59,2 @@ public:
- void AddOwnerMesh( Tr2MeshBase * mesh );
- void RemoveOwnerMesh( Tr2MeshBase * mesh );
+ void AddOwnerMesh( Tr2MeshBase* mesh );
+ void RemoveOwnerMesh( Tr2MeshBase* mesh );
diff --git a/trinity/Tr2MeshBase.h b/trinity/Tr2MeshBase.h
--- a/trinity/Tr2MeshBase.h
+++ b/trinity/Tr2MeshBase.h
@@ -34 +34 @@ public:
- virtual void GetBatches( ITriRenderBatchAccumulator * batches,
+ virtual void GetBatches( ITriRenderBatchAccumulator* batches,
@@ -42,2 +42,2 @@ public:
- void CollectAreaBlocks( std::vector<TriRenderBatchAreaBlock> & areaBlockVector, TriBatchType areaType ) const;
- void CollectAreaBlocksWithSharedMaterials( std::vector<TriRenderBatchAreaBlocksWithSharedMaterial> & collectors, TriBatchType areaType ) const;
+ void CollectAreaBlocks( std::vector<TriRenderBatchAreaBlock>& areaBlockVector, TriBatchType areaType ) const;
+ void CollectAreaBlocksWithSharedMaterials( std::vector<TriRenderBatchAreaBlocksWithSharedMaterial>& collectors, TriBatchType areaType ) const;
@@ -56 +56 @@ public:
- bool GetBoundingBox( Vector3 & min, Vector3 & max ) const;
+ bool GetBoundingBox( Vector3& min, Vector3& max ) const;
@@ -91 +91 @@ public:
- virtual void GetDebugOptions( Tr2DebugRendererOptions & options );
+ virtual void GetDebugOptions( Tr2DebugRendererOptions& options );
diff --git a/trinity/include/ITriEffectParameter.h b/trinity/include/ITriEffectParameter.h
--- a/trinity/include/ITriEffectParameter.h
+++ b/trinity/include/ITriEffectParameter.h
@@ -16 +16 @@ BLUE_INTERFACE( ITriEffectParameter ) :
- virtual void RebuildEffectHandles( Tr2Shader * effectRes ) = 0;
+ virtual void RebuildEffectHandles( Tr2Shader* effectRes ) = 0;
@@ -30,3 +30,9 @@ BLUE_INTERFACE( ITriEffectResourceParameter ) :
- public ITriEffectParameter{
- virtual void OnAddedToMaterial( Tr2Material * material ){} virtual void OnRemovedFromMaterial( Tr2Material * material ){}
- };
+ public ITriEffectParameter
+{
+ virtual void OnAddedToMaterial( Tr2Material* material )
+ {
+ }
+ virtual void OnRemovedFromMaterial( Tr2Material* material )
+ {
+ }
+};
✨ Powered by cpp-linter -- ⭐ Star • ❤️ Sponsor • 💬 Feedback
Author
|
cpp-linter: I did not touch these lines. |
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 re-deriving the same texture LOD requests for every visible mesh every frame. The requests a mesh issues depend only on its on-screen size and the textures bound by its materials, and for most meshes neither changes from one frame to the next, yet the full material walk ran each frame regardless. This change remembers the result of one walk together with the range of screen sizes over which it stays valid, and replays it until the mesh leaves that range or a texture changes.
1. The cache (
Tr2ScreenSizeRequests,Tr2MeshBase::UseWithScreenSize).Each mesh keeps one
Tr2ScreenSizeRequests: the list of (texture, LOD) pairs its last material walk requested, plus a[minScreenSize, maxScreenSize)interval. On a hit (same geometry, mesh LOD, world radius and generation, and the screen size inside the interval) the mesh replays the requests directly on the textures and returns. On a miss it re-walks its material areas throughUsedWithScreenSize, which fills the request list. A miss counter is kept (Trinity/Mesh/screenSizeRequestCacheMisses); misses are rare in practice.2. The validity interval (
TriTextureParameter::RequestLod).A texture's requested LOD only changes when screen size divided by the material's UV density crosses a power of two of the texture resolution. While computing a request, each texture parameter narrows the interval to the band in which its own LOD stays the same (with a small epsilon on either side), so the interval is the intersection over all textures in the mesh. A parameter whose request cannot be bounded that way marks the entry invalid, so that mesh re-walks every frame as before.
3. Invalidation.
A global generation counter is bumped whenever a cached request could go stale: a texture parameter is initialised, assigned a new resource or path, a texture finishes loading or is destroyed, or an effect's loddable parameters are rebuilt or released. Any mesh whose cache was built under an older generation misses once and rebuilds.
Also removes an unused bounds computation in
EveChildMesh::UpdateVisibility(an animated-bounds query whose result was never read). Toggle:meshScreenSizeRequestCache.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 -0.3 ms frame mean with raytraced shadows and -0.4 ms 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