Skip to content

chore(vr): add Tracy zones for SSS dispatches#2217

Merged
doodlum merged 1 commit into
community-shaders:devfrom
alandtse:chore/perf-tracy-zones
Apr 27, 2026
Merged

chore(vr): add Tracy zones for SSS dispatches#2217
doodlum merged 1 commit into
community-shaders:devfrom
alandtse:chore/perf-tracy-zones

Conversation

@alandtse
Copy link
Copy Markdown
Contributor

@alandtse alandtse commented Apr 27, 2026

Summary

Adds Tracy GPU and CPU profiling zones around VR stereo passes and per-eye Screen Space Shadows dispatches. No logic changes — instrumentation only.

Why

Recent VR perf investigation surfaced significant per-frame cost in the VRStereoOptimizations and StereoBlend passes that was previously invisible in Tracy captures. Without these zones, future VR perf work — both validating optimizations and identifying further targets — cannot be measured. The instrumentation gap was the single biggest blocker on data-driven VR perf decisions.

What

Eight zone categories across three files:

  • src/Features/VR/StereoBlend.cppStereoBlend - Overwrite / StereoBlend - Bilateral (conditional on isOverwriteMode).
  • src/Features/VRStereoOptimizations.cppStereoOpt - Stencil Write, StereoOpt - Mode Classify (parent), with Mode Classify Bind and Mode Classify Dispatch sub-zones.
  • src/Features/ScreenSpaceShadows.cppSSS - Left Eye / SSS - Right Eye outer zones at the DispatchEye call sites in DrawShadows(). The pre-existing SSS - Ray March zone inside the Bend dispatch loop was renamed and split into SSS - DispatchEye CB (CB upload per sweep) and SSS - DispatchEye Sweep (the dispatch itself), giving per-sweep granularity. Net effect: the loop is more profilable, not less.

Risk

Zero. Tracy macros (TracyD3D11Zone, ZoneScoped) compile to nothing when TRACY_SUPPORT=OFF (the default).

Validation

  • Built successfully with ./BuildRelease.bat ALL (default preset, TRACY_SUPPORT=OFF). No warnings introduced; the only build warning is an unrelated extern/FidelityFX-SDK CMake deprecation.
  • Captures with ALL-TRACY will surface the new zones for validation. Sample data (from a test build of these zones on a downstream branch) showed StereoOpt - Mode Classify at ~306 µs/frame and StereoBlend - Overwrite at ~303 µs/frame — costs that were entirely invisible before.

Summary by CodeRabbit

  • Chores
    • Enhanced internal performance profiling instrumentation across screen-space shadows, stereo blending, and VR stereo optimization systems for improved performance monitoring and analysis.

Add GPU/CPU profiling zones around the StereoBlendCS dispatch
(conditional Overwrite vs Bilateral name), the VRStereoOptimizations
mode-classify CS (with Bind and Dispatch sub-zones) and stencil write
pass, and per-eye SSS dispatches (Left Eye, Right Eye) with per-sweep
sub-zones (DispatchEye CB, DispatchEye Sweep) inside the DispatchEye
lambda.

Recent VR perf investigation revealed these passes had no Tracy
visibility, making cost measurement impossible. The SSS inner-loop zone
is renamed from "SSS - Ray March" to the more descriptive sub-zones.

Risk: none. TracyD3D11Zone and ZoneScoped compile out entirely when
TRACY_SUPPORT is not enabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

This PR refactors Tracy profiling instrumentation across three VR/stereo rendering features. ScreenSpaceShadows reorganizes shadow dispatch zones into separate constant-buffer and compute phases with per-eye labeling. StereoBlend adds per-branch profiling zones for overwrite vs. bilateral dispatch modes. VRStereoOptimizations adds instrumentation around stereo stencil classification and write passes, separating shader binding from dispatch operations.

Changes

Cohort / File(s) Summary
Screen Space Shadows Profiling
src/Features/ScreenSpaceShadows.cpp
Reorganizes Tracy zones in DrawShadows: replaces single "SSS - Ray March" zone with separate "SSS - DispatchEye CB" and "SSS - DispatchEye Sweep" zones for distinct phases; adds dedicated per-eye zones ("SSS - Left Eye" / "SSS - Right Eye") for VR dispatch calls.
Stereo Blend Dispatch Profiling
src/Features/VR/StereoBlend.cpp
Adds branching Tracy D3D11 zones ("StereoBlend - Overwrite" and "StereoBlend - Bilateral") around compute dispatch calls, with each zone scoped to its respective branch path.
VR Stereo Optimizations Profiling
src/Features/VRStereoOptimizations.cpp
Adds Tracy instrumentation separating shader/descriptor binding operations from the compute dispatch call in stereo stencil classification pass; wraps ExecuteStencilWritePass() in dedicated profiling zone.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • jiayev
  • doodlum
  • davo0411

Poem

🐰 Hopping through shadows with Tracy's bright light,
We measure each zone—left eye, right eye, just right!
From stereo blends to stencil's delight,
Profiling the profilers, making code shine so bright!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately describes the main change: adding Tracy instrumentation zones for VR-related and SSS dispatches, which aligns with the core purpose of the pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

No actionable suggestions for changed features.

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.

🧹 Nitpick comments (1)
src/Features/ScreenSpaceShadows.cpp (1)

232-246: Optional: consider an outer Tracy zone for the non-VR path for symmetry.

In VR, both DispatchEye calls are wrapped in "SSS - Left Eye"/"SSS - Right Eye". The non-VR call at Line 233 has no analogous outer zone, so the per-sweep zones appear directly under "Screen Space Shadows". Functionally fine (no profiling gap), but a "SSS - Mono" (or similar) wrapper would make Tracy traces structurally consistent across VR/non-VR captures. Up to you.

♻️ Optional symmetry tweak
 	if (!globals::game::isVR) {
-		DispatchEye(nullptr, GetComputeRaymarch(), lightProjectionF.data(), InvTexSizeX, InvTexSizeY);
+		TracyD3D11Zone(globals::state->tracyCtx, "SSS - Mono");
+		DispatchEye(nullptr, GetComputeRaymarch(), lightProjectionF.data(), InvTexSizeX, InvTexSizeY);
 	} else {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Features/ScreenSpaceShadows.cpp` around lines 232 - 246, Non-VR path
lacks an outer Tracy zone for symmetry with the VR branch, so wrap the single
DispatchEye call so profiling traces match both branches; when
globals::game::isVR is false, add a TracyD3D11Zone (e.g., "SSS - Mono") around
the call that invokes DispatchEye(nullptr, GetComputeRaymarch(),
lightProjectionF.data(), InvTexSizeX, InvTexSizeY) so it mirrors the "SSS - Left
Eye"/"SSS - Right Eye" zones used when calling GetComputeRaymarchRight() and
CalculateLightProjection(1).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Features/ScreenSpaceShadows.cpp`:
- Around line 232-246: Non-VR path lacks an outer Tracy zone for symmetry with
the VR branch, so wrap the single DispatchEye call so profiling traces match
both branches; when globals::game::isVR is false, add a TracyD3D11Zone (e.g.,
"SSS - Mono") around the call that invokes DispatchEye(nullptr,
GetComputeRaymarch(), lightProjectionF.data(), InvTexSizeX, InvTexSizeY) so it
mirrors the "SSS - Left Eye"/"SSS - Right Eye" zones used when calling
GetComputeRaymarchRight() and CalculateLightProjection(1).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0f2097f0-83ea-4c93-a84d-d2faacf8364a

📥 Commits

Reviewing files that changed from the base of the PR and between 790044b and c0da9df.

📒 Files selected for processing (3)
  • src/Features/ScreenSpaceShadows.cpp
  • src/Features/VR/StereoBlend.cpp
  • src/Features/VRStereoOptimizations.cpp

@alandtse alandtse changed the title chore(perf): add Tracy zones for VR stereo + per-eye SSS dispatches chore(perf): add Tracy zones for VR SSS dispatches Apr 27, 2026
@alandtse alandtse changed the title chore(perf): add Tracy zones for VR SSS dispatches chore(vr): add Tracy zones for VR SSS dispatches Apr 27, 2026
@alandtse alandtse changed the title chore(vr): add Tracy zones for VR SSS dispatches chore(vr): add Tracy zones for SSS dispatches Apr 27, 2026
@github-actions
Copy link
Copy Markdown

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

@doodlum doodlum merged commit c614997 into community-shaders:dev Apr 27, 2026
20 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit c614997)
IgorAlanAlbuquerque pushed a commit to IgorAlanAlbuquerque/skyrim-community-shaders that referenced this pull request May 29, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants