From 18b39d8239ce9658225370420719365128ad6834 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 10 Aug 2018 23:29:45 +0200 Subject: [PATCH] [dxvk] Fix base pipeline assignment when compipling new pipelines We might otherwise end up destroying our base pipeline. --- src/dxvk/dxvk_graphics.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 52440c9e..8bd99f28 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -168,14 +168,14 @@ namespace dxvk { instance->m_stateVector, instance->m_renderPass, 0, m_fastPipelineBase); - // Use the new pipeline as the base pipeline for derivative pipelines - if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE) - m_fastPipelineBase.compare_exchange_strong(newPipelineBase, newPipelineHandle); - - // If an optimized version has been compiled - // in the meantime, discard the new pipeline - if (!instance->setFastPipeline(newPipelineHandle)) + if (!instance->setFastPipeline(newPipelineHandle)) { + // If another thread finished compiling an optimized version of this + // pipeline before this one finished, discard the new pipeline object. m_vkd->vkDestroyPipeline(m_vkd->device(), newPipelineHandle, nullptr); + } else if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE) { + // Use the new pipeline as the base pipeline for derivative pipelines. + m_fastPipelineBase.compare_exchange_strong(newPipelineBase, newPipelineHandle); + } }