Skip to content

feat(tracy): add additional zones#1760

Merged
alandtse merged 3 commits into
community-shaders:devfrom
alandtse:tracy_fixes
Jan 25, 2026
Merged

feat(tracy): add additional zones#1760
alandtse merged 3 commits into
community-shaders:devfrom
alandtse:tracy_fixes

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented Jan 25, 2026

Summary by CodeRabbit

  • Refactor

    • Simplified internal feature iteration to streamline lifecycle handling and improve maintainability.
  • Chores

    • Added and standardized profiling hooks and tracing labels to improve performance monitoring and diagnostics.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 25, 2026 10:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 25, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a new Feature::ForEachLoadedFeature(template) to centralize iteration over loaded features with optional Tracy profiling, and updates multiple call sites to use it. Adds and adjusts profiling zones in Deferred.cpp, State.cpp, ShaderCache.cpp, and ScreenSpaceShadows.cpp; no exported API changes.

Changes

Cohort / File(s) Summary
Feature Iteration Abstraction
src/Feature.h
Adds template<typename Func> static inline void ForEachLoadedFeature(std::string_view methodName, Func&& callback) that iterates GetFeatureList() and calls callback(feature) only for feature->loaded, wrapping calls in Tracy ZoneScoped/ZoneText when TRACY_ENABLE is defined.
Deferred render-pass updates
src/Deferred.cpp
Replaced manual per-feature loops for ReflectionsPrepass/EarlyPrepasses/PrepassPasses with ForEachLoadedFeature calls; updated Tracy context references from globals::game::graphicsState->tracyCtx to globals::state->tracyCtx; adjusted zone name to "Reflections Prepass".
State lifecycle & per-feature calls
src/State.cpp
Replaced manual loops with ForEachLoadedFeature for Reset and SetupResources; added ZoneScoped/ZoneScopedN profiling around State::Draw and several per-feature update blocks (WeatherManager, TerrainBlending, CloudShadows, TerrainHelper, TruePBR).
Plugin lifecycle refactors
src/XSEPlugin.cpp
Replaced GetFeatureList loops for PostPostLoad, DataLoaded, and Load sequences with ForEachLoadedFeature calls invoking respective feature methods.
Profiling additions
src/ShaderCache.cpp, src/Features/ScreenSpaceShadows.cpp
Added ZoneScoped/ZoneText around shader compilation in ShaderCompilationTask::Perform(); simplified per-eye Tracy usage in ScreenSpaceShadows dispatch to a fixed Tracy label ("SSS - Ray March") and localized perf event naming when enabled.

Sequence Diagram(s)

(omitted — changes are internal iteration and profiling refactors without a multi-component sequential flow that benefits from a diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

Suggested reviewers

  • doodlum

Poem

🐰 A template hops through lists so fair,

ForEachLoadedFeature takes care with flair,
Zones light up where profiling used to roam,
Loops consolidated, each feature finds home,
A tiny rabbit cheers: "Refactor — hop on!" 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title focuses on adding Tracy zones, but the PR primarily refactors feature iteration loops to use ForEachLoadedFeature, which is a significant structural change beyond just adding profiling zones. Consider a more comprehensive title like 'refactor(feature): consolidate feature iteration with ForEachLoadedFeature and tracy zones' to accurately reflect the main change.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Using provided base ref: a077f9e
Using base ref: a077f9e
Base commit date: 2026-01-25T01:56:31-08:00 (Sunday, January 25, 2026 01:56 AM)
No actionable suggestions for changed features.

@alandtse alandtse changed the title Tracy_fixes feat(tracy): add additional zones Jan 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Tracy profiling integration by introducing a new ForEachLoadedFeature helper method that adds automatic CPU profiling zones when iterating over loaded features. It also fixes incorrect Tracy context references in Deferred.cpp and simplifies profiling code in ScreenSpaceShadows.cpp.

Changes:

  • Introduced Feature::ForEachLoadedFeature() template method that automatically adds Tracy CPU profiling zones
  • Replaced manual feature iteration loops with the new helper in XSEPlugin.cpp, State.cpp, and Deferred.cpp
  • Added profiling zones to State::Draw() and ShaderCache compilation
  • Fixed incorrect globals::game::graphicsState->tracyCtx references to use globals::state->tracyCtx in Deferred.cpp

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Feature.h Added new ForEachLoadedFeature() template method with Tracy CPU profiling support
src/XSEPlugin.cpp Replaced manual feature iteration with ForEachLoadedFeature() for PostPostLoad, DataLoaded, and Load methods
src/State.cpp Replaced manual feature iteration with ForEachLoadedFeature() for Reset and SetupResources; added profiling zones to Draw()
src/ShaderCache.cpp Added Tracy profiling zones to shader compilation tasks
src/Features/ScreenSpaceShadows.cpp Simplified Tracy profiling code by removing unnecessary string formatting
src/Deferred.cpp Fixed incorrect tracyCtx references and replaced manual feature iteration with ForEachLoadedFeature()

Comment thread src/Feature.h Outdated
Comment thread src/Feature.h Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Features/ScreenSpaceShadows.cpp (1)

103-108: PR metadata: conventional title + issue keyword

The PR title isn’t in conventional-commit format. Consider something like fix(tracing): standardize tracy zones (≤50 chars). If this fixes a bug, add a keyword reference (e.g., Fixes #123``). As per coding guidelines, ...

🧹 Nitpick comments (2)
src/ShaderCache.cpp (1)

2648-2650: Missing TRACY_ENABLE preprocessor guards.

The Tracy macros ZoneScoped and ZoneText are used without #ifdef TRACY_ENABLE guards. While Tracy macros typically expand to no-ops when profiling is disabled at compile time, for consistency with the pattern established in Feature.h (lines 192-203), consider adding explicit guards.

Suggested fix
 void ShaderCompilationTask::Perform() const
 {
+#ifdef TRACY_ENABLE
 	ZoneScoped;
 	ZoneText(GetString().c_str(), GetString().size());
+#endif

 	if (shaderClass == ShaderClass::Vertex) {
src/Feature.h (1)

187-206: Well-designed centralized feature iteration with profiling support.

The ForEachLoadedFeature template provides a clean abstraction for iterating over loaded features with optional Tracy profiling. The use of thread_local for zoneName is appropriate for minimizing allocations in multi-threaded scenarios.

Minor nit: There's an extra blank line at line 202 before #endif.

Optional formatting fix
 `#else`
 				callback(feature);
-
 `#endif`
 			}
 		}

,

@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit 21d5fcc into community-shaders:dev Jan 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants