Skip to content

chore(VR): disable stereoopt by default#2097

Merged
davo0411 merged 2 commits into
community-shaders:devfrom
alandtse:stereopt_disable
Apr 13, 2026
Merged

chore(VR): disable stereoopt by default#2097
davo0411 merged 2 commits into
community-shaders:devfrom
alandtse:stereopt_disable

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented Apr 12, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Tightened VR stereo-optimization activation to respect runtime VR state and stereo mode, reducing incorrect resource use.
    • Fixed shader-define behavior so VR stereo optimizations are applied only when stencil/reprojection can dispatch.
  • Defaults

    • Changed defaults to disable stereo optimization and stereo consistency blend by default for safer VR behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 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: 1a4e11ce-b963-40ba-bbaa-d6e068736a98

📥 Commits

Reviewing files that changed from the base of the PR and between dab4079 and 723a86a.

📒 Files selected for processing (2)
  • src/Deferred.cpp
  • src/Globals.cpp
✅ Files skipped from review due to trivial changes (1)
  • src/Globals.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Deferred.cpp

📝 Walkthrough

Walkthrough

VR stereo-optimization gating was tightened and reworked: shader define injection and D3D11 hook installation are now conditioned differently, VR resource setup checks additional runtime flags, and several defaults for stereo settings were changed to disabled states.

Changes

Cohort / File(s) Summary
Deferred shader compilation
src/Deferred.cpp
Changed when VR_STEREO_OPT HLSL define is injected for main composite compute shaders — now tied to REL::Module::IsVR() rather than previous runtime-loaded flag.
VR feature logic & defaults
src/Features/VR.h, src/Features/VRStereoOptimizations.h
VR::HasShaderDefine(...) now uses stereoOpt.CanDispatchStencil() instead of stereoOpt.loaded; default stereoMode changed from EnableOff; EnableStereoBlend default changed to false.
VR resource setup
src/Features/VR.cpp
VR::SetupResources() now requires globals::game::isVR and stereoOpt.settings.stereoMode != StereoMode::Off to set up stereoOpt and mark it loaded; explicitly sets stereoOpt.loaded = false otherwise.
Global D3D11 hooks
src/Globals.cpp
Installation of D3D11 detours for OMSetDepthStencilState and ClearDepthStencilView now only occurs when globals::game::isVR and stereo mode is not Off (gating hooks on stereo-mode setting).

Sequence Diagram(s)

sequenceDiagram
    participant Init as Process startup
    participant Globals as globals::InstallD3DHooks
    participant VR as VR::SetupResources
    participant Deferred as Deferred::GetComputeMainComposite
    participant GPU as Shader compile / dispatch

    rect rgba(100,150,240,0.5)
    Init->>Globals: call InstallD3DHooks
    Globals->>VR: check isVR && stereoMode != Off
    end

    rect rgba(120,200,140,0.5)
    Init->>VR: call SetupResources
    VR->>VR: if isVR && stereoMode != Off => stereoOpt.SetupResources() / loaded=true
    VR->>VR: else stereoOpt.loaded = false
    end

    rect rgba(240,180,80,0.5)
    Deferred->>VR: query HasShaderDefine(Type::Utility)
    VR->>Deferred: return stereoOpt.CanDispatchStencil() (or false)
    Deferred->>GPU: include `VR_STEREO_OPT` define if REL::Module::IsVR() (and predicate allows)
    GPU->>GPU: compile/dispatch shader
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • davo0411
  • doodlum

Poem

🐰 With ears perked high and whiskers bright,
I hop through shaders in the night.
Gating tightened, defaults turned low,
Stencil checks now come and go.
A rabbit cheers: prepared to show delight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(VR): disable stereoopt by default' clearly and concisely summarizes the primary change across all modified files, which collectively disable stereo optimizations by default through configuration changes.

✏️ 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Deferred.cpp`:
- Around line 589-590: Change the compile-time VR define to use the stable VR
presence check instead of the transient readiness flag: replace uses of
globals::features::vr.IsStereoOptimizationCullingReady() when pushing the
"VR_STEREO_OPT" define (the code around defines.push_back({ "VR_STEREO_OPT",
nullptr })) with REL::Module::IsVR() so mainCompositeCS and
mainCompositeInteriorCS compile with the correct VR permutation; keep runtime
behavior of SRV binding (pass null when IsStereoOptimizationCullingReady() is
false) and rely on DeferredCompositeCS shader branch logic to handle the
not-ready case without recompiling.

In `@src/Globals.cpp`:
- Around line 361-364: The detour installation is incorrectly gated by
globals::features::vr.IsStereoOptimizationCullingReady(), causing hooks never to
be installed because resources are created later; update InstallD3DHooks (the
block that checks globals::game::isVR) to remove the
IsStereoOptimizationCullingReady() condition and always call the
stl::detour_vfunc<36, ID3D11DeviceContext_OMSetDepthStencilState>(a_context) and
stl::detour_vfunc<53, ID3D11DeviceContext_ClearDepthStencilView>(a_context) when
globals::game::isVR is true, relying on the existing runtime guards in the hook
thunks to protect functionality until VR::SetupResources() runs.
🪄 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: 8af8f479-f370-4b6c-b974-aed36da5f612

📥 Commits

Reviewing files that changed from the base of the PR and between f4a7ecc and dab4079.

📒 Files selected for processing (5)
  • src/Deferred.cpp
  • src/Features/VR.cpp
  • src/Features/VR.h
  • src/Features/VRStereoOptimizations.h
  • src/Globals.cpp

Comment thread src/Deferred.cpp Outdated
Comment thread src/Globals.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 12, 2026

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

@davo0411
Copy link
Copy Markdown
Collaborator

check ai and i will approve

@davo0411 davo0411 merged commit c28624d into community-shaders:dev Apr 13, 2026
17 checks passed
YtzyFvra pushed a commit to YtzyFvra/skyrim-community-shaders that referenced this pull request Apr 19, 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.

2 participants