Improves handling of window resizes on vulkan (avoids crashes) (#2123)

* Improves handling of window resizes on vulkan (avoids crashes)

* Change to previous commit as requested.
Rebased and added refresh swapchain check inside updateResolution(),
similar to renderer_d3d12.cpp.
This commit is contained in:
kingscallop
2020-07-18 21:41:35 +01:00
committed by GitHub
parent 6093250a3b
commit ff9f624b9b

View File

@@ -2898,7 +2898,7 @@ VK_IMPORT_DEVICE
return idx;
}
void updateResolution(const Resolution& _resolution)
bool updateResolution(const Resolution& _resolution)
{
if (!!(_resolution.reset & BGFX_RESET_MAXANISOTROPY) )
{
@@ -2982,7 +2982,7 @@ VK_IMPORT_DEVICE
{
m_resolution.width = 0;
m_resolution.height = 0;
return;
return true;
}
VK_CHECK(createSwapchain() );
@@ -3009,6 +3009,13 @@ VK_IMPORT_DEVICE
);
}
}
if (m_needToRefreshSwapchain)
{
return true;
}
return false;
}
void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs)
@@ -5870,7 +5877,10 @@ VK_DESTROY
submitCommandAndWait(m_commandBuffer);
m_commandBuffer = VK_NULL_HANDLE;
updateResolution(_render->m_resolution);
if (updateResolution(_render->m_resolution) )
{
return;
}
if (m_swapchain == VK_NULL_HANDLE)
return;