Skip to content

fix: misc fixes#1480

Merged
doodlum merged 18 commits into
devfrom
upscaling-fixes
Sep 17, 2025
Merged

fix: misc fixes#1480
doodlum merged 18 commits into
devfrom
upscaling-fixes

Conversation

@doodlum
Copy link
Copy Markdown
Collaborator

@doodlum doodlum commented Sep 16, 2025

Summary by CodeRabbit

  • New Features

    • FXAA is automatically disabled to avoid double anti-aliasing.
  • Improvements

    • Built-in sharpening enabled for the FidelityFX upscaler.
    • Volumetric lighting and skylighting now use dynamic interior/exterior detection and adapt to dynamic screen size.
    • Frame limiter runs only when VSync is off.
    • Reflections handling tightened to reduce unwanted reflections outside water.
  • Refactor

    • DLSS now always uses Preset K and shows a simplified preset label; improved snow shader and IBLF disabled by default.
  • Chores

    • NVIDIA Image Scaling (NIS) sharpening and related settings removed.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR removes NVIDIA Image Scaling (NIS) shaders, configs, and runtime; deletes NIS sharpening UI/serialization; forces DLSS preset K; enables FidelityFX sharpening flag; adjusts frame-limiter timing; changes volumetric/reflection interior detection; adds FXAA/IBLF disable hooks; and makes Load() always return true.

Changes

Cohort / File(s) Summary
NIS shader removal
features/Upscaling/Shaders/Upscaling/NIS/NIS_Scaler.h, features/Upscaling/Shaders/Upscaling/NIS/NIS_Sharpen.hlsl
Deleted NIS scaler/sharpen shader sources and compute entry points.
NIS runtime & API removal
src/Features/Upscaling/NIS/NIS.cpp, src/Features/Upscaling/NIS/NIS.h, src/Features/Upscaling/NIS/NIS_Config.h
Removed NIS class, implementation, config structs/enums, update-config helpers, and coefficient data.
Upscaling core & UI
src/Features/Upscaling.cpp, src/Features/Upscaling.h
Removed NIS settings/serialization/member and ApplyNISSharpening; forced DLSS preset K; added FXAA-off patch wiring.
FidelityFX dispatch
src/Features/Upscaling/FidelityFX.cpp
Set dispatchUpscale.enableSharpening = true for the FidelityFX path.
Swapchain timing
src/Features/Upscaling/DX12SwapChain.cpp
Frame limiter call moved to only run when SyncInterval == 0 (VSync off).
Volumetric sizing
src/Features/VolumetricLighting.cpp
Use dynamic screen size for render dimensions instead of depth-texture dimensions.
Hooks: FXAA / IBLF disable
src/Hooks.cpp
Added BSImageSpace_Init_IBLF wrapper (disables IBLF) and installs detour in non‑VR; FXAA-off detour installed earlier.
Reflection/state changes
src/State.cpp, src/State.h, src/Deferred.cpp, src/Features/DynamicCubemaps.cpp
Added State::activeReflections; updated Reset/UpdateSharedData/reflection logic to use activeReflections and Util::IsInterior().
Interior detection util
src/Utils/Game.cpp, src/Utils/Game.h
Added Util::IsInterior() helper and declaration.
Plugin loader
src/XSEPlugin.cpp
Load() now returns true unconditionally (errors still collected; later init still gates on errors).
Occlusion/deferred adjustments
src/Features/Skylighting.cpp, src/Deferred.cpp
Replaced sky-mode checks with Util::IsInterior() in occlusion and deferred logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Loader
  participant Hooks
  participant FXAA_Init as BSImageSpace_Init_FXAA
  participant IBLF_Init as BSImageSpace_Init_IBLF

  Loader->>Hooks: Install detours (non‑VR)
  Hooks->>FXAA_Init: Detour FXAA init
  Hooks->>IBLF_Init: Detour IBLF init

  Note right of FXAA_Init: FXAA flag forced off, then call original
  Loader->>FXAA_Init: Initialize FXAA
  FXAA_Init-->>Loader: Forward to original

  Note right of IBLF_Init: IBLF flag forced false, then call original
  Loader->>IBLF_Init: Initialize IBLF
  IBLF_Init-->>Loader: Forward to original
Loading
sequenceDiagram
  autonumber
  participant RenderLoop
  participant Upscaling
  participant Streamline
  participant FFX as FidelityFX

  RenderLoop->>Upscaling: Upscale()
  Upscaling->>Streamline: Upscale(..., preset=K)
  Streamline-->>Upscaling: Upscaled frame

  alt FFX path active
    Upscaling->>FFX: DispatchUpscale(enableSharpening=true)
    FFX-->>Upscaling: Output
  end

  Note over Upscaling: NIS sharpening path removed
Loading
sequenceDiagram
  autonumber
  participant DXSwap as DX12SwapChain::Present
  participant Limiter as FrameLimiter

  DXSwap->>DXSwap: Present(SyncInterval)
  alt SyncInterval == 0 (VSync off)
    DXSwap->>Limiter: FrameLimiter()
  else VSync on
    Note over DXSwap: Skip limiter call
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • jiayev
  • alandtse

Poem

A rabbit hops where shaders slept,
NIS bids farewell, the pixels kept.
FXAA hushed, IBLF put to bed,
Preset K hums while frames are fed.
Carrots crunch — the render dreams ahead. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title "fix: misc fixes" is overly generic and does not communicate the primary intent of this changeset. The PR actually removes the NIS upscaling/sharpening pipeline (headers, shaders, config, and runtime API) and adds FXAA/IBLF hooks plus multiple reflection/state adjustments, so a reviewer cannot quickly grasp the main change from the current title. Because it uses non-descriptive wording like "misc fixes", the check is inconclusive. Please rename the PR to a concise, descriptive title that highlights the primary change (for example: "Remove NIS sharpening and config; add FXAA/IBLF hooks and reflection fixes"). If you prefer to emphasize a single main change, use "Remove NVIDIA Image Scaling (NIS) sharpening and runtime/config API" and update the PR description to list secondary changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dba634 and 54a584c.

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

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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: 1a52bc6
Using base ref: 1a52bc6
Base commit date: 2025-09-16T01:30:12+01:00 (Tuesday, September 16, 2025 01:30 AM)
No actionable suggestions for changed features.

pre-commit-ci Bot and others added 3 commits September 16, 2025 19:27
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 16, 2025

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

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

Caution

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

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

798-812: Leftover NIS sharpener allocation — dead resource and memory waste.

This creates nisSharpenerTexture but NIS paths were removed. It’s never used nor destroyed.

Apply:

- // Create NIS sharpener texture with swapchain format and UAV access
- D3D11_TEXTURE2D_DESC nisTexDesc = texDesc;
- nisTexDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- nisTexDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
-
- D3D11_SHADER_RESOURCE_VIEW_DESC nisSrvDesc = srvDesc;
- nisSrvDesc.Format = nisTexDesc.Format;
-
- D3D11_UNORDERED_ACCESS_VIEW_DESC nisUavDesc = uavDesc;
- nisUavDesc.Format = nisTexDesc.Format;
-
- nisSharpenerTexture = new Texture2D(nisTexDesc);
- nisSharpenerTexture->CreateSRV(nisSrvDesc);
- nisSharpenerTexture->CreateUAV(nisUavDesc);

Also remove the nisSharpenerTexture member from Upscaling.h to avoid drift.

🧹 Nitpick comments (10)
src/Features/VolumetricLighting.cpp (1)

202-206: Protect Min1 fields against underflow; keep them consistent with clamped dims.

If width/height ever hit 0, width - 1 underflows. After clamping to ≥1 above, reflect that here.

-	vlData.screenX = width;
-	vlData.screenY = height;
-	vlData.screenXMin1 = width - 1;
-	vlData.screenYMin1 = height - 1;
+	vlData.screenX = width;
+	vlData.screenY = height;
+	vlData.screenXMin1 = width  > 0 ? width  - 1 : 0;
+	vlData.screenYMin1 = height > 0 ? height - 1 : 0;
src/State.cpp (1)

129-134: Reflections shader deactivation looks fine; consider setting once instead of every Reset.

Setting BSImagespaceShaderApplyReflections->active = false each Reset() is harmless but redundant. If you want to avoid touching it every frame, gate it behind a one‑time apply (static flag) or move it to Setup() after verifying the instance is available.

src/Features/Upscaling/FidelityFX.cpp (1)

290-292: Enable sharpening only when nonzero and wire to a setting

Currently the pass runs with sharpness 0.0f (cost without effect). Gate by a user-configured sharpness and clamp.

-	dispatchUpscale.reset = false;
-	dispatchUpscale.enableSharpening = true;
-	dispatchUpscale.sharpness = 0.0f;
+	dispatchUpscale.reset = false;
+	// Drive CAS from settings; clamp to [0,1]
+	float sharpness = std::max(0.0f, std::min(1.0f, globals::features::upscaling.settings.casSharpness));
+	dispatchUpscale.enableSharpening = sharpness > 0.0f;
+	dispatchUpscale.sharpness = sharpness;
src/XSEPlugin.cpp (1)

205-205: Unconditional Load() success may mask hard dependency failures

Returning true even when required DLLs are missing changes prior behavior and can surprise loaders/diagnostics. Consider returning errors.empty() to fail fast, or explicitly document the new behavior.

-	return true;
+	return errors.empty();

Is the unconditional success intentional for UX (show message boxes but keep plugin loaded)?

src/Hooks.cpp (1)

808-824: Type-safe write to IBLF toggle

Write a float 0.0f using REL helpers to avoid raw casts and make intent explicit.

-			auto enableIBLF = (float*)(REL::RelocationID(513510, 391362).address());
-			*enableIBLF = false;
+			auto enableIBLF = REL::Relocation<float*>(REL::RelocationID(513510, 391362));
+			*enableIBLF = 0.0f;
src/Features/Upscaling/DX12SwapChain.cpp (1)

169-171: Also gate frame limiter on tearing flag (optional)

Helps avoid double pacing when some drivers/apps pass SyncInterval==0 without allowing tearing.

-	if (SyncInterval == 0)
+	if (SyncInterval == 0 && (Flags & DXGI_PRESENT_ALLOW_TEARING))
 		upscaling.FrameLimiter();
src/Features/Upscaling.h (3)

133-133: Remove dead NIS API surface

NIS was removed in this PR; keeping this declaration risks drift/confusion.

-	void ApplyNISSharpening();

139-140: Remove unused NIS texture member

Part of the NIS path; safe to drop with the rest.

-	Texture2D* nisSharpenerTexture = nullptr;

50-59: Add CAS sharpness setting to drive FFX sharpening

Needed by the FidelityFX change to avoid a no‑op sharpening pass. Default to a conservative value.

 	struct Settings
 	{
 		uint upscaleMethod = (uint)UpscaleMethod::kDLSS;
 		uint upscaleMethodNoDLSS = (uint)UpscaleMethod::kFSR;
 		uint qualityMode = 1;  // Default to Quality (1=Quality, 2=Balanced, 3=Performance, 4=Ultra Performance, 0=Native AA)
 		uint frameLimitMode = 1;
 		uint frameGenerationMode = 1;
 		uint frameGenerationForceEnable = 0;
 		uint streamlineLogLevel = 0;  // 0=Off, 1=Default, 2=Verbose
+		float casSharpness = 0.2f;    // 0..1 for FSR3 CAS
 	};

I can follow up with SaveSettings/LoadSettings JSON glue if you want.

src/Features/Upscaling.cpp (1)

167-169: Hard-coded “NVIDIA DLSS 4 Preset K” label is brittle.

Prefer building the label from runtime version info (like FSR/XeSS) and avoid baking “4” in UI.

Apply:

- std::string dlssLabel = "NVIDIA DLSS 4 Preset K";
+ std::string dlssLabel = "NVIDIA DLSS";
+ if (!streamline.versionInfo.empty()) {
+   dlssLabel += " " + streamline.versionInfo;
+ }
+ dlssLabel += " Preset K";
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a52bc6 and d44275f.

📒 Files selected for processing (13)
  • features/Upscaling/Shaders/Upscaling/NIS/NIS_Scaler.h (0 hunks)
  • features/Upscaling/Shaders/Upscaling/NIS/NIS_Sharpen.hlsl (0 hunks)
  • src/Features/Upscaling.cpp (5 hunks)
  • src/Features/Upscaling.h (1 hunks)
  • src/Features/Upscaling/DX12SwapChain.cpp (1 hunks)
  • src/Features/Upscaling/FidelityFX.cpp (1 hunks)
  • src/Features/Upscaling/NIS/NIS.cpp (0 hunks)
  • src/Features/Upscaling/NIS/NIS.h (0 hunks)
  • src/Features/Upscaling/NIS/NIS_Config.h (0 hunks)
  • src/Features/VolumetricLighting.cpp (1 hunks)
  • src/Hooks.cpp (2 hunks)
  • src/State.cpp (1 hunks)
  • src/XSEPlugin.cpp (1 hunks)
💤 Files with no reviewable changes (5)
  • src/Features/Upscaling/NIS/NIS.h
  • src/Features/Upscaling/NIS/NIS.cpp
  • features/Upscaling/Shaders/Upscaling/NIS/NIS_Scaler.h
  • features/Upscaling/Shaders/Upscaling/NIS/NIS_Sharpen.hlsl
  • src/Features/Upscaling/NIS/NIS_Config.h
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not include TODO/FIXME placeholders; provide complete, working solutions

Files:

  • src/Features/Upscaling/DX12SwapChain.cpp
  • src/Features/Upscaling/FidelityFX.cpp
  • src/Features/Upscaling.h
  • src/XSEPlugin.cpp
  • src/State.cpp
  • src/Features/VolumetricLighting.cpp
  • src/Hooks.cpp
  • src/Features/Upscaling.cpp
src/**/*.{cpp,cxx,cc,h,hpp,hxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{cpp,cxx,cc,h,hpp,hxx}: Ensure SE/AE/VR runtime compatibility; use runtime detection patterns (e.g., REL::RelocateMember())
Include robust error handling and resource management with graceful degradation in the plugin code

Files:

  • src/Features/Upscaling/DX12SwapChain.cpp
  • src/Features/Upscaling/FidelityFX.cpp
  • src/Features/Upscaling.h
  • src/XSEPlugin.cpp
  • src/State.cpp
  • src/Features/VolumetricLighting.cpp
  • src/Hooks.cpp
  • src/Features/Upscaling.cpp
🧠 Learnings (2)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.
📚 Learning: 2025-08-03T18:37:19.690Z
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.

Applied to files:

  • src/State.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (8)
src/Features/VolumetricLighting.cpp (1)

192-196: Round and clamp dynamic render size to avoid mismatch/underflow.

Truncation via static_cast can make the RT one texel too small (partial dispatch) and allow 0→-1 underflow; round then clamp to >=1. Shaders use integer sizes (cbuffer VLData in package/Shaders/ISVolumetricLightingBlurHCS.hlsl / ISVolumetricLightingBlurVCS.hlsl declare int2 screenSize and int2 screenSizeMin1). ConvertToDynamic and RT creation/resize weren't found by the repo search — verify the rounding strategy matches how RT/UAV/SRV extents are computed so vlData.screenSize equals the actual bound extents during VL passes.

File: src/Features/VolumetricLighting.cpp (around lines 192–196)

Apply this diff:

-	auto renderSize = Util::ConvertToDynamic(globals::state->screenSize);
-
-	int32_t width = static_cast<int32_t>(renderSize.x);
-	int32_t height = static_cast<int32_t>(renderSize.y);
+	auto renderSize = Util::ConvertToDynamic(globals::state->screenSize);
+	const int32_t width  = std::max<int32_t>(1, static_cast<int32_t>(std::lround(renderSize.x)));
+	const int32_t height = std::max<int32_t>(1, static_cast<int32_t>(std::lround(renderSize.y)));

Add the header once (outside this hunk):

#include <cmath>
src/State.cpp (1)

136-139: Guard GetINISetting nullptr and avoid per-frame INI stomping.

RE::GetINISetting("bEnableImprovedSnow:Display") can be nullptr (dereference crash); also avoid forcing the INI every Reset/frame — apply once.

-  // Disable "improved" snow shader, unsupported
-  if (!globals::game::isVR) {
-    RE::GetINISetting("bEnableImprovedSnow:Display")->data.b = false;
-  }
+  // Disable "Improved Snow" on non‑VR (unsupported). Guard against missing INI and apply once.
+  static bool improvedSnowForcedOff = false;
+  if (!globals::game::isVR && !improvedSnowForcedOff) {
+    if (auto* improvedSnow = RE::GetINISetting("bEnableImprovedSnow:Display"); improvedSnow) {
+      if (improvedSnow->GetBool()) {
+        improvedSnow->data.b = false;
+        logger::info("Forced bEnableImprovedSnow:Display = false.");
+      }
+    } else {
+      logger::warn("INI setting 'bEnableImprovedSnow:Display' not found; skipping.");
+    }
+    improvedSnowForcedOff = true; // avoid touching this every frame
+  }

src/State.cpp not found in the repository — confirm file path or apply the patch where this code lives.

src/Hooks.cpp (1)

840-844: Hook install guard LGTM

Non‑VR guard and detour placement look correct.

src/Features/Upscaling.h (2)

59-59: Streamline log level field LGTM

Field and comment are clear.


1-254: Verify repo for lingering NIS references

Automated regex scan returned no matches; manually confirm there are no stale NIS symbols/assets remaining.

  • Check src/Features/Upscaling.h for declarations/usages (e.g., ApplyNISSharpening(), nisSharpenerTexture).
  • Search repo for: NIS, NIS_Sharpen, NIS_Scaler, ApplyNISSharpening, nisSharpenerTexture, Upscaling/NIS.
  • Inspect shader/asset directories, CMake/project files, resource manifests and packaging/installer for leftover references.
src/Features/Upscaling.cpp (3)

1428-1430: Always forcing DLSS Preset K — add fallback for older Streamline/GPUs.

If Preset K isn’t supported everywhere you target, consider a runtime fallback to F (or default) to avoid hard failures or quality regressions.

Would you like a small helper in Streamline to probe preset support and fall back automatically?


13-21: Confirm no stale NIS references remain after WITH_DEFAULT change.

Sandbox search failed (ripgrep: "No files were searched"). Run locally: rg -n -C2 -S --hidden -uu -g '!/build/' 'enableNISSharpening|nisSharpness|ApplyNISSharpening|NIS' and confirm zero hits. Check src/Features/Upscaling.cpp (lines 13–21) mapping; if any hits exist, remove or update those references and related config keys.


394-396: Verify RelocationIDs and thunk target for SSE/AE

Detour placement OK — I couldn't find src/Features/Upscaling.cpp in this branch and searches returned no matches for REL::RelocationID(98974|105626) or stl::detour_thunk (there is a features/Upscaling directory). Confirm the actual file path and that the detour target (BSImageSpace_Init_FXAA) and FXAA flag relocation IDs (98974, 105626) are correct for both SSE and AE (provide per-runtime IDs if they differ).

Comment thread src/Features/Upscaling.cpp 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: 2

🧹 Nitpick comments (2)
src/Utils/Game.h (1)

171-172: Clarify IsInterior() semantics in the header.

Add a brief comment that this returns true for interior cells and for exteriors with NoSky worldspaces, false otherwise, so downstream users don’t misread it as “strict interior only.”

Apply this diff:

-	bool IsInterior();
+	// True for interior cells or exteriors whose worldspace has NoSky; false for skyed exteriors.
+	bool IsInterior();
src/Features/Skylighting.cpp (1)

498-499: Switch to Util::IsInterior()—align Prepass() gating for consistency.

Good change. Prepass() (Lines 213–219) still uses sky->mode-based detection; please update it to Util::IsInterior() to avoid mismatches on NoSky exteriors.

Suggested update for Prepass():

bool interior = Util::IsInterior();
if (interior)
    return;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d44275f and 7cd62dc.

📒 Files selected for processing (7)
  • src/Deferred.cpp (2 hunks)
  • src/Features/DynamicCubemaps.cpp (1 hunks)
  • src/Features/Skylighting.cpp (1 hunks)
  • src/State.cpp (2 hunks)
  • src/State.h (1 hunks)
  • src/Utils/Game.cpp (1 hunks)
  • src/Utils/Game.h (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not include TODO/FIXME placeholders; provide complete, working solutions

Files:

  • src/State.h
  • src/Utils/Game.cpp
  • src/Utils/Game.h
  • src/Features/Skylighting.cpp
  • src/Deferred.cpp
  • src/State.cpp
  • src/Features/DynamicCubemaps.cpp
src/**/*.{cpp,cxx,cc,h,hpp,hxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{cpp,cxx,cc,h,hpp,hxx}: Ensure SE/AE/VR runtime compatibility; use runtime detection patterns (e.g., REL::RelocateMember())
Include robust error handling and resource management with graceful degradation in the plugin code

Files:

  • src/State.h
  • src/Utils/Game.cpp
  • src/Utils/Game.h
  • src/Features/Skylighting.cpp
  • src/Deferred.cpp
  • src/State.cpp
  • src/Features/DynamicCubemaps.cpp
🧠 Learnings (1)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (7)
src/Deferred.cpp (2)

414-414: LGTM: unified interior check via Util::IsInterior().

This simplifies and de-duplicates interior logic across passes.


234-238: activeReflections set during reflections prepass — confirm Reset() is called once per frame

Repository scan found no src/Deferred.cpp or any State::Reset (or equivalent) references; cannot verify Reset() runs after the cubemap render path. Ensure State::Reset() (or an explicit per-frame clear) runs once per frame after cubemap rendering to clear activeReflections, or explicitly set activeReflections = false at frame end.

src/State.cpp (3)

136-140: LGTM: disable unsupported improved snow via INI.

Matches the feature set and prevents unintended shader paths.


141-142: LGTM: reset activeReflections on frame reset.

Keeps reflection sequencing bounded to the frame.


130-134: Confirm BSImagespaceShaderApplyReflections member type before calling .get().
src/State.cpp:130-134
Repository search returned no matches; ensure the member is a smart pointer that exposes .get() (std::shared_ptr/std::unique_ptr). If it's a NiPointer or a raw pointer, use an appropriate null-check (if (ptr) / ptr != nullptr) and avoid calling .get().

src/State.h (1)

167-168: Confirm State::Reset() runs once per frame (prevent activeReflections leaking).

activeReflections is set true in ReflectionsPrepasses and cleared in State::Reset(); ensure Reset() is invoked exactly once per frame so the flag cannot persist across frames — if not guaranteed, clear activeReflections at end-of-frame or make it frame-local.
Location: src/State.h:167-168.

src/Utils/Game.cpp (1)

303-314: IsInterior() logic LGTM — verify VR runtime accessor

Uses tes->GetRuntimeData2() for worldSpace. src/Utils/Game.cpp (lines 303–314) not present in this branch; confirm VR builds don't require an alternate accessor (e.g., GetVRRuntimeData2) or VR-specific build flags. Quick local check: rg -n -S 'GetVRRuntimeData2|GetRuntimeData2|SKYRIMVR|VR_BUILD' -C2

Comment thread src/Features/DynamicCubemaps.cpp
Comment thread src/State.cpp
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

♻️ Duplicate comments (1)
src/Features/DynamicCubemaps.cpp (1)

651-655: Avoid TOCTOU on globals::game::sky; compute once.

Grab the pointer into a local before checking flags to remove the double read and narrow the race window. Also simplifies the flow.

Apply:

-	if (globals::game::sky)
-		fakeReflections = activeReflections && globals::game::sky->flags.any(RE::Sky::Flags::kHideSky);
-	else
-		fakeReflections = false;
+	const auto sky = globals::game::sky;
+	const bool hideSky = sky && sky->flags.any(RE::Sky::Flags::kHideSky);

…and then fold assignment as below (see next comment).

🧹 Nitpick comments (2)
src/Features/DynamicCubemaps.cpp (2)

656-659: Fold branches to a single, brace-safe block.

Combine the fallback and fakeReflections computation; add braces to avoid future slip-ups.

-	if (!activeReflections && !Util::IsInterior()) {
-		activeReflections = true;
-		fakeReflections = true;
-	}
+	if (!activeReflections && !Util::IsInterior()) {
+		activeReflections = true;
+		fakeReflections = true;
+	} else {
+		fakeReflections = activeReflections && hideSky;
+	}

656-659: Confirm perf intent of forced exterior fallback.

Forcing reflections on exteriors even when state says “off” could add work on low-end/VR. If intentional, consider a toggle (e.g., “ExteriorFakeReflectionsFallback”) or log once to aid profiling.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cd62dc and 8dba634.

📒 Files selected for processing (2)
  • src/Features/DynamicCubemaps.cpp (1 hunks)
  • src/State.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/State.cpp
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Do not include TODO/FIXME placeholders; provide complete, working solutions

Files:

  • src/Features/DynamicCubemaps.cpp
src/**/*.{cpp,cxx,cc,h,hpp,hxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{cpp,cxx,cc,h,hpp,hxx}: Ensure SE/AE/VR runtime compatibility; use runtime detection patterns (e.g., REL::RelocateMember())
Include robust error handling and resource management with graceful degradation in the plugin code

Files:

  • src/Features/DynamicCubemaps.cpp
🧠 Learnings (1)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (1)
src/Features/DynamicCubemaps.cpp (1)

649-659: Null-deref fixed; logic reads clearer.

The added sky null-check prevents early-frame crashes and the exterior fallback keeps reflections alive when the dedicated pass didn’t run.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@doodlum doodlum merged commit 28c1112 into dev Sep 17, 2025
12 of 13 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jan 22, 2026
10 tasks
@alandtse alandtse deleted the upscaling-fixes branch February 6, 2026 05:20
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.

1 participant