diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 7133bb8f9..58488adf7 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -106,6 +106,9 @@ D3D11DebugManager::D3D11DebugManager(WrappedID3D11Device *wrapper) m_OutputWindowID = 1; + m_supersamplingX = 1.0f; + m_supersamplingY = 1.0f; + m_WrappedDevice = wrapper; ID3D11DeviceContext *ctx = NULL; m_WrappedDevice->GetImmediateContext(&ctx); @@ -1628,6 +1631,13 @@ bool D3D11DebugManager::InitFontRendering() return true; } +void D3D11DebugManager::SetOutputWindow(HWND w) +{ + RECT rect;GetClientRect(w, &rect); + m_supersamplingX = float(m_width)/float(rect.right-rect.left); + m_supersamplingY = float(m_height)/float(rect.bottom-rect.top); +} + void D3D11DebugManager::OutputWindow::MakeRTV() { ID3D11Texture2D *texture = NULL; @@ -3201,6 +3211,9 @@ void D3D11DebugManager::RenderTextInternal(float x, float y, const char *text) data.TextSize = m_Font.CharSize; data.FontScreenAspect.x *= m_Font.CharAspect; + + data.FontScreenAspect.x *= m_supersamplingX; + data.FontScreenAspect.y *= m_supersamplingY; data.CharacterSize.x = 1.0f/float(FONT_TEX_WIDTH); data.CharacterSize.y = 1.0f/float(FONT_TEX_HEIGHT); diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index 0da55807f..8df73aa35 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -108,6 +108,7 @@ class D3D11DebugManager void FlipOutputWindow(uint64_t id); void SetOutputDimensions(int w, int h) { m_width = w; m_height = h; } + void SetOutputWindow(HWND w); int GetWidth() { return m_width; } int GetHeight() { return m_height; } @@ -252,6 +253,7 @@ class D3D11DebugManager CacheElem &GetCachedElem(ResourceId id, bool raw); int m_width, m_height; + float m_supersamplingX, m_supersamplingY; WrappedID3D11Device *m_WrappedDevice; WrappedID3D11DeviceContext *m_WrappedContext; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 019a6ce50..b745355bf 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -2349,8 +2349,6 @@ void WrappedID3D11Device::SetSwapChainTexture(IDXGISwapChain *swap, DXGI_SWAP_CH if(m_SwapChain == NULL) { m_SwapChain = swap; - - GetDebugManager()->SetOutputDimensions(desc.Width, desc.Height); } } @@ -2767,6 +2765,7 @@ bool WrappedID3D11Device::EndFrameCapture(void *wnd) DXGI_SWAP_CHAIN_DESC swapDesc = {0}; swap->GetDesc(&swapDesc); GetDebugManager()->SetOutputDimensions(swapDesc.BufferDesc.Width, swapDesc.BufferDesc.Height); + GetDebugManager()->SetOutputWindow(swapDesc.OutputWindow); const char *reasonString = "Unknown reason"; switch(reason) @@ -2777,8 +2776,6 @@ bool WrappedID3D11Device::EndFrameCapture(void *wnd) } GetDebugManager()->RenderText(0.0f, 0.0f, "Failed to capture frame %u: %hs", m_FrameCounter, reasonString); - - GetDebugManager()->SetOutputDimensions(w, h); } old.ApplyState(m_pImmediateContext); @@ -2931,6 +2928,7 @@ HRESULT WrappedID3D11Device::Present(IDXGISwapChain *swap, UINT SyncInterval, UI DXGI_SWAP_CHAIN_DESC swapDesc = {0}; swap->GetDesc(&swapDesc); GetDebugManager()->SetOutputDimensions(swapDesc.BufferDesc.Width, swapDesc.BufferDesc.Height); + GetDebugManager()->SetOutputWindow(swapDesc.OutputWindow); if(swap == m_SwapChain) { @@ -3016,8 +3014,6 @@ HRESULT WrappedID3D11Device::Present(IDXGISwapChain *swap, UINT SyncInterval, UI GetDebugManager()->RenderText(0.0f, 0.0f, str.c_str()); } - GetDebugManager()->SetOutputDimensions(w, h); - old.ApplyState(m_pImmediateContext); } @@ -3045,6 +3041,7 @@ HRESULT WrappedID3D11Device::Present(IDXGISwapChain *swap, UINT SyncInterval, UI DXGI_SWAP_CHAIN_DESC swapDesc = {0}; m_SwapChain->GetDesc(&swapDesc); GetDebugManager()->SetOutputDimensions(swapDesc.BufferDesc.Width, swapDesc.BufferDesc.Height); + GetDebugManager()->SetOutputWindow(swapDesc.OutputWindow); } }