Skip to content

fix(vr): full-resolution underwater mask#34

Merged
alandtse merged 4 commits into
devfrom
fix-vr-fullres-underwater-mask
May 24, 2026
Merged

fix(vr): full-resolution underwater mask#34
alandtse merged 4 commits into
devfrom
fix-vr-fullres-underwater-mask

Conversation

@alandtse
Copy link
Copy Markdown
Owner

@alandtse alandtse commented May 23, 2026

Summary

Cherry-picks b2a9b0e49 from ParticleTroned/cs-1.5-PL-VR — the underwater mask repair pass currently bails when IsUpscalingActive() is false (DLAA, TAA, or no upscaler), so VR users on those paths see a broken underwater mask. ParticleTroned's fix lets UpscaleDepth() run in the full-resolution mask path (vendor upscaler at qualityMode=0 / TAA / kNONE in VR) to refresh the depth source the analytical mask needs, then dispatches the existing underwater-mask repair draw.

Authorship preserved via git cherry-pick -x — original commit is by @ParticleTroned, the cherry-pick adds a (cherry picked from commit b2a9b0e49) trailer.

What it changes

src/Features/Upscaling.cpp::UpscaleDepth:

  • Early-exit broadens: was if (!IsUpscalingActive()) return;. Now also runs when isVR && fullResolutionMaskPath && !depthUpscaleActive, where fullResolutionMaskPath covers kNONE / kTAA / vendor-upscaler-at-DLAA.
  • Resource-presence guard split: upscaleDepthStencilState, refractionNormals.*, saoCameraZ.RTV, and depth.views[0] are only required when depthUpscaleActive (the full-res mask path doesn't draw the depth-refinement pass, just the mask draw).
  • Wide-kernel hysteresis block + the original depth-refinement draw move under if (depthUpscaleActive).
  • New else branch refreshes depthCopy.texture from depth.texture so the underwater mask PS gets fresh depth.
  • Main_PostProcessing now also calls UpscaleDepth() in the VR-kNONE / VR-kTAA branch (where PerformUpscaling isn't called).

Why this isn't already on dev

b2a9b0e49 lives only on ParticleTroned's cs-1.5-PL-VR / cs-1.5-PL-VR-unleashed branches and was never opened upstream. Surfacing it here so the fork has it on dev.

Test plan

  • VR + DLSS DLAA: underwater scene shows correct tint mask
  • VR + TAA: same
  • VR + no upscaler: same
  • VR + DLSS Quality/Balanced/Performance: behavior unchanged (already covered by depthUpscaleActive branch)
  • Non-VR builds: behavior unchanged (the new branch is isVR &&-gated)

Credit

@ParticleTroned for the original fix.

Summary by CodeRabbit

  • Refactor
    • Reworked depth upscaling and VR rendering paths to be more robust and efficient, improving stability and maintainability.
  • Bug Fixes
    • Improved validation and conditional handling so depth/underwater-mask upscaling and VR full-resolution repair run only when needed, reducing visual artifacts and unnecessary work.

Review Change Stack

Copilot AI review requested due to automatic review settings May 23, 2026 18:45
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b70e806c-05d8-4501-8994-3209401e3fd0

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8c5b2 and 91bfe90.

📒 Files selected for processing (1)
  • src/Features/Upscaling.cpp

📝 Walkthrough

Walkthrough

UpscaleDepth was refactored to centralize depth-upscale gating, add finer resource validation, value-initialize jitter CB, reorganize depth-copy/stencil/render-target steps for active vs VR-repair flows, tighten VR propagation conditions, and update Main_PostProcessing dispatch routing.

Changes

Upscale Depth Refactoring

Layer / File(s) Summary
Depth upscale gate and resource validation
src/Features/Upscaling.cpp
UpscaleDepth computes depthUpscaleActive, derives full-resolution-mask and VR-repair flags, expands early-return checks, and validates depth/depthCopy and underwater-mask resources; depth-refraction PS is selected only when depthUpscaleActive.
Constant buffer initialization refactoring
src/Features/Upscaling.cpp
JitterCB jitterData{} is value-initialized before writing jitter values; wide-kernel hysteresis runs only when depthUpscaleActive.
Render pass reorganization and VR stencil logic
src/Features/Upscaling.cpp
Active path: scoped zone, copy depth->depthCopy (skip aliases), VR-only stencil clear to 0xFF, configure DSV/RTVs with isVR-dependent RTV slot, and draw depth refraction fullscreen. Inactive VR-repair path refreshes depthCopy for underwater-mask stage.
VR depth propagation condition tightening
src/Features/Upscaling.cpp
Propagate depth into kMAIN_COPY only when globals::game::isVR && depthUpscaleActive; skip propagation on the full-resolution repair path.
Main_PostProcessing dispatch update
src/Features/Upscaling.cpp
For non-NONE/non-TAA upscaling call PerformUpscaling(); otherwise call UpscaleDepth() only when VR fallback is required.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I nibble through the render pass, soft and spry,
Jitter tidy, buffers initialized by and by,
Guards in place where depths may creep,
VR paths mend what shadows keep,
A rabbit cheers the pixels dry. 🐰✨

🚥 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.
Title check ✅ Passed The title 'fix(vr): full-resolution underwater mask' clearly summarizes the main change—a fix for VR's full-resolution underwater mask handling in the upscaling system.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-vr-fullres-underwater-mask

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.21.0)

OpenGrep fatal error (exit code 2): [00.12][ERROR]: Error: exception Unix_error: No such file or directory stat src/Features/Upscaling.cpp
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from S


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

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

Fixes a VR-specific rendering regression where the underwater mask repair pass could bail out when vendor upscaling wasn’t “active” (DLAA / TAA / no upscaler), leaving the underwater tint/mask broken on those full-resolution paths. The change fits into the Upscaling feature’s postprocessing pipeline by ensuring the depth source used by the underwater-mask repair is refreshed even when no depth upscaling draw is performed.

Changes:

  • Extends UpscaleDepth() to run on VR full-resolution mask paths (kNONE / kTAA / DLAA/NativeAA) even when IsUpscalingActive() is false, with split resource validation depending on whether depth upscaling is actually active.
  • Gates the wide-kernel hysteresis + depth-refinement draw behind depthUpscaleActive, and adds a full-resolution branch that refreshes depthCopy from depth.
  • Updates Main_PostProcessing to call UpscaleDepth() on the VR kNONE/kTAA path where PerformUpscaling() is not invoked.

Comment thread src/Features/Upscaling.cpp
The non-upscale branch already refreshes depthCopy from depth before
running the underwater mask draw; the unconditional VR propagate block
then copied the same resource a second time per frame. Gate the
propagate on depthUpscaleActive so the full-resolution path issues
exactly one CopyResource.
@alandtse alandtse changed the title fix(vr): repair full-resolution underwater mask fix(vr): full-resolution underwater mask May 23, 2026
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Features/Upscaling.cpp`:
- Around line 1867-1869: The early return 'if (isVR && !depthCopy.stencilSRV) {
return; }' incorrectly applies to the full-resolution repair path (which only
updates depthCopy.texture and uses depthCopy.depthSRV for the underwater-mask
pass), so narrow this guard to only the VR upscale path: move or change the
condition so the check for depthCopy.stencilSRV runs only when executing the
upscale path (e.g., wrap it inside the upscale branch or add an isUpscalePath
flag check), leaving the full-resolution repair branch able to proceed even when
stencilSRV is unavailable; reference symbols: isVR, depthCopy.stencilSRV,
depthCopy.texture, depthCopy.depthSRV, underwater-mask pass, and the upscale
branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a963c803-bb87-4e7d-8b5f-6cec21da91b1

📥 Commits

Reviewing files that changed from the base of the PR and between 8b162bd and 6f8c5b2.

📒 Files selected for processing (1)
  • src/Features/Upscaling.cpp

Comment thread src/Features/Upscaling.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

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

The full-resolution underwater mask repair samples depthCopy.depthSRV
only; it never binds depthCopy.stencilSRV (an upscale-path input) or
depth.views[0] (DSV for the depth-refinement draw). Requiring them in
the shared early-exit disabled the VR repair on setups where stencil
SRV creation isn't available, even though that branch can still
succeed. Collapse both into one upscale-path guard.
Copilot AI review requested due to automatic review settings May 23, 2026 20:00
Copy link
Copy Markdown

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

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

Comment thread src/Features/Upscaling.cpp Outdated
Comment thread src/Features/Upscaling.cpp
Two Copilot review findings:

1. UpscaleDepth() can now be invoked standalone from Main_PostProcessing
   on the kNONE/kTAA VR path, bypassing Upscale()'s explicit RT unbind.
   The first CopyResource on depth/depthCopy can then race a still-bound
   DSV. Mirror Upscale()'s precondition by unbinding RTs at entry.

2. Use the existing local isVR flag in the propagate gate instead of
   re-reading globals::game::isVR.
@alandtse alandtse merged commit 37dfdee into dev May 24, 2026
20 checks passed
@alandtse alandtse deleted the fix-vr-fullres-underwater-mask branch May 24, 2026 04:07
alandtse added a commit that referenced this pull request May 24, 2026
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