// D3D10 specific logic for the Present function. void presentD3D10(IDXGISwapChain *pSwapChain) { ID3D10Device *pDevice = NULL; HRESULT hr = pSwapChain->GetDevice(__uuidof(ID3D10Device), (void **) &pDevice); if (SUCCEEDED(hr) && pDevice) { SwapchainMap::iterator it = chains.find(pSwapChain); D10State *ds = it != chains.end() ? it->second : NULL; if (ds && ds->pDevice != pDevice) { ods("D3D10: SwapChain device changed"); devices.erase(ds->pDevice); delete ds; ds = NULL; } if (ds == NULL) { ods("D3D10: New state"); ds = new D10State(pSwapChain, pDevice); if (!ds->init()) { pDevice->Release(); delete ds; return; } chains[pSwapChain] = ds; devices[pDevice] = ds; } ds->draw(); pDevice->Release(); } else { #ifdef EXTENDED_OVERLAY_DEBUGOUTPUT // DXGI is used for multiple D3D versions. Thus, it is possible a device // associated with the DXGISwapChain may very well not be a D3D10 one, // in which case we can safely ignore it. ods("D3D10: Could not draw because ID3D10Device could not be retrieved."); #endif } }
static HRESULT __stdcall myPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags) { HRESULT hr; // ods("DXGI: Device Present"); ID3D10Device *pDevice = NULL; ods("DXGI: DrawBegin"); hr = pSwapChain->GetDevice(__uuidof(ID3D10Device), (void **) &pDevice); if (pDevice) { D10State *ds = chains[pSwapChain]; if (ds && ds->pDevice != pDevice) { ods("DXGI: SwapChain device changed"); devices.erase(ds->pDevice); delete ds; ds = NULL; } if (! ds) { ods("DXGI: New state"); ds = new D10State(pSwapChain, pDevice); chains[pSwapChain] = ds; devices[pDevice] = ds; ds->init(); } ds->draw(); pDevice->Release(); ods("DXGI: DrawEnd"); } PresentType oPresent = (PresentType) hhPresent.call; hhPresent.restore(); hr = oPresent(pSwapChain, SyncInterval, Flags); hhPresent.inject(); return hr; }