mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +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() {
|
||||
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);
|
||||
|
||||
if (this->findPipeline(state, newPipelineHandle))
|
||||
return newPipelineHandle;
|
||||
auto instance = this->findInstance(state);
|
||||
|
||||
if (instance)
|
||||
return instance->pipeline();
|
||||
|
||||
// If no pipeline instance exists with the given state
|
||||
// vector, create a new one and add it to the list.
|
||||
newPipelineHandle = this->createPipeline(state);
|
||||
|
||||
// Add new pipeline to the set
|
||||
m_pipelines.push_back({ state, newPipelineHandle });
|
||||
m_pipelines.emplace_back(state, newPipelineHandle);
|
||||
m_pipeMgr->m_numComputePipelines += 1;
|
||||
}
|
||||
|
||||
@ -66,17 +68,14 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
bool DxvkComputePipeline::findPipeline(
|
||||
const DxvkComputePipelineStateInfo& state,
|
||||
VkPipeline& pipeline) const {
|
||||
for (const PipelineStruct& pair : m_pipelines) {
|
||||
if (pair.stateVector == state) {
|
||||
pipeline = pair.pipeline;
|
||||
return true;
|
||||
}
|
||||
const DxvkComputePipelineInstance* DxvkComputePipeline::findInstance(
|
||||
const DxvkComputePipelineStateInfo& state) const {
|
||||
for (const auto& instance : m_pipelines) {
|
||||
if (instance.isCompatible(state))
|
||||
return &instance;
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
@ -75,11 +119,6 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
struct PipelineStruct {
|
||||
DxvkComputePipelineStateInfo stateVector;
|
||||
VkPipeline pipeline;
|
||||
};
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
DxvkPipelineManager* m_pipeMgr;
|
||||
|
||||
@ -89,11 +128,10 @@ namespace dxvk {
|
||||
Rc<DxvkPipelineLayout> m_layout;
|
||||
|
||||
sync::Spinlock m_mutex;
|
||||
std::vector<PipelineStruct> m_pipelines;
|
||||
std::vector<DxvkComputePipelineInstance> m_pipelines;
|
||||
|
||||
bool findPipeline(
|
||||
const DxvkComputePipelineStateInfo& state,
|
||||
VkPipeline& pipeline) const;
|
||||
const DxvkComputePipelineInstance* findInstance(
|
||||
const DxvkComputePipelineStateInfo& state) const;
|
||||
|
||||
VkPipeline createPipeline(
|
||||
const DxvkComputePipelineStateInfo& state) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user