From dc9e29601d57fbd0a067cae95bbd8a5d0d50c16c Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Wed, 20 Aug 2014 15:55:30 -0700 Subject: [PATCH 1/2] Resolve active render target in D3D9 before switch On D3D9 platforms that work on active render target instead of a specified surface, the resovle of the previous RT must happen before the new RT becomes active. --- src/renderer_d3d9.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 10625c4a..a9f9687c 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -939,6 +939,14 @@ namespace bgfx void setFrameBuffer(FrameBufferHandle _fbh, bool _msaa = true) { + if (isValid(m_fbh) + && m_fbh.idx != _fbh.idx + && m_rtMsaa) + { + FrameBufferD3D9& frameBuffer = m_frameBuffers[m_fbh.idx]; + frameBuffer.resolve(); + } + if (!isValid(_fbh) ) { DX_CHECK(m_device->SetRenderTarget(0, m_backBufferColor) ); @@ -970,14 +978,6 @@ namespace bgfx DX_CHECK(m_device->SetDepthStencilSurface(NULL != depthStencil ? depthStencil : m_backBufferDepthStencil) ); } - if (isValid(m_fbh) - && m_fbh.idx != _fbh.idx - && m_rtMsaa) - { - FrameBufferD3D9& frameBuffer = m_frameBuffers[m_fbh.idx]; - frameBuffer.resolve(); - } - m_fbh = _fbh; m_rtMsaa = _msaa; } From b209308fbce4c30705cb5478c7d2fc55673350fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 20 Aug 2014 20:11:50 -0700 Subject: [PATCH 2/2] Cleanup. --- src/renderer_d3d9.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index a9f9687c..81fe1dd6 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -940,8 +940,8 @@ namespace bgfx void setFrameBuffer(FrameBufferHandle _fbh, bool _msaa = true) { if (isValid(m_fbh) - && m_fbh.idx != _fbh.idx - && m_rtMsaa) + && m_fbh.idx != _fbh.idx + && m_rtMsaa) { FrameBufferD3D9& frameBuffer = m_frameBuffers[m_fbh.idx]; frameBuffer.resolve(); @@ -960,7 +960,7 @@ namespace bgfx { const FrameBufferD3D9& frameBuffer = m_frameBuffers[_fbh.idx]; - // If frame buffer has only depth attachement D3DFMT_NULL + // If frame buffer has only depth attachment D3DFMT_NULL // render target is created. uint32_t fbnum = bx::uint32_max(1, frameBuffer.m_num);