mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-27 22:54:16 +01:00
[dxvk] Use derivative pipelines again
This commit is contained in:
parent
b805560340
commit
368eea7310
@ -118,8 +118,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
// 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.
|
||||||
|
VkPipeline newPipelineBase = m_basePipelineBase.load();
|
||||||
VkPipeline newPipelineHandle = this->compilePipeline(state, renderPassHandle,
|
VkPipeline newPipelineHandle = this->compilePipeline(state, renderPassHandle,
|
||||||
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT, VK_NULL_HANDLE);
|
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT, newPipelineBase);
|
||||||
|
|
||||||
Rc<DxvkGraphicsPipelineInstance> newPipeline =
|
Rc<DxvkGraphicsPipelineInstance> newPipeline =
|
||||||
new DxvkGraphicsPipelineInstance(m_device->vkd(), state,
|
new DxvkGraphicsPipelineInstance(m_device->vkd(), state,
|
||||||
@ -141,6 +142,10 @@ namespace dxvk {
|
|||||||
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
|
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the new pipeline as the base pipeline for derivative pipelines
|
||||||
|
if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE)
|
||||||
|
m_basePipelineBase.compare_exchange_strong(newPipelineBase, newPipelineHandle);
|
||||||
|
|
||||||
// Compile optimized pipeline asynchronously
|
// Compile optimized pipeline asynchronously
|
||||||
m_compiler->queueCompilation(this, newPipeline);
|
m_compiler->queueCompilation(this, newPipeline);
|
||||||
return newPipelineHandle;
|
return newPipelineHandle;
|
||||||
@ -150,9 +155,14 @@ namespace dxvk {
|
|||||||
void DxvkGraphicsPipeline::compileInstance(
|
void DxvkGraphicsPipeline::compileInstance(
|
||||||
const Rc<DxvkGraphicsPipelineInstance>& instance) {
|
const Rc<DxvkGraphicsPipelineInstance>& instance) {
|
||||||
// Compile an optimized version of the pipeline
|
// Compile an optimized version of the pipeline
|
||||||
|
VkPipeline newPipelineBase = m_fastPipelineBase.load();
|
||||||
VkPipeline newPipelineHandle = this->compilePipeline(
|
VkPipeline newPipelineHandle = this->compilePipeline(
|
||||||
instance->m_stateVector, instance->m_renderPass,
|
instance->m_stateVector, instance->m_renderPass,
|
||||||
0, VK_NULL_HANDLE);
|
0, m_fastPipelineBase);
|
||||||
|
|
||||||
|
// Use the new pipeline as the base pipeline for derivative pipelines
|
||||||
|
if (newPipelineBase == VK_NULL_HANDLE && newPipelineHandle != VK_NULL_HANDLE)
|
||||||
|
m_fastPipelineBase.compare_exchange_strong(newPipelineBase, newPipelineHandle);
|
||||||
|
|
||||||
// If an optimized version has been compiled
|
// If an optimized version has been compiled
|
||||||
// in the meantime, discard the new pipeline
|
// in the meantime, discard the new pipeline
|
||||||
|
@ -249,9 +249,14 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkGraphicsCommonPipelineStateInfo m_common;
|
DxvkGraphicsCommonPipelineStateInfo m_common;
|
||||||
|
|
||||||
sync::Spinlock m_mutex;
|
// List of pipeline instances, shared between threads
|
||||||
|
alignas(CACHE_LINE_SIZE) sync::Spinlock m_mutex;
|
||||||
std::vector<Rc<DxvkGraphicsPipelineInstance>> m_pipelines;
|
std::vector<Rc<DxvkGraphicsPipelineInstance>> m_pipelines;
|
||||||
|
|
||||||
|
// Pipeline handles used for derivative pipelines
|
||||||
|
std::atomic<VkPipeline> m_basePipelineBase = { VK_NULL_HANDLE };
|
||||||
|
std::atomic<VkPipeline> m_fastPipelineBase = { VK_NULL_HANDLE };
|
||||||
|
|
||||||
DxvkGraphicsPipelineInstance* findInstance(
|
DxvkGraphicsPipelineInstance* findInstance(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkRenderPass renderPass) const;
|
VkRenderPass renderPass) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user