chore(upscaling): improve upscaling for xess and fsr#1466
Conversation
WalkthroughImplements 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
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)
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 ...")
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate 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. Comment |
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
There was a problem hiding this comment.
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
📒 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.hsrc/Features/Upscaling.cppfeatures/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.hsrc/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
|
✅ A pre-release build is available for this PR: |
Summary by CodeRabbit
New Features
Chores