Skip to content

RR runtime: retain checks for ID3D12GraphicsCommandList2 before it records anything - #80

Merged
phantoslayer21 merged 1 commit into
mainfrom
fix/65-retain-list2-first
Nov 13, 2026
Merged

phantoslayer21 merged 1 commit into
mainfrom
fix/65-retain-list2-first

Conversation

@phantoslayer21

Copy link
Copy Markdown
Owner

Fixes #65

What was wrong

retain_locked (clean/rr_f/runtime/src/rr_runtime.cpp) created the transient copy resource and recorded CopyResource / CopyTextureRegion plus barriers into the game's command list. Only after that did it query the list for ID3D12GraphicsCommandList2, which it needs for the completion marker. If that query failed, the marker write and the rt.serial increment were skipped, but the function still returned WG_OK. A later release_transient_locked then called defer_release(r, rt.serial), which could free the copy at once while the recorded copy was still pending on the list. Evaluate already refuses a list without List2; retain did not.

It is very rare: D3D12 runtime lists have answered the List2 query since Windows 10 1703. Only a wrapper layer exposing just the base interfaces would hit it.

The fix

The List2 query moves to the top of retain_locked. If it fails, the function returns WG_E_INVALID_PARAMETER before creating or recording anything (and releases the list reference it holds). The marker write itself is unchanged, and the copy-creation failure path now releases the List2 reference too. No other change.

The test

None added, and none can fail on the CPU today. The defect needs a command list that refuses IID_ID3D12GraphicsCommandList2 handed to the RR runtime, and set_device requires an RDNA 4 adapter (rr_runtime.cpp, rdna4_adapter), so the retain path cannot be reached on WARP or with a stub. The issue itself says a code check is enough for this reorder without a test seam, and adding that seam is a larger change than this fix.

Code check: the query is the first thing after the base list query; the failure return of the query releases the base list; the copy-creation failure return releases both references; the success path releases both at the end.

Tested

  • cl /Zs /EHsc /std:c++17 /W3 over rr_runtime.cpp (MSVC): no errors; the only warnings are the existing _wfopen / getenv deprecation ones.
  • Repository gates (secrets, personal data, licence, view layout): pass.

Not tested

  • No test for the changed behaviour (see above); nothing run on a GPU or in a game.
  • The full runtime build (kernels, DXC) and the RR test host were not run; they need the GPU toolchain and a Radeon RX 9000 card.

…cords anything

retain_locked created the transient copy and recorded the copy and its barriers
into the game's list, and only then asked the list for
ID3D12GraphicsCommandList2, which the completion marker needs. If the query
failed, the marker and the serial increment were skipped, retain still
returned WG_OK, and a later release could free the copy while its recorded
copy was still pending on the list. The query now comes first; a list without
List2 gets WG_E_INVALID_PARAMETER before anything is created or recorded, as
evaluate already refuses such a list.

Fixes #65

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 13, 2026 20:53
@phantoslayer21
phantoslayer21 merged commit b8a1042 into main Nov 13, 2026
2 checks passed
@phantoslayer21
phantoslayer21 deleted the fix/65-retain-list2-first branch November 13, 2026 21:02
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.

RR retain records a copy before it checks for ID3D12GraphicsCommandList2

1 participant