mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-21 13:29:26 +01:00
[dxvk] Introduce DxvkComputePipelineInstance
Same as the graphics pipeline equivalent.
This commit is contained in:
parent
20b0cbdfb6
commit
3dc33c64a9
@ -37,7 +37,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkComputePipeline::~DxvkComputePipeline() {
|
DxvkComputePipeline::~DxvkComputePipeline() {
|
||||||
for (const auto& instance : m_pipelines)
|
for (const auto& instance : m_pipelines)
|
||||||
this->destroyPipeline(instance.pipeline);
|
this->destroyPipeline(instance.pipeline());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,15 +47,17 @@ namespace dxvk {
|
|||||||
|
|
||||||
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
{ std::lock_guard<sync::Spinlock> lock(m_mutex);
|
||||||
|
|
||||||
if (this->findPipeline(state, newPipelineHandle))
|
auto instance = this->findInstance(state);
|
||||||
return newPipelineHandle;
|
|
||||||
|
if (instance)
|
||||||
|
return instance->pipeline();
|
||||||
|
|
||||||
// If no pipeline instance exists with the given state
|
// If no pipeline instance exists with the given state
|
||||||
// vector, create a new one and add it to the list.
|
// vector, create a new one and add it to the list.
|
||||||
newPipelineHandle = this->createPipeline(state);
|
newPipelineHandle = this->createPipeline(state);
|
||||||
|
|
||||||
// Add new pipeline to the set
|
// Add new pipeline to the set
|
||||||
m_pipelines.push_back({ state, newPipelineHandle });
|
m_pipelines.emplace_back(state, newPipelineHandle);
|
||||||
m_pipeMgr->m_numComputePipelines += 1;
|
m_pipeMgr->m_numComputePipelines += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,17 +68,14 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DxvkComputePipeline::findPipeline(
|
const DxvkComputePipelineInstance* DxvkComputePipeline::findInstance(
|
||||||
const DxvkComputePipelineStateInfo& state,
|
const DxvkComputePipelineStateInfo& state) const {
|
||||||
VkPipeline& pipeline) const {
|
for (const auto& instance : m_pipelines) {
|
||||||
for (const PipelineStruct& pair : m_pipelines) {
|
if (instance.isCompatible(state))
|
||||||
if (pair.stateVector == state) {
|
return &instance;
|
||||||
pipeline = pair.pipeline;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,50 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Compute pipeline instance
|
||||||
|
*/
|
||||||
|
class DxvkComputePipelineInstance {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DxvkComputePipelineInstance()
|
||||||
|
: m_stateVector (),
|
||||||
|
m_pipeline (VK_NULL_HANDLE) { }
|
||||||
|
|
||||||
|
DxvkComputePipelineInstance(
|
||||||
|
const DxvkComputePipelineStateInfo& state,
|
||||||
|
VkPipeline pipe)
|
||||||
|
: m_stateVector (state),
|
||||||
|
m_pipeline (pipe) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Checks for matching pipeline state
|
||||||
|
*
|
||||||
|
* \param [in] stateVector Graphics pipeline state
|
||||||
|
* \param [in] renderPass Render pass handle
|
||||||
|
* \returns \c true if the specialization is compatible
|
||||||
|
*/
|
||||||
|
bool isCompatible(const DxvkComputePipelineStateInfo& state) const {
|
||||||
|
return m_stateVector == state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retrieves pipeline
|
||||||
|
* \returns The pipeline handle
|
||||||
|
*/
|
||||||
|
VkPipeline pipeline() const {
|
||||||
|
return m_pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
DxvkComputePipelineStateInfo m_stateVector;
|
||||||
|
VkPipeline m_pipeline;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compute pipeline
|
* \brief Compute pipeline
|
||||||
*
|
*
|
||||||
@ -75,11 +119,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct PipelineStruct {
|
|
||||||
DxvkComputePipelineStateInfo stateVector;
|
|
||||||
VkPipeline pipeline;
|
|
||||||
};
|
|
||||||
|
|
||||||
Rc<vk::DeviceFn> m_vkd;
|
Rc<vk::DeviceFn> m_vkd;
|
||||||
DxvkPipelineManager* m_pipeMgr;
|
DxvkPipelineManager* m_pipeMgr;
|
||||||
|
|
||||||
@ -89,11 +128,10 @@ namespace dxvk {
|
|||||||
Rc<DxvkPipelineLayout> m_layout;
|
Rc<DxvkPipelineLayout> m_layout;
|
||||||
|
|
||||||
sync::Spinlock m_mutex;
|
sync::Spinlock m_mutex;
|
||||||
std::vector<PipelineStruct> m_pipelines;
|
std::vector<DxvkComputePipelineInstance> m_pipelines;
|
||||||
|
|
||||||
bool findPipeline(
|
const DxvkComputePipelineInstance* findInstance(
|
||||||
const DxvkComputePipelineStateInfo& state,
|
const DxvkComputePipelineStateInfo& state) const;
|
||||||
VkPipeline& pipeline) const;
|
|
||||||
|
|
||||||
VkPipeline createPipeline(
|
VkPipeline createPipeline(
|
||||||
const DxvkComputePipelineStateInfo& state) const;
|
const DxvkComputePipelineStateInfo& state) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user