From 3d3a7258121f71992ef4fad49b14198a18dab39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 22 Sep 2014 23:00:42 -0700 Subject: [PATCH] DX9: Fixed swap chain depth creation. --- examples/common/entry/entry_windows.cpp | 2 +- src/renderer_d3d9.cpp | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 252845a1..90fd4a82 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -278,8 +278,8 @@ namespace entry m_hwnd[_wparam] = hwnd; WindowHandle handle = { (uint16_t)_wparam }; - m_eventQueue.postWindowEvent(handle, hwnd); m_eventQueue.postSizeEvent(handle, msg->m_width, msg->m_height); + m_eventQueue.postWindowEvent(handle, hwnd); delete msg; } diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 07c55647..a7ac0ce3 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -2545,13 +2545,24 @@ namespace bgfx D3DPRESENT_PARAMETERS params; memcpy(¶ms, &s_renderD3D9->m_params, sizeof(D3DPRESENT_PARAMETERS) ); - params.BackBufferWidth = _width; - params.BackBufferHeight = _height; + params.BackBufferWidth = bx::uint32_max(_width, 16); + params.BackBufferHeight = bx::uint32_max(_height, 16); DX_CHECK(s_renderD3D9->m_device->CreateAdditionalSwapChain(¶ms, &m_swapChain) ); DX_CHECK(m_swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_color[0]) ); + + DX_CHECK(s_renderD3D9->m_device->CreateDepthStencilSurface( + params.BackBufferWidth + , params.BackBufferHeight + , params.AutoDepthStencilFormat + , params.MultiSampleType + , params.MultiSampleQuality + , FALSE + , &m_depthStencil + , NULL + ) ); + m_colorHandle[0].idx = invalidHandle; - m_depthStencil = NULL; m_denseIdx = _denseIdx; m_num = 1; m_needResolve = false; @@ -2561,8 +2572,9 @@ namespace bgfx { if (NULL != m_hwnd) { - DX_RELEASE(m_color[0], 0); - DX_RELEASE(m_swapChain, 0); + DX_RELEASE(m_depthStencil, 0); + DX_RELEASE(m_color[0], 0); + DX_RELEASE(m_swapChain, 0); } else {