Choose command queue associated to swap chain in DirectX 12 hook - #209
Merged
Merged
Conversation
Create a builder-like data structure that has to have a IDXGISwapChain set first, and a ID3D12CommandQueue set later, provided it is associated with the previously-set swap chain. The heuristic used is to check the first 512 pointers in the memory pointed to by the swap chain, dereference each of them, and see if any of them matches the command queue that gets passed in. In practice, the command queue is among the first few pointers. A bit of extra care is given in checking for memory readability with VirtualQuery before dereferencing. There is some overhead but it is probably negligible, and only happens the first time the methods are hooked, so it's way less than a frame in total. Some concern might be raised by the fact that now we need to lock a mutex twice per frame, but practically that will happen almost always on the same thread and parking_lot has good performance for that case. Besides, we already do that successfully with the Pipeline.
veeenu
force-pushed
the
dx12-command-queue-vtable
branch
from
October 30, 2024 08:59
bdd5b03 to
55700fd
Compare
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.
This PR changes the selection mechanism for the command queue. Whenever a command queue is detected via the
ExecuteCommandListshook, the command queue pointer is matched against the memory next to the swap chain. The assumption is that the swap chain will hold a reference to the command queue it uses. This is predicated on the fact thatCreateSwapChainForHwndaccepts a command queue in DirectX 12.A state machine enum implements the requisite logic.
Closes #203.