From 79e867624ae5710023e263078e86bb362675f6dc Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 3 Apr 2019 19:46:28 +0200 Subject: [PATCH] [dxvk] Don't cache shader modules for compute pipelines --- src/dxvk/dxvk_compute.cpp | 28 ++++++++++++++-------------- src/dxvk/dxvk_compute.h | 10 ++++++---- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index 69eec5c4b..6338ea86e 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -23,23 +23,17 @@ namespace dxvk { DxvkPipelineManager* pipeMgr, const Rc& cs) : m_vkd(pipeMgr->m_device->vkd()), - m_pipeMgr(pipeMgr) { - DxvkDescriptorSlotMapping slotMapping; - cs->defineResourceSlots(slotMapping); + m_pipeMgr(pipeMgr), m_cs(cs) { + cs->defineResourceSlots(m_slotMapping); - slotMapping.makeDescriptorsDynamic( + m_slotMapping.makeDescriptorsDynamic( m_pipeMgr->m_device->options().maxNumDynamicUniformBuffers, m_pipeMgr->m_device->options().maxNumDynamicStorageBuffers); m_layout = new DxvkPipelineLayout(m_vkd, - slotMapping.bindingCount(), - slotMapping.bindingInfos(), + m_slotMapping.bindingCount(), + m_slotMapping.bindingInfos(), VK_PIPELINE_BIND_POINT_COMPUTE); - - DxvkShaderModuleCreateInfo moduleInfo; - moduleInfo.fsDualSrcBlend = false; - - m_cs = cs->createShaderModule(m_vkd, slotMapping, moduleInfo); } @@ -98,9 +92,15 @@ namespace dxvk { if (Logger::logLevel() <= LogLevel::Debug) { Logger::debug("Compiling compute pipeline..."); - Logger::debug(str::format(" cs : ", m_cs->shader()->debugName())); + Logger::debug(str::format(" cs : ", m_cs->debugName())); } + + DxvkShaderModuleCreateInfo moduleInfo; + moduleInfo.fsDualSrcBlend = false; + + auto csm = m_cs->createShaderModule(m_vkd, m_slotMapping, moduleInfo); + DxvkSpecConstantData specData; for (uint32_t i = 0; i < MaxNumActiveBindings; i++) @@ -118,7 +118,7 @@ namespace dxvk { info.flags = baseHandle == VK_NULL_HANDLE ? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT : VK_PIPELINE_CREATE_DERIVATIVE_BIT; - info.stage = m_cs->stageInfo(&specInfo); + info.stage = csm->stageInfo(&specInfo); info.layout = m_layout->pipelineLayout(); info.basePipelineHandle = baseHandle; info.basePipelineIndex = -1; @@ -130,7 +130,7 @@ namespace dxvk { if (m_vkd->vkCreateComputePipelines(m_vkd->device(), m_pipeMgr->m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) { Logger::err("DxvkComputePipeline: Failed to compile pipeline"); - Logger::err(str::format(" cs : ", m_cs->shader()->debugName())); + Logger::err(str::format(" cs : ", m_cs->debugName())); return VK_NULL_HANDLE; } diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 8063d8e5d..740030d94 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -71,11 +71,13 @@ namespace dxvk { VkPipeline pipeline; }; - Rc m_vkd; - DxvkPipelineManager* m_pipeMgr; + Rc m_vkd; + DxvkPipelineManager* m_pipeMgr; + + DxvkDescriptorSlotMapping m_slotMapping; - Rc m_layout; - Rc m_cs; + Rc m_cs; + Rc m_layout; sync::Spinlock m_mutex; std::vector m_pipelines;