From 8bccbbccc8d1c8feb5c0d7d6dd2637526e5b15a3 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 10 Jan 2018 22:54:00 +0100 Subject: [PATCH] [dxvk] Using derivative graphics pipelines --- src/dxvk/dxvk_compute.cpp | 2 +- src/dxvk/dxvk_graphics.cpp | 16 +++++++++++----- src/dxvk/dxvk_graphics.h | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index af49a71b..f1a4e2c6 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -35,7 +35,7 @@ namespace dxvk { info.stage = m_cs->stageInfo(nullptr); info.layout = m_layout->pipelineLayout(); info.basePipelineHandle = VK_NULL_HANDLE; - info.basePipelineIndex = 0; + info.basePipelineIndex = -1; if (m_vkd->vkCreateComputePipelines(m_vkd->device(), VK_NULL_HANDLE, 1, &info, nullptr, &m_pipeline) != VK_SUCCESS) diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 4af16692..077f1199 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -73,14 +73,18 @@ namespace dxvk { return pair.pipeline; } - VkPipeline pipeline = this->compilePipeline(state); + VkPipeline pipeline = this->compilePipeline(state, m_basePipeline); m_pipelines.push_back({ state, pipeline }); + + if (m_basePipeline == VK_NULL_HANDLE) + m_basePipeline = pipeline; return pipeline; } VkPipeline DxvkGraphicsPipeline::compilePipeline( - const DxvkGraphicsPipelineStateInfo& state) const { + const DxvkGraphicsPipelineStateInfo& state, + VkPipeline baseHandle) const { std::array dynamicStates = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, @@ -197,7 +201,9 @@ namespace dxvk { VkGraphicsPipelineCreateInfo info; info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; info.pNext = nullptr; - info.flags = 0; + info.flags = baseHandle == VK_NULL_HANDLE + ? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT + : VK_PIPELINE_CREATE_DERIVATIVE_BIT; info.stageCount = stages.size(); info.pStages = stages.data(); info.pVertexInputState = &viInfo; @@ -212,8 +218,8 @@ namespace dxvk { info.layout = m_layout->pipelineLayout(); info.renderPass = state.omRenderPass; info.subpass = 0; - info.basePipelineHandle = VK_NULL_HANDLE; // TODO use this - info.basePipelineIndex = 0; + info.basePipelineHandle = baseHandle; + info.basePipelineIndex = -1; VkPipeline pipeline = VK_NULL_HANDLE; if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(), diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h index 42158272..8491b764 100644 --- a/src/dxvk/dxvk_graphics.h +++ b/src/dxvk/dxvk_graphics.h @@ -134,9 +134,11 @@ namespace dxvk { std::mutex m_mutex; std::vector m_pipelines; - VkPipeline compilePipeline( - const DxvkGraphicsPipelineStateInfo& state) const; + VkPipeline m_basePipeline = VK_NULL_HANDLE; + VkPipeline compilePipeline( + const DxvkGraphicsPipelineStateInfo& state, + VkPipeline baseHandle) const; void destroyPipelines(); };