Skip to content

chore(upscaling): improve upscaling for xess and fsr#1466

Merged
doodlum merged 5 commits into
devfrom
upscaling-improvements
Sep 12, 2025
Merged

chore(upscaling): improve upscaling for xess and fsr#1466
doodlum merged 5 commits into
devfrom
upscaling-improvements

Conversation

@doodlum
Copy link
Copy Markdown
Collaborator

@doodlum doodlum commented Sep 12, 2025

Summary by CodeRabbit

  • New Features

    • Depth-aware 5x5 neighborhood analysis for motion-vector selection when using DLSS/XeSS, improving motion clarity and reducing ghosting.
    • Refined reactive mask computation per upscaler path for more stable anti-aliasing and transparency handling.
  • Chores

    • Reduced log verbosity by moving shared resource update messages to debug level.
    • Updated default NIS sharpness from 0.30 to 0.15 for a more balanced sharpening out of the box.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 12, 2025

Walkthrough

Implements depth-driven 5x5 neighborhood analysis in EncodeTexturesCS.hlsl to select motion vectors for DLSS/XESS, adjusts reactive/transparency mask computation branches, lowers logging verbosity in Upscaling shared-resource updates, removes D3D11 shared misc flags in interop paths, and changes the default NIS sharpness from 0.3 to 0.15.

Changes

Cohort / File(s) Summary
Shader neighborhood and mask logic
features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl
Replaces reactiveMask-first path with depth-gated 5x5 neighbor scan; selects longest motion vector for DLSS/XESS; clamps TAA across closer neighbors; updates MotionVectorOutput only for DLSS/XESS; adjusts reactive/transparency mask formulas per macro path.
Interop and logging adjustments (DX12/D3D11)
src/Features/Upscaling.cpp, src/Features/Upscaling/DX12SwapChain.cpp
Moves two Upscaling shared-resource logs from info to debug; removes D3D11 shared resource MiscFlags (and explicit Usage/CPUAccessFlags in swapchain interop), altering cross-API sharing setup without changing signatures.
Default setting tweak
src/Features/Upscaling.h
Changes Upscaling::Settings::nisSharpness default from 0.3f to 0.15f; no interface or logic changes otherwise.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CS as EncodeTexturesCS.hlsl
  participant TAAM as TAAMask
  participant Depth as DepthMask
  participant MV as MotionVectorMask
  participant Out as MotionVectorOutput

  CS->>Depth: Load depth at dispatchID.xy
  CS->>CS: For neighbors in 5x5 window
  alt neighbor is closer (neighborDepth < depth)
    CS->>TAAM: Clamp taaMask.x with neighbor TAAMask.x
    opt DLSS/XESS enabled
      CS->>MV: Compare neighbor motion length^2
      CS->>CS: Track longestMotionVector
    end
  end
  opt DLSS/XESS enabled
    CS->>Out: Write longestMotionVector
  end
  CS->>CS: Compute reactive/transparency masks per macro path (DLSS/FSR vs other)
Loading
sequenceDiagram
  autonumber
  participant Ups as Upscaling::UpdateSharedResources
  participant Log as Logger
  participant D3D11 as D3D11 Tex Desc
  participant D3D12 as D3D12 Shared

  Ups->>Log: debug("Updating shared D3D12 resources")
  Ups->>D3D11: Create desc (no explicit MISC_SHARED/NTHANDLE)
  Ups->>D3D12: Proceed with interop setup
  Ups->>Log: debug("Shared resource update complete ...")
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • jiayev
  • alandtse

Poem

I sniff the pixels, hop through depth and light,
A 5×5 meadow where motions take flight.
I twitch my whiskers—logs now whisper, not shout,
Shared flags trimmed, less clatter about.
With softer sharpness, I gently preen—
Upscaled horizons, silky and clean. 🐇✨

Pre-merge checks (2 passed, 1 warning)

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 concisely and accurately captures the primary intent of the changeset—improvements to upscaling behavior for XESS and FSR—matching the shader and upscaling modifications in the diff. It is short, focused, and free of noise or irrelevant detail. Minor unrelated edits (logging level, texture sharing flag, default nisSharpness) do not make the title misleading.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch upscaling-improvements

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.

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@github-actions
Copy link
Copy Markdown

Using provided base ref: 7b5e74e
Using base ref: 7b5e74e
Base commit date: 2025-09-12T14:03:37+01:00 (Friday, September 12, 2025 02:03 PM)
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: 1

Caution

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

⚠️ Outside diff range comments (1)
features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl (1)

29-36: Out-of-bounds texture reads at screen edges — clamp samplePos.

The 5x5 neighborhood uses raw integer indexing without bounds checks. This can read outside the texture on borders, causing undefined data and GPU debug warnings. Clamp to texture dimensions before sampling.

Apply:

-	[unroll]
-	for (int y = -2; y <= 2; y++) {
+	uint width, height;
+	DepthMask.GetDimensions(width, height);
+	int2 maxCoord = int2(int(width) - 1, int(height) - 1);
+	[unroll]
+	for (int y = -2; y <= 2; y++) {
 		[unroll]
 		for (int x = -2; x <= 2; x++) {
-			int2 samplePos = int2(dispatchID.xy) + int2(x, y);
+			int2 samplePos = int2(dispatchID.xy) + int2(x, y);
+			samplePos = clamp(samplePos, int2(0, 0), maxCoord);
🧹 Nitpick comments (1)
features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl (1)

22-27: Minor: precompute and reuse motion length to save a dot().

Cheap, but inside a 25-sample loop across all pixels. Cache initial length once (you already do) and keep neighbor path as-is—good. No action required unless profiling shows hotspot.

📜 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 7b5e74e and b6b0da7.

📒 Files selected for processing (4)
  • features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl (3 hunks)
  • src/Features/Upscaling.cpp (2 hunks)
  • src/Features/Upscaling.h (1 hunks)
  • src/Features/Upscaling/DX12SwapChain.cpp (0 hunks)
💤 Files with no reviewable changes (1)
  • src/Features/Upscaling/DX12SwapChain.cpp
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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.h
  • src/Features/Upscaling.cpp
  • features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl
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.h
  • src/Features/Upscaling.cpp
features/*/Shaders/**/*.{hlsl,hlsli,fx,fxh}

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

features/*/Shaders/**/*.{hlsl,hlsli,fx,fxh}: Place all feature shaders under features/YourFeature/Shaders/
Avoid GPU register/buffer conflicts in HLSL; verify register usage (e.g., with hlslkit buffer scanning)

Files:

  • features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl
🧠 Learnings (2)
📓 Common learnings
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:

  • features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.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). (3)
  • GitHub Check: Build plugin and addons
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
🔇 Additional comments (2)
src/Features/Upscaling.h (1)

60-61: Default NIS sharpness lowered — sensible to reduce oversharpening by default.

No functional risks. Confirm release notes/UI text reflect the new 0.15 default.

src/Features/Upscaling.cpp (1)

959-959: Lowering verbosity to debug is appropriate here.

Good for noise reduction during normal play; retains detail when needed.

Also applies to: 1081-1083

Comment thread features/Upscaling/Shaders/Upscaling/EncodeTexturesCS.hlsl
@github-actions
Copy link
Copy Markdown

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

@doodlum doodlum changed the title chore: improve upscaling for xess and fsr chore(upscaling): improve upscaling for xess and fsr Sep 12, 2025
@doodlum doodlum merged commit 1c3377e into dev Sep 12, 2025
19 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Feb 6, 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.

1 participant