Phase 2: Present-hook video path (shared-texture mirror)
Add an injected IDXGISwapChain::Present / Present1 hook as a lower-latency, border-free alternative to WGC. The hook copies the swapchain backbuffer into a shared keyed-mutex texture (coop_video_<pid>); the host opens it by name and samples it. New opt-in HookSubsys_Video (protocol v6 -> v7); the Video mirror panel gains a WGC vs Hooked source toggle that installs/removes the subsystem. Verified by present_hook_test (drives a real D3D11 swapchain end-to-end and reads the rendered pixels back through the shared texture) and against Phantom Brave (D3D9: hook installs cleanly and stays idle, WGC fallback). All 5 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
35
hook/src/present_hook.hpp
Normal file
35
hook/src/present_hook.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Injected Present-hook video path: hooks IDXGISwapChain::Present in the target
|
||||
// game, copies the swapchain backbuffer into a shared keyed-mutex texture
|
||||
// (coop_video_<pid>), and publishes its dimensions/format to the host over IPC.
|
||||
// The host opens that texture by name and samples it -- a lower-latency, more
|
||||
// stable alternative to Windows Graphics Capture (which composites off the
|
||||
// desktop and can stutter / show a capture border).
|
||||
//
|
||||
// Only DXGI swapchains (D3D10/11/12-backed games) are caught; the backbuffer
|
||||
// must be an ID3D11Texture2D (the common D3D11 case). Games on D3D9 or a pure
|
||||
// D3D12 resource path won't engage this hook -- WGC stays as the fallback.
|
||||
#pragma once
|
||||
|
||||
#include "ipc_client.hpp"
|
||||
|
||||
namespace coop::hook
|
||||
{
|
||||
|
||||
// Installs the Present hook. Grabs IDXGISwapChain::Present from a throwaway
|
||||
// swapchain and inline-hooks it, so every swapchain in the process is caught.
|
||||
// `ipc` must outlive the hook (used to publish the shared-texture descriptor).
|
||||
// Returns true once the hook is in place; safe to call repeatedly.
|
||||
bool install_present_hooks(IpcClient& ipc);
|
||||
|
||||
// Removes the Present hook and releases the shared texture (best effort).
|
||||
void remove_present_hooks();
|
||||
|
||||
// --- Diagnostics (used by the self-test) -----------------------------------
|
||||
|
||||
// Cumulative Present() detours observed.
|
||||
std::uint64_t present_calls();
|
||||
|
||||
// Frames actually copied into the shared texture (a backbuffer we could share).
|
||||
std::uint64_t present_frames_shared();
|
||||
|
||||
} // namespace coop::hook
|
||||
Reference in New Issue
Block a user