Graphics: acquire D3D12 back buffer per-present (resize/F-11 fix)#218
Conversation
|
Warning Review limit reached
More reviews will be available in 34 minutes and 45 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe D3D12 backend now acquires the swapchain back buffer each frame, creates the RTV during ChangesD3D12 back-buffer lifecycle
Sequence Diagram(s)sequenceDiagram
participant D3D12Backend
participant IDXGISwapChain3
participant FrameContext
D3D12Backend->>FrameContext: assign reserved main render target descriptor in Init()
D3D12Backend->>IDXGISwapChain3: GetCurrentBackBufferIndex()
D3D12Backend->>IDXGISwapChain3: GetBuffer(index, _currentBackBuffer)
D3D12Backend->>D3D12Backend: CreateRenderTargetView(_currentBackBuffer, frameContext._mainRenderTargetDescriptor)
D3D12Backend->>D3D12Backend: transition _currentBackBuffer for rendering
D3D12Backend->>D3D12Backend: transition _currentBackBuffer for present
D3D12Backend->>D3D12Backend: release _currentBackBuffer in End()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@code/framework/src/graphics/backend/d3d12.h`:
- Around line 62-64: `SetSwapChain` currently only replaces `_swapChain` and
leaves the frame-state derived from `Init()` stale. Update the
`D3D12Backend::SetSwapChain` flow to rebuild swapchain-dependent state when a
new `IDXGISwapChain3` is assigned: refresh `_frameBufferCount`,
resize/reinitialize `_frameContext`, and ensure any RTV/descriptor resources
tied to the old buffer count are recreated or validated before `Begin()` uses
them.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 23cdfd0f-e3a7-4d96-9bc6-0b6e0500af19
📒 Files selected for processing (2)
code/framework/src/graphics/backend/d3d12.cppcode/framework/src/graphics/backend/d3d12.h
The backend cached the swapchain back buffers for the process lifetime, so the game's ResizeBuffers failed (DXGI_ERROR_INVALID_CALL) and UE4 crashed on any fullscreen/resolution change. Acquire the back buffer fresh in Begin() and release it in End() so no reference is held across frames.
This issue predated my work on the d3d12 view. When
Initis called, the back buffers were cached, but these are usually recreated whenever the window is resized--making references to them invalid.The backend cached the swapchain back buffers for the process lifetime, so the game's ResizeBuffers failed (DXGI_ERROR_INVALID_CALL) and UE4 crashed on any fullscreen/resolution change. Acquire the back buffer fresh in Begin() and release it in End() so no reference is held across frames.
Summary by CodeRabbit
Bug Fixes
New Features