From a7666aad82697c75f0df4c0751c309722eff122c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 30 Jul 2019 13:15:45 +0200 Subject: [PATCH] [dxvk] Refactor the way render passes to pipeline compiler methods --- src/dxvk/dxvk_framebuffer.h | 4 ++-- src/dxvk/dxvk_graphics.cpp | 22 ++++++++++------------ src/dxvk/dxvk_graphics.h | 16 ++++++++-------- src/dxvk/dxvk_state_cache.cpp | 2 +- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/dxvk/dxvk_framebuffer.h b/src/dxvk/dxvk_framebuffer.h index 2190a5ae8..5e4038b04 100644 --- a/src/dxvk/dxvk_framebuffer.h +++ b/src/dxvk/dxvk_framebuffer.h @@ -120,8 +120,8 @@ namespace dxvk { * \brief Retrieves render pass * \returns Render pass reference */ - const DxvkRenderPass& getRenderPass() const { - return *m_renderPass; + DxvkRenderPass* getRenderPass() const { + return m_renderPass; } /** diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 9045fdbaa..b7ee63563 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -96,7 +96,7 @@ namespace dxvk { VkPipeline DxvkGraphicsPipeline::getPipelineHandle( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) { + const DxvkRenderPass* renderPass) { DxvkGraphicsPipelineInstance* instance = nullptr; { std::lock_guard lock(m_mutex); @@ -112,14 +112,14 @@ namespace dxvk { if (!instance) return VK_NULL_HANDLE; - this->writePipelineStateToCache(state, renderPass.format()); + this->writePipelineStateToCache(state, renderPass->format()); return instance->pipeline(); } void DxvkGraphicsPipeline::compilePipeline( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) { + const DxvkRenderPass* renderPass) { std::lock_guard lock(m_mutex); if (!this->findInstance(state, renderPass)) @@ -129,7 +129,7 @@ namespace dxvk { DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) { + const DxvkRenderPass* renderPass) { // If the pipeline state vector is invalid, don't try // to create a new pipeline, it won't work anyway. if (!this->validatePipelineState(state)) @@ -138,17 +138,15 @@ namespace dxvk { VkPipeline newPipelineHandle = this->createPipeline(state, renderPass); m_pipeMgr->m_numGraphicsPipelines += 1; - return &m_pipelines.emplace_back(state, renderPass.getDefaultHandle(), newPipelineHandle); + return &m_pipelines.emplace_back(state, renderPass, newPipelineHandle); } DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::findInstance( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) { - VkRenderPass renderPassHandle = renderPass.getDefaultHandle(); - + const DxvkRenderPass* renderPass) { for (auto& instance : m_pipelines) { - if (instance.isCompatible(state, renderPassHandle)) + if (instance.isCompatible(state, renderPass)) return &instance; } @@ -158,14 +156,14 @@ namespace dxvk { VkPipeline DxvkGraphicsPipeline::createPipeline( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) const { + const DxvkRenderPass* renderPass) const { if (Logger::logLevel() <= LogLevel::Debug) { Logger::debug("Compiling graphics pipeline..."); this->logPipelineState(LogLevel::Debug, state); } // Render pass format and image layouts - DxvkRenderPassFormat passFormat = renderPass.format(); + DxvkRenderPassFormat passFormat = renderPass->format(); // Set up dynamic states as needed std::array dynamicStates; @@ -432,7 +430,7 @@ namespace dxvk { info.pColorBlendState = &cbInfo; info.pDynamicState = &dyInfo; info.layout = m_layout->pipelineLayout(); - info.renderPass = renderPass.getDefaultHandle(); + info.renderPass = renderPass->getDefaultHandle(); info.subpass = 0; info.basePipelineHandle = VK_NULL_HANDLE; info.basePipelineIndex = -1; diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 7750f5236..8467fcd5c 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -155,7 +155,7 @@ namespace dxvk { DxvkGraphicsPipelineInstance( const DxvkGraphicsPipelineStateInfo& state, - VkRenderPass rp, + const DxvkRenderPass* rp, VkPipeline pipe) : m_stateVector (state), m_renderPass (rp), @@ -170,7 +170,7 @@ namespace dxvk { */ bool isCompatible( const DxvkGraphicsPipelineStateInfo& state, - VkRenderPass rp) const { + const DxvkRenderPass* rp) { return m_stateVector == state && m_renderPass == rp; } @@ -186,7 +186,7 @@ namespace dxvk { private: DxvkGraphicsPipelineStateInfo m_stateVector; - VkRenderPass m_renderPass; + const DxvkRenderPass* m_renderPass; VkPipeline m_pipeline; }; @@ -251,7 +251,7 @@ namespace dxvk { */ VkPipeline getPipelineHandle( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass); + const DxvkRenderPass* renderPass); /** * \brief Compiles a pipeline @@ -263,7 +263,7 @@ namespace dxvk { */ void compilePipeline( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass); + const DxvkRenderPass* renderPass); private: @@ -287,15 +287,15 @@ namespace dxvk { DxvkGraphicsPipelineInstance* createInstance( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass); + const DxvkRenderPass* renderPass); DxvkGraphicsPipelineInstance* findInstance( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass); + const DxvkRenderPass* renderPass); VkPipeline createPipeline( const DxvkGraphicsPipelineStateInfo& state, - const DxvkRenderPass& renderPass) const; + const DxvkRenderPass* renderPass) const; void destroyPipeline( VkPipeline pipeline) const; diff --git a/src/dxvk/dxvk_state_cache.cpp b/src/dxvk/dxvk_state_cache.cpp index d45ef1a70..5bc30c589 100644 --- a/src/dxvk/dxvk_state_cache.cpp +++ b/src/dxvk/dxvk_state_cache.cpp @@ -262,7 +262,7 @@ namespace dxvk { const auto& entry = m_entries[e->second]; auto rp = m_passManager->getRenderPass(entry.format); - pipeline->compilePipeline(entry.gpState, *rp); + pipeline->compilePipeline(entry.gpState, rp); } } else { auto pipeline = m_pipeManager->createComputePipeline(item.cp);