Skip to content

fix(HDR): background blur with HDR#2274

Merged
doodlum merged 5 commits into
community-shaders:devfrom
Dlizzio:hdr-background-blur
May 5, 2026
Merged

fix(HDR): background blur with HDR#2274
doodlum merged 5 commits into
community-shaders:devfrom
Dlizzio:hdr-background-blur

Conversation

@Dlizzio
Copy link
Copy Markdown
Contributor

@Dlizzio Dlizzio commented May 4, 2026

Fixes instances of background blur with HDR.

Matrix:
HDR Display loaded, Upscaling disabled, HDR toggle disabled: works.
HDR Display loaded, Upscaling disabled, HDR toggle enabled: works.
HDR Display loaded, Upscaling enabled, Frame Gen disabled, HDR toggle disabled: works.
HDR Display loaded, Upscaling enabled, Frame Gen enabled, HDR toggle disabled: works.
HDR Display loaded, Upscaling enabled, Frame Gen disabled, HDR toggle enabled: works.
HDR Display loaded, Upscaling enabled, Frame Gen enabled, HDR toggle enabled: works.
HDR Display unloaded, Upscaling disabled: works.
HDR Display unloaded, Upscaling enabled, Frame Gen disabled: works.
HDR Display unloaded, Upscaling enabled, Frame Gen enabled: works.

Summary by CodeRabbit

  • Bug Fixes

    • Preserve visual resources during HDR render-target upgrades to avoid display glitches
    • More reliable per-frame detection of frame-generation to prevent inconsistent compositing
    • Improved menu/state detection for correct UI visibility
  • Improvements

    • Smarter selection of D3D12 UI rendering path for better HDR/UI fidelity and fallback handling
    • Better integration of background blur with HDR and frame-generation scenarios
  • Chores

    • Updated shader feature versions for HDR and Upscaling configurations

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 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 Plus

Run ID: 64744a44-c9cd-4913-8000-95e5965128a4

📥 Commits

Reviewing files that changed from the base of the PR and between 6b32b5c and 2e1097a.

📒 Files selected for processing (1)
  • src/Menu/BackgroundBlur.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Menu/BackgroundBlur.cpp

📝 Walkthrough

Walkthrough

Centralizes per-frame FG gating via Upscaling::ShouldUseFrameGenerationThisFrame(), introduces D3D12 UI-buffer mode computation in HDRDisplay to route UI (or fallback copy), preserves UAVs when upgrading LDR→HDR targets, refactors BackgroundBlur to use unified UI-buffer helpers, adds State menu-open queries, and bumps two shader feature versions.

Changes

Frame‑Generation, UI Buffer Routing, and Render‑Target UAV Preservation

Layer / File(s) Summary
Data Shape
src/Features/HDRDisplay.h
HDRDataCB::SavedRenderTarget adds ID3D11UnorderedAccessView* UAV to persist UAVs across upgrades.
Frame‑Generation Core
src/Features/Upscaling.h, src/Features/Upscaling.cpp
Adds Upscaling::ShouldUseFrameGenerationThisFrame() and uses it to scale frame-limiter timing and gate DX12 FG shared-resource paths.
UI‑Buffer Mode Computation
src/Features/HDRDisplay.h, src/Features/HDRDisplay.cpp
Adds D3D12UIBufferMode, GetD3D12UIBufferMode() and ShouldUseD3D12UIBuffer() to derive useUIBuffer / useFallbackCopy from HDR readiness and FG compositing.
SetUIBuffer / RTV Selection
src/Features/HDRDisplay.cpp
SetUIBuffer() D3D12 path now uses GetD3D12UIBufferMode(); early-exits if requested UI buffer unavailable; selects target RTV among wrapped UI buffer, fallback framebuffer copy, or wrapped back-buffer.
LDR→HDR Upgrade / Restore
src/Features/HDRDisplay.cpp
UpgradeLDRRenderTargets() saves existing rt.UAV, creates matching UAVs for upgraded R16G16B16A16_FLOAT textures and assigns them; RestoreLDRRenderTargets() releases and restores UAVs.
Blur Integration & UI Buffer Helpers
src/Menu/BackgroundBlur.cpp
Adds UIBufferViews and helpers (GetHDRUIBufferViews, GetD3D12UIBufferViews, ShouldSkipStartupMenuBlur, etc.), refactors RenderBackgroundBlur() to use uiBuffer and pass uiBuffer.srv/uiBuffer.rtv to blur calls.
DX12 Present Integration
src/Features/Upscaling/DX12SwapChain.cpp
DX12SwapChain::Present now forwards upscaling.ShouldUseFrameGenerationThisFrame() to fidelityFX.Present(...) instead of the previous inline condition.
State Helpers
src/State.h
Adds State::IsMainOrLoadingMenuOpen() and State::IsMainOrLoadingMenuOpen(RE::UI* ui) overloads combining cached flags with dynamic UI queries.
Metadata
features/HDR Display/Shaders/Features/HDRDisplay.ini, features/Upscaling/Shaders/Features/Upscaling.ini
Bump feature shader metadata versions: HDRDisplay 1-0-0 → 1-0-1, Upscaling 1-3-0 → 1-3-1.

Sequence Diagram

sequenceDiagram
    participant DX12 as DX12SwapChain
    participant Upscaling as Upscaling
    participant HDR as HDRDisplay
    participant Blur as BackgroundBlur
    participant UI as UI/Renderer

    DX12->>Upscaling: ShouldUseFrameGenerationThisFrame()
    Upscaling-->>DX12: FG allowed? (yes/no)
    DX12->>HDR: SetUIBuffer()
    HDR->>HDR: GetD3D12UIBufferMode()
    HDR-->>HDR: mode {useUIBuffer, useFallbackCopy}
    HDR->>UI: select RTV (uiBuffer / fallbackCopy / backBuffer)
    Blur->>HDR: Get*UIBufferViews(...)
    HDR-->>Blur: return {srv, rtv}
    Blur->>UI: PerformBlur(srv, rtv)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

Suggested Reviewers

  • doodlum
  • alandtse
  • jiayev

Poem

🐇 Hopping frames through moonlit code,

FG doors open on the road,
UAVs snug in leafy keeps,
UI routed while the world sleeps,
Blur and menus dream in gentle loads.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.45% 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(HDR): background blur with HDR' clearly describes the main problem being addressed—fixing background blur issues in HDR scenarios. It aligns well with the core changeset focus on HDR/background blur interactions across multiple feature modules.
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 unit tests (beta)
  • Create PR with unit tests

Review rate limit: 8/10 reviews remaining, refill in 8 minutes and 29 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

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

🤖 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/Menu/BackgroundBlur.cpp`:
- Around line 113-117: The null-HDR branch in ShouldUseD3D12UIBufferForBlur
incorrectly only checks !ui->GameIsPaused(), causing divergence from
HDRDisplay::SetUIBuffer's routing into uiBufferWrapped; update
ShouldUseD3D12UIBufferForBlur so when hdr is null it also verifies the same
D3D12 UI-buffer decision used by SetUIBuffer (i.e., consult
HDRDisplay::ShouldUseD3D12UIBuffer via the global HDRDisplay instance instead of
only !ui->GameIsPaused()), referencing ShouldUseD3D12UIBufferForBlur,
HDRDisplay::ShouldUseD3D12UIBuffer, HDRDisplay::SetUIBuffer, globals::game::ui
and uiBufferWrapped to locate where to change the condition.
🪄 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 Plus

Run ID: b80f523d-d088-4c80-badf-06bc85e321d9

📥 Commits

Reviewing files that changed from the base of the PR and between d919016 and 599911f.

📒 Files selected for processing (7)
  • src/Features/HDRDisplay.cpp
  • src/Features/HDRDisplay.h
  • src/Features/Upscaling.cpp
  • src/Features/Upscaling.h
  • src/Features/Upscaling/DX12SwapChain.cpp
  • src/Menu/BackgroundBlur.cpp
  • src/State.h

Comment thread src/Menu/BackgroundBlur.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

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

Copy link
Copy Markdown
Collaborator

@SkrubbySkrubInAShrub SkrubbySkrubInAShrub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in all combos on my side too.

@doodlum doodlum merged commit 3874151 into community-shaders:dev May 5, 2026
13 checks passed
@Dlizzio Dlizzio deleted the hdr-background-blur branch May 5, 2026 22:34
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