diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index 4e968430..c6df6122 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -37,7 +37,7 @@ namespace dxvk { * \brief Pipeline handle * \returns Pipeline handle */ - VkPipeline handle() const { + VkPipeline getPipelineHandle() const { return m_pipeline; } diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 35229dd2..93ed7f91 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -144,7 +144,7 @@ namespace dxvk { && m_state.c.pipeline != nullptr) { m_cmd->cmdBindPipeline( VK_PIPELINE_BIND_POINT_COMPUTE, - m_state.c.pipeline->handle()); + m_state.c.pipeline->getPipelineHandle()); } m_state.c.flags.clr( diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index e69de29b..f8526130 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -0,0 +1,57 @@ +#include "dxvk_graphics.h" + +namespace dxvk { + + size_t DxvkGraphicsPipelineState::hash() const { + // TODO implement + } + + + bool DxvkGraphicsPipelineState::operator == (const DxvkGraphicsPipelineState& other) const { + // TODO implement + } + + + bool DxvkGraphicsPipelineState::operator != (const DxvkGraphicsPipelineState& other) const { + return !this->operator == (other); + } + + + DxvkGraphicsPipeline::DxvkGraphicsPipeline( + const Rc& vkd, + const Rc& vs, + const Rc& tcs, + const Rc& tes, + const Rc& gs, + const Rc& fs) + : m_vkd(vkd), m_vs(vs), m_tcs(tcs), + m_tes(tes), m_gs(gs), m_fs(fs) { + + } + + + DxvkGraphicsPipeline::~DxvkGraphicsPipeline() { + + } + + + VkPipeline DxvkGraphicsPipeline::getPipelineHandle( + const DxvkGraphicsPipelineState& state) { + std::lock_guard lock(m_mutex); + + auto pair = m_pipelines.find(state); + if (pair != m_pipelines.end()) + return pair->second; + + VkPipeline pipeline = this->compilePipeline(state); + m_pipelines.insert(std::make_pair(state, pipeline)); + return pipeline; + } + + + VkPipeline DxvkGraphicsPipeline::compilePipeline( + const DxvkGraphicsPipelineState& state) const { + + } + +} \ No newline at end of file diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 8de76016..7cf001f2 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -1,12 +1,23 @@ #pragma once #include +#include +#include "dxvk_hash.h" #include "dxvk_shader.h" #include "dxvk_resource.h" namespace dxvk { + struct DxvkGraphicsPipelineState { + VkRenderPass renderPass; + + size_t hash() const; + + bool operator == (const DxvkGraphicsPipelineState& other) const; + bool operator != (const DxvkGraphicsPipelineState& other) const; + }; + /** * \brief Graphics pipeline * @@ -27,10 +38,34 @@ namespace dxvk { const Rc& fs); ~DxvkGraphicsPipeline(); + VkDescriptorSetLayout descriptorSetLayout() const { + return m_descriptorSetLayout; + } + + VkPipeline getPipelineHandle( + const DxvkGraphicsPipelineState& state); + private: + Rc m_vkd; + Rc m_vs; + Rc m_tcs; + Rc m_tes; + Rc m_gs; + Rc m_fs; + + VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE; + VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE; + std::mutex m_mutex; + std::unordered_map< + DxvkGraphicsPipelineState, + VkPipeline, DxvkHash> m_pipelines; + + VkPipeline compilePipeline( + const DxvkGraphicsPipelineState& state) const; + }; } \ No newline at end of file