diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index be6439b96..ac575be06 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -3,6 +3,7 @@ #include "dxvk_compute.h" #include "dxvk_device.h" +#include "dxvk_pipemanager.h" #include "dxvk_spec_const.h" namespace dxvk { @@ -18,17 +19,16 @@ namespace dxvk { DxvkComputePipeline::DxvkComputePipeline( - const DxvkDevice* device, - const Rc& cache, + DxvkPipelineManager* pipeMgr, const Rc& cs) - : m_device(device), m_vkd(device->vkd()), - m_cache(cache) { + : m_vkd(pipeMgr->m_device->vkd()), + m_pipeMgr(pipeMgr) { DxvkDescriptorSlotMapping slotMapping; cs->defineResourceSlots(slotMapping); slotMapping.makeDescriptorsDynamic( - device->options().maxNumDynamicUniformBuffers, - device->options().maxNumDynamicStorageBuffers); + m_pipeMgr->m_device->options().maxNumDynamicUniformBuffers, + m_pipeMgr->m_device->options().maxNumDynamicStorageBuffers); m_layout = new DxvkPipelineLayout(m_vkd, slotMapping.bindingCount(), @@ -131,7 +131,7 @@ namespace dxvk { VkPipeline pipeline = VK_NULL_HANDLE; if (m_vkd->vkCreateComputePipelines(m_vkd->device(), - m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) { + 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())); return VK_NULL_HANDLE; diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 4fcedab2f..530d59d45 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -12,6 +12,7 @@ namespace dxvk { class DxvkDevice; + class DxvkPipelineManager; /** * \brief Compute pipeline state info @@ -37,8 +38,7 @@ namespace dxvk { public: DxvkComputePipeline( - const DxvkDevice* device, - const Rc& cache, + DxvkPipelineManager* pipeMgr, const Rc& cs); ~DxvkComputePipeline(); @@ -71,10 +71,9 @@ namespace dxvk { VkPipeline pipeline; }; - const DxvkDevice* const m_device; - const Rc m_vkd; + Rc m_vkd; + DxvkPipelineManager* m_pipeMgr; - Rc m_cache; Rc m_layout; Rc m_cs; diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 2b2511408..083e51823 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -3,6 +3,7 @@ #include "dxvk_device.h" #include "dxvk_graphics.h" +#include "dxvk_pipemanager.h" #include "dxvk_spec_const.h" namespace dxvk { @@ -36,14 +37,13 @@ namespace dxvk { DxvkGraphicsPipeline::DxvkGraphicsPipeline( - const DxvkDevice* device, - const Rc& cache, + DxvkPipelineManager* pipeMgr, const Rc& vs, const Rc& tcs, const Rc& tes, const Rc& gs, const Rc& fs) - : m_device(device), m_vkd(device->vkd()), m_cache(cache) { + : m_vkd(pipeMgr->m_device->vkd()), m_pipeMgr(pipeMgr) { DxvkDescriptorSlotMapping slotMapping; if (vs != nullptr) vs ->defineResourceSlots(slotMapping); if (tcs != nullptr) tcs->defineResourceSlots(slotMapping); @@ -52,8 +52,8 @@ namespace dxvk { if (fs != nullptr) fs ->defineResourceSlots(slotMapping); slotMapping.makeDescriptorsDynamic( - device->options().maxNumDynamicUniformBuffers, - device->options().maxNumDynamicStorageBuffers); + pipeMgr->m_device->options().maxNumDynamicUniformBuffers, + pipeMgr->m_device->options().maxNumDynamicStorageBuffers); m_layout = new DxvkPipelineLayout(m_vkd, slotMapping.bindingCount(), @@ -237,7 +237,7 @@ namespace dxvk { viInfo.pNext = viDivisorInfo.pNext; // TODO remove this once the extension is widely supported - if (!m_device->extensions().extVertexAttributeDivisor) + if (!m_pipeMgr->m_device->extensions().extVertexAttributeDivisor) viInfo.pNext = viDivisorInfo.pNext; VkPipelineInputAssemblyStateCreateInfo iaInfo; @@ -354,7 +354,7 @@ namespace dxvk { VkPipeline pipeline = VK_NULL_HANDLE; if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(), - m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) { + m_pipeMgr->m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) { Logger::err("DxvkGraphicsPipeline: Failed to compile pipeline"); this->logPipelineState(LogLevel::Error, state); return VK_NULL_HANDLE; diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index fc332c6cc..770cac0e4 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -14,6 +14,7 @@ namespace dxvk { class DxvkDevice; + class DxvkPipelineManager; /** * \brief Graphics pipeline state info @@ -147,8 +148,7 @@ namespace dxvk { public: DxvkGraphicsPipeline( - const DxvkDevice* device, - const Rc& cache, + DxvkPipelineManager* pipeMgr, const Rc& vs, const Rc& tcs, const Rc& tes, @@ -191,17 +191,15 @@ namespace dxvk { VkPipeline pipeline; }; - const DxvkDevice* const m_device; - const Rc m_vkd; - - Rc m_cache; - Rc m_layout; - - Rc m_vs; - Rc m_tcs; - Rc m_tes; - Rc m_gs; - Rc m_fs; + Rc m_vkd; + DxvkPipelineManager* m_pipeMgr; + + Rc m_layout; + Rc m_vs; + Rc m_tcs; + Rc m_tes; + Rc m_gs; + Rc m_fs; uint32_t m_vsIn = 0; uint32_t m_fsOut = 0; diff --git a/src/dxvk/dxvk_pipemanager.cpp b/src/dxvk/dxvk_pipemanager.cpp index 433b6002c..2d1b4902f 100644 --- a/src/dxvk/dxvk_pipemanager.cpp +++ b/src/dxvk/dxvk_pipemanager.cpp @@ -65,7 +65,7 @@ namespace dxvk { return pair->second; const Rc pipeline - = new DxvkComputePipeline(m_device, m_cache, cs); + = new DxvkComputePipeline(this, cs); m_computePipelines.insert(std::make_pair(key, pipeline)); return pipeline; @@ -95,7 +95,7 @@ namespace dxvk { return pair->second; Rc pipeline = new DxvkGraphicsPipeline( - m_device, m_cache, vs, tcs, tes, gs, fs); + this, vs, tcs, tes, gs, fs); m_graphicsPipelines.insert(std::make_pair(key, pipeline)); return pipeline; diff --git a/src/dxvk/dxvk_pipemanager.h b/src/dxvk/dxvk_pipemanager.h index f7d05536c..f605953b9 100644 --- a/src/dxvk/dxvk_pipemanager.h +++ b/src/dxvk/dxvk_pipemanager.h @@ -56,7 +56,8 @@ namespace dxvk { * pipeline objects to the client API. */ class DxvkPipelineManager : public RcObject { - + friend class DxvkComputePipeline; + friend class DxvkGraphicsPipeline; public: DxvkPipelineManager(const DxvkDevice* device);