Fix crash when frame buffers are resized

This commit is contained in:
Magnus Norddahl 2023-08-30 18:53:45 +02:00 committed by Christoph Oelckers
parent ff7dff993d
commit a45fab65e8
5 changed files with 19 additions and 0 deletions

View file

@ -70,6 +70,7 @@ void VkRenderBuffers::BeginFrame(int width, int height, int sceneWidth, int scen
{
fb->GetCommands()->WaitForCommands(false);
fb->GetRenderPassManager()->RenderBuffersReset();
fb->ResetRenderStateCache();
}
if (width != mWidth || height != mHeight)

View file

@ -493,6 +493,14 @@ void VulkanRenderDevice::WaitForCommands(bool finish)
mCommands->WaitForCommands(finish);
}
void VulkanRenderDevice::ResetRenderStateCache()
{
for (auto& renderstate : mRenderState)
{
renderstate->ResetCache();
}
}
void VulkanRenderDevice::PrintStartupLog()
{
const auto &props = mDevice->PhysicalDevice.Properties.Properties;

View file

@ -85,6 +85,8 @@ public:
void WaitForCommands(bool finish) override;
void ResetRenderStateCache();
std::mutex ThreadMutex;
private:

View file

@ -740,6 +740,12 @@ void VkRenderState::EndFrame()
mStreamBufferWriter.Reset();
}
void VkRenderState::ResetCache()
{
mRenderPassSetups.clear();
mPipelineLayouts.clear();
}
void VkRenderState::EnableDrawBuffers(int count, bool apply)
{
if (mRenderTarget.DrawBuffers != count)

View file

@ -64,6 +64,8 @@ public:
void EndRenderPass();
void EndFrame();
void ResetCache();
protected:
void Apply(int dt);
void ApplyRenderPass(int dt);