Fixed swap chain window counting.

This commit is contained in:
Branimir Karadžić
2018-08-27 17:56:33 -07:00
parent 41810f55bb
commit dc18a2931b
6 changed files with 49 additions and 13 deletions

View File

@@ -1806,6 +1806,16 @@ namespace bgfx { namespace d3d11
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _format, TextureFormat::Enum _depthFormat) override
{
for (uint32_t ii = 0, num = m_numWindows; ii < num; ++ii)
{
FrameBufferHandle handle = m_windows[ii];
if (isValid(handle)
&& m_frameBuffers[handle.idx].m_nwh == _nwh)
{
destroyFrameBuffer(handle);
}
}
uint16_t denseIdx = m_numWindows++;
m_windows[denseIdx] = _handle;
m_frameBuffers[_handle.idx].create(denseIdx, _nwh, _width, _height, _format, _depthFormat);
@@ -1820,8 +1830,12 @@ namespace bgfx { namespace d3d11
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
m_windows[m_numWindows] = {kInvalidHandle};
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
}
}
}
}
@@ -4564,6 +4578,7 @@ namespace bgfx { namespace d3d11
DX_RELEASE(depthStencil, 0);
m_srv[0] = NULL;
m_nwh = _nwh;
m_denseIdx = _denseIdx;
m_num = 1;
}
@@ -4575,6 +4590,7 @@ namespace bgfx { namespace d3d11
DX_RELEASE(m_swapChain, 0);
m_num = 0;
m_nwh = NULL;
m_numTh = 0;
m_needPresent = false;

View File

@@ -305,6 +305,7 @@ namespace bgfx { namespace d3d11
FrameBufferD3D11()
: m_dsv(NULL)
, m_swapChain(NULL)
, m_nwh(NULL)
, m_width(0)
, m_height(0)
, m_denseIdx(UINT16_MAX)
@@ -328,6 +329,7 @@ namespace bgfx { namespace d3d11
ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS-1];
ID3D11DepthStencilView* m_dsv;
Dxgi::SwapChainI* m_swapChain;
void* m_nwh;
uint32_t m_width;
uint32_t m_height;

View File

@@ -1658,11 +1658,13 @@ namespace bgfx { namespace d3d12
{
finishAll(true);
for (uint32_t ii = 0; ii < BX_COUNTOF(m_frameBuffers); ++ii)
for (uint32_t ii = 0, num = m_numWindows; ii < num; ++ii)
{
if (m_frameBuffers[ii].m_nwh == _nwh)
FrameBufferHandle handle = m_windows[ii];
if (isValid(handle)
&& m_frameBuffers[handle.idx].m_nwh == _nwh)
{
m_frameBuffers[ii].destroy();
destroyFrameBuffer(handle);
}
}
@@ -1687,8 +1689,12 @@ namespace bgfx { namespace d3d12
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
m_windows[m_numWindows] = {kInvalidHandle};
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
}
}
}
}

View File

@@ -1161,8 +1161,12 @@ namespace bgfx { namespace d3d9
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
m_windows[m_numWindows] = {kInvalidHandle};
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
}
}
}
}

View File

@@ -2881,8 +2881,12 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
m_windows[m_numWindows] = {kInvalidHandle};
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
}
}
}
}

View File

@@ -937,8 +937,12 @@ namespace bgfx { namespace mtl
if (m_numWindows > 1)
{
FrameBufferHandle handle = m_windows[m_numWindows];
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
m_windows[m_numWindows] = {kInvalidHandle};
if (m_numWindows != denseIdx)
{
m_windows[denseIdx] = handle;
m_frameBuffers[handle.idx].m_denseIdx = denseIdx;
}
}
}
}