mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Use VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT
Optimized versions of the pipelines will be compiled asynchronously.
This commit is contained in:
parent
517a7532be
commit
cfb4791872
@ -57,13 +57,14 @@ namespace dxvk {
|
|||||||
DxvkGraphicsPipeline::DxvkGraphicsPipeline(
|
DxvkGraphicsPipeline::DxvkGraphicsPipeline(
|
||||||
const DxvkDevice* device,
|
const DxvkDevice* device,
|
||||||
const Rc<DxvkPipelineCache>& cache,
|
const Rc<DxvkPipelineCache>& cache,
|
||||||
|
const Rc<DxvkPipelineCompiler>& compiler,
|
||||||
const Rc<DxvkShader>& vs,
|
const Rc<DxvkShader>& vs,
|
||||||
const Rc<DxvkShader>& tcs,
|
const Rc<DxvkShader>& tcs,
|
||||||
const Rc<DxvkShader>& tes,
|
const Rc<DxvkShader>& tes,
|
||||||
const Rc<DxvkShader>& gs,
|
const Rc<DxvkShader>& gs,
|
||||||
const Rc<DxvkShader>& fs)
|
const Rc<DxvkShader>& fs)
|
||||||
: m_device(device), m_vkd(device->vkd()),
|
: m_device(device), m_vkd(device->vkd()),
|
||||||
m_cache(cache) {
|
m_cache(cache), m_compiler(compiler) {
|
||||||
DxvkDescriptorSlotMapping slotMapping;
|
DxvkDescriptorSlotMapping slotMapping;
|
||||||
if (vs != nullptr) vs ->defineResourceSlots(slotMapping);
|
if (vs != nullptr) vs ->defineResourceSlots(slotMapping);
|
||||||
if (tcs != nullptr) tcs->defineResourceSlots(slotMapping);
|
if (tcs != nullptr) tcs->defineResourceSlots(slotMapping);
|
||||||
@ -117,8 +118,8 @@ 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 newPipelineHandle = this->compilePipeline(
|
VkPipeline newPipelineHandle = this->compilePipeline(state, renderPassHandle,
|
||||||
state, renderPassHandle, VK_NULL_HANDLE);
|
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT, VK_NULL_HANDLE);
|
||||||
|
|
||||||
Rc<DxvkGraphicsPipelineInstance> newPipeline =
|
Rc<DxvkGraphicsPipelineInstance> newPipeline =
|
||||||
new DxvkGraphicsPipelineInstance(m_device->vkd(), state,
|
new DxvkGraphicsPipelineInstance(m_device->vkd(), state,
|
||||||
@ -138,16 +139,20 @@ namespace dxvk {
|
|||||||
m_pipelines.push_back(newPipeline);
|
m_pipelines.push_back(newPipeline);
|
||||||
|
|
||||||
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
|
stats.addCtr(DxvkStatCounter::PipeCountGraphics, 1);
|
||||||
return newPipeline->getPipeline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile optimized pipeline asynchronously
|
||||||
|
m_compiler->queueCompilation(this, newPipeline);
|
||||||
|
return newPipelineHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkGraphicsPipeline::compilePipelineInstance(
|
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 newPipelineHandle = this->compilePipeline(
|
VkPipeline newPipelineHandle = this->compilePipeline(
|
||||||
instance->m_stateVector, instance->m_renderPass, VK_NULL_HANDLE);
|
instance->m_stateVector, instance->m_renderPass,
|
||||||
|
0, VK_NULL_HANDLE);
|
||||||
|
|
||||||
// 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
|
||||||
@ -171,6 +176,7 @@ namespace dxvk {
|
|||||||
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkRenderPass renderPass,
|
VkRenderPass renderPass,
|
||||||
|
VkPipelineCreateFlags createFlags,
|
||||||
VkPipeline baseHandle) const {
|
VkPipeline baseHandle) const {
|
||||||
if (Logger::logLevel() <= LogLevel::Debug) {
|
if (Logger::logLevel() <= LogLevel::Debug) {
|
||||||
Logger::debug("Compiling graphics pipeline...");
|
Logger::debug("Compiling graphics pipeline...");
|
||||||
@ -324,9 +330,7 @@ namespace dxvk {
|
|||||||
VkGraphicsPipelineCreateInfo info;
|
VkGraphicsPipelineCreateInfo info;
|
||||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||||
info.pNext = nullptr;
|
info.pNext = nullptr;
|
||||||
info.flags = baseHandle == VK_NULL_HANDLE
|
info.flags = createFlags;
|
||||||
? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT
|
|
||||||
: VK_PIPELINE_CREATE_DERIVATIVE_BIT;
|
|
||||||
info.stageCount = stages.size();
|
info.stageCount = stages.size();
|
||||||
info.pStages = stages.data();
|
info.pStages = stages.data();
|
||||||
info.pVertexInputState = &viInfo;
|
info.pVertexInputState = &viInfo;
|
||||||
@ -344,6 +348,10 @@ namespace dxvk {
|
|||||||
info.basePipelineHandle = baseHandle;
|
info.basePipelineHandle = baseHandle;
|
||||||
info.basePipelineIndex = -1;
|
info.basePipelineIndex = -1;
|
||||||
|
|
||||||
|
info.flags |= baseHandle == VK_NULL_HANDLE
|
||||||
|
? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT
|
||||||
|
: VK_PIPELINE_CREATE_DERIVATIVE_BIT;
|
||||||
|
|
||||||
if (tsInfo.patchControlPoints == 0)
|
if (tsInfo.patchControlPoints == 0)
|
||||||
info.pTessellationState = nullptr;
|
info.pTessellationState = nullptr;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "dxvk_binding.h"
|
#include "dxvk_binding.h"
|
||||||
#include "dxvk_constant_state.h"
|
#include "dxvk_constant_state.h"
|
||||||
#include "dxvk_pipecache.h"
|
#include "dxvk_pipecache.h"
|
||||||
|
#include "dxvk_pipecompiler.h"
|
||||||
#include "dxvk_pipelayout.h"
|
#include "dxvk_pipelayout.h"
|
||||||
#include "dxvk_renderpass.h"
|
#include "dxvk_renderpass.h"
|
||||||
#include "dxvk_resource.h"
|
#include "dxvk_resource.h"
|
||||||
@ -177,6 +178,7 @@ namespace dxvk {
|
|||||||
DxvkGraphicsPipeline(
|
DxvkGraphicsPipeline(
|
||||||
const DxvkDevice* device,
|
const DxvkDevice* device,
|
||||||
const Rc<DxvkPipelineCache>& cache,
|
const Rc<DxvkPipelineCache>& cache,
|
||||||
|
const Rc<DxvkPipelineCompiler>& compiler,
|
||||||
const Rc<DxvkShader>& vs,
|
const Rc<DxvkShader>& vs,
|
||||||
const Rc<DxvkShader>& tcs,
|
const Rc<DxvkShader>& tcs,
|
||||||
const Rc<DxvkShader>& tes,
|
const Rc<DxvkShader>& tes,
|
||||||
@ -218,7 +220,7 @@ namespace dxvk {
|
|||||||
* and makes it available to the system.
|
* and makes it available to the system.
|
||||||
* \param [in] instance The pipeline instance
|
* \param [in] instance The pipeline instance
|
||||||
*/
|
*/
|
||||||
void compilePipelineInstance(
|
void compileInstance(
|
||||||
const Rc<DxvkGraphicsPipelineInstance>& instance);
|
const Rc<DxvkGraphicsPipelineInstance>& instance);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -233,6 +235,7 @@ namespace dxvk {
|
|||||||
const Rc<vk::DeviceFn> m_vkd;
|
const Rc<vk::DeviceFn> m_vkd;
|
||||||
|
|
||||||
Rc<DxvkPipelineCache> m_cache;
|
Rc<DxvkPipelineCache> m_cache;
|
||||||
|
Rc<DxvkPipelineCompiler> m_compiler;
|
||||||
Rc<DxvkPipelineLayout> m_layout;
|
Rc<DxvkPipelineLayout> m_layout;
|
||||||
|
|
||||||
Rc<DxvkShaderModule> m_vs;
|
Rc<DxvkShaderModule> m_vs;
|
||||||
@ -256,6 +259,7 @@ namespace dxvk {
|
|||||||
VkPipeline compilePipeline(
|
VkPipeline compilePipeline(
|
||||||
const DxvkGraphicsPipelineStateInfo& state,
|
const DxvkGraphicsPipelineStateInfo& state,
|
||||||
VkRenderPass renderPass,
|
VkRenderPass renderPass,
|
||||||
|
VkPipelineCreateFlags createFlags,
|
||||||
VkPipeline baseHandle) const;
|
VkPipeline baseHandle) const;
|
||||||
|
|
||||||
bool validatePipelineState(
|
bool validatePipelineState(
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "dxvk_graphics.h"
|
||||||
#include "dxvk_pipecompiler.h"
|
#include "dxvk_pipecompiler.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
@ -6,10 +6,13 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "dxvk_graphics.h"
|
#include "dxvk_include.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
|
class DxvkGraphicsPipeline;
|
||||||
|
class DxvkGraphicsPipelineInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Pipeline compiler
|
* \brief Pipeline compiler
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
DxvkPipelineManager::DxvkPipelineManager(const DxvkDevice* device)
|
DxvkPipelineManager::DxvkPipelineManager(const DxvkDevice* device)
|
||||||
: m_device(device), m_cache(new DxvkPipelineCache(device->vkd())) {
|
: m_device (device),
|
||||||
|
m_cache (new DxvkPipelineCache(device->vkd())),
|
||||||
|
m_compiler(new DxvkPipelineCompiler()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +95,8 @@ namespace dxvk {
|
|||||||
if (pair != m_graphicsPipelines.end())
|
if (pair != m_graphicsPipelines.end())
|
||||||
return pair->second;
|
return pair->second;
|
||||||
|
|
||||||
const Rc<DxvkGraphicsPipeline> pipeline
|
Rc<DxvkGraphicsPipeline> pipeline = new DxvkGraphicsPipeline(
|
||||||
= new DxvkGraphicsPipeline(m_device, m_cache, vs, tcs, tes, gs, fs);
|
m_device, m_cache, m_compiler, vs, tcs, tes, gs, fs);
|
||||||
|
|
||||||
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
|
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
|
||||||
return pipeline;
|
return pipeline;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "dxvk_compute.h"
|
#include "dxvk_compute.h"
|
||||||
#include "dxvk_graphics.h"
|
#include "dxvk_graphics.h"
|
||||||
|
#include "dxvk_pipecompiler.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
const DxvkDevice* m_device;
|
const DxvkDevice* m_device;
|
||||||
const Rc<DxvkPipelineCache> m_cache;
|
const Rc<DxvkPipelineCache> m_cache;
|
||||||
|
const Rc<DxvkPipelineCompiler> m_compiler;
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user