Add DX12 hooked capture via a D3D11On12 bridge
D3D12 games (e.g. Spider-Man: Miles Morales) fire the Present hook -- the DXGI
swapchain's Present is the same vtable function for D3D11 and D3D12 -- but
GetBuffer(0) as ID3D11Texture2D fails, so the hook used to idle. Now, when the D3D11
GetBuffer fails, present_hook bridges via D3D11On12: it gets the game's ID3D12Device
from the backbuffer, creates its own DIRECT command queue on it (no need to hook the
game's ExecuteCommandLists), builds an ID3D11On12Device, CreateWrappedResource's the
D3D12 backbuffer, and CopyResource's it into the existing shared keyed-mutex texture
-- so the host side is unchanged. The bridge is created lazily and torn down with the
hook.
Verified with a new in-process dx12_present_hook_test: it drives a real D3D12
swapchain (clears a backbuffer, Presents) and asserts present fired, the backbuffer
was bridged into the shared texture, and a second device reads the exact color back
by name -- {51,102,153,255}. Full build x64 + x86 clean (the x86 hook compiles the
D3D12 path too); ctest x64 10/10, x86 3/3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,27 @@ target_link_libraries(present_hook_test PRIVATE
|
||||
|
||||
add_test(NAME present_hook_test COMMAND present_hook_test)
|
||||
|
||||
# In-process self-test for the D3D12 path of the Present hook: drives a real D3D12
|
||||
# swapchain through the (shared) IDXGISwapChain::Present vtable and verifies the
|
||||
# D3D11On12 bridge copies the D3D12 backbuffer into the shared texture. Skips on a
|
||||
# machine without a D3D12 device.
|
||||
add_executable(dx12_present_hook_test
|
||||
dx12_present_hook_test.cpp
|
||||
${CMAKE_SOURCE_DIR}/hook/src/present_hook.cpp
|
||||
${CMAKE_SOURCE_DIR}/hook/src/debug_log.cpp
|
||||
${CMAKE_SOURCE_DIR}/hook/src/hook_registry.cpp)
|
||||
|
||||
target_include_directories(dx12_present_hook_test PRIVATE ${CMAKE_SOURCE_DIR}/hook/src)
|
||||
|
||||
target_link_libraries(dx12_present_hook_test PRIVATE
|
||||
coop_common
|
||||
safetyhook::safetyhook
|
||||
d3d11
|
||||
d3d12
|
||||
dxgi)
|
||||
|
||||
add_test(NAME dx12_present_hook_test COMMAND dx12_present_hook_test)
|
||||
|
||||
# In-process self-test for the OpenGL capture path. Reuses the shipping
|
||||
# opengl_hook.cpp and drives a real OpenGL context in the same process, so it
|
||||
# exercises the SwapBuffers hook, the glReadPixels readback, and the upload into
|
||||
@@ -131,4 +152,5 @@ coop_output_subdir(tests
|
||||
audio_hook_test
|
||||
srgb_format_test
|
||||
present_hook_test
|
||||
dx12_present_hook_test
|
||||
opengl_hook_test)
|
||||
|
||||
Reference in New Issue
Block a user