Repository navigation
RR runtime: retain checks for ID3D12GraphicsCommandList2 before it records anything - #80
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65
What was wrong
retain_locked(clean/rr_f/runtime/src/rr_runtime.cpp) created the transient copy resource and recordedCopyResource/CopyTextureRegionplus barriers into the game's command list. Only after that did it query the list forID3D12GraphicsCommandList2, which it needs for the completion marker. If that query failed, the marker write and thert.serialincrement were skipped, but the function still returnedWG_OK. A laterrelease_transient_lockedthen calleddefer_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 returnsWG_E_INVALID_PARAMETERbefore 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_ID3D12GraphicsCommandList2handed to the RR runtime, andset_devicerequires 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 /W3overrr_runtime.cpp(MSVC): no errors; the only warnings are the existing_wfopen/getenvdeprecation ones.Not tested