| 281 | D3D11CreateDeviceAndSwapChain_t D3D11CreateDeviceAndSwapChain_orig = nullptr; |
| 282 | |
| 283 | HRESULT WINAPI D3D11CreateDeviceAndSwapChain_hook(void *pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, |
| 284 | UINT Flags, const void *pFeatureLevels, UINT FeatureLevels, |
| 285 | UINT SDKVersion, const DXGI_SWAP_CHAIN_DESC *pSwapChainDesc, |
| 286 | IDXGISwapChain **ppSwapChain, ID3D11Device **ppDevice, |
| 287 | void *pFeatureLevel, ID3D11DeviceContext **ppImmediateContext) |
| 288 | { |
| 289 | ZoneScopedN(__FUNCTION__); |
| 290 | |
| 291 | HRESULT res = D3D11CreateDeviceAndSwapChain_orig(pAdapter, DriverType, Software, Flags, pFeatureLevels, |
| 292 | FeatureLevels, SDKVersion, pSwapChainDesc, ppSwapChain, ppDevice, |
| 293 | pFeatureLevel, ppImmediateContext); |
| 294 | |
| 295 | // We only care about the first call to this function. Other hook-based mods will sometimes create their own |
| 296 | // devices, but we don't care about those, and don't want to inject into those. |
| 297 | if (g_device) |
| 298 | { |
| 299 | return res; |
| 300 | } |
| 301 | |
| 302 | g_frameConstants.screenWidth = pSwapChainDesc->BufferDesc.Width; |
| 303 | g_frameConstants.screenHeight = pSwapChainDesc->BufferDesc.Height; |
| 304 | |
| 305 | g_device = *ppDevice; |
| 306 | |
| 307 | DX_CHECK(g_device->CreateDeferredContext(0, &g_deferred_context)); |
| 308 | |
| 309 | g_tracyD3D11Ctx = TracyD3D11Context(g_device, *ppImmediateContext); |
| 310 | |
| 311 | #define HOOK_DEVICE_METHOD(NAME) \ |
| 312 | g_d3dHooks.NAME = \ |
| 313 | hookMethod(*(void ***)*ppDevice, int(D3D11DeviceVTbl::NAME), &NAME##_hook, (void **)&g_d3dHookOrig.NAME) |
| 314 | #define HOOK_CONTEXT_METHOD(NAME) \ |
| 315 | g_d3dHooks.NAME = hookMethod(*(void ***)*ppImmediateContext, int(D3D11DeviceContextVTbl::NAME), &NAME##_hook, \ |
| 316 | (void **)&g_d3dHookOrig.NAME) |
| 317 | #define HOOK_SWAPCHAIN_METHOD(NAME) \ |
| 318 | g_d3dHooks.NAME = \ |
| 319 | hookMethod(*(void ***)*ppSwapChain, int(IDXGISwapChainVtbl::NAME), &NAME##_hook, (void **)&g_d3dHookOrig.NAME) |
| 320 | |
| 321 | HOOK_DEVICE_METHOD(CreatePixelShader); |
| 322 | HOOK_DEVICE_METHOD(CreateVertexShader); |
| 323 | HOOK_DEVICE_METHOD(CreateSamplerState); |
| 324 | |
| 325 | HOOK_CONTEXT_METHOD(PSSetShader); |
| 326 | HOOK_CONTEXT_METHOD(VSSetShader); |
| 327 | HOOK_CONTEXT_METHOD(Draw); |
| 328 | |
| 329 | HOOK_SWAPCHAIN_METHOD(ResizeBuffers); |
| 330 | HOOK_SWAPCHAIN_METHOD(Present); |
| 331 | |
| 332 | taaHookApi(*ppImmediateContext); |
| 333 | |
| 334 | #undef HOOK_DEVICE_METHOD |
| 335 | #undef HOOK_CONTEXT_METHOD |
| 336 | #undef HOOK_SWAPCHAIN_METHOD |
| 337 | |
| 338 | enableShaderHooks(); |
| 339 | |
| 340 | enableMethodHook(g_d3dHooks.CreatePixelShader); |
nothing calls this directly
no test coverage detected