mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05: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
@ -55,15 +55,16 @@ namespace dxvk {
|
||||
|
||||
|
||||
DxvkGraphicsPipeline::DxvkGraphicsPipeline(
|
||||
const DxvkDevice* device,
|
||||
const Rc<DxvkPipelineCache>& cache,
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs)
|
||||
const DxvkDevice* device,
|
||||
const Rc<DxvkPipelineCache>& cache,
|
||||
const Rc<DxvkPipelineCompiler>& compiler,
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs)
|
||||
: m_device(device), m_vkd(device->vkd()),
|
||||
m_cache(cache) {
|
||||
m_cache(cache), m_compiler(compiler) {
|
||||
DxvkDescriptorSlotMapping slotMapping;
|
||||
if (vs != nullptr) vs ->defineResourceSlots(slotMapping);
|
||||
if (tcs != nullptr) tcs->defineResourceSlots(slotMapping);
|
||||
@ -117,8 +118,8 @@ namespace dxvk {
|
||||
|
||||
// If no pipeline instance exists with the given state
|
||||
// vector, create a new one and add it to the list.
|
||||
VkPipeline newPipelineHandle = this->compilePipeline(
|
||||
state, renderPassHandle, VK_NULL_HANDLE);
|
||||
VkPipeline newPipelineHandle = this->compilePipeline(state, renderPassHandle,
|
||||
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT, VK_NULL_HANDLE);
|
||||
|
||||
Rc<DxvkGraphicsPipelineInstance> newPipeline =
|
||||
new DxvkGraphicsPipelineInstance(m_device->vkd(), state,
|
||||
@ -138,16 +139,20 @@ namespace dxvk {
|
||||
m_pipelines.push_back(newPipeline);
|
||||
|
||||
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) {
|
||||
// Compile an optimized version of the pipeline
|
||||
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
|
||||
// in the meantime, discard the new pipeline
|
||||
@ -171,6 +176,7 @@ namespace dxvk {
|
||||
VkPipeline DxvkGraphicsPipeline::compilePipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
VkRenderPass renderPass,
|
||||
VkPipelineCreateFlags createFlags,
|
||||
VkPipeline baseHandle) const {
|
||||
if (Logger::logLevel() <= LogLevel::Debug) {
|
||||
Logger::debug("Compiling graphics pipeline...");
|
||||
@ -324,9 +330,7 @@ namespace dxvk {
|
||||
VkGraphicsPipelineCreateInfo info;
|
||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.flags = baseHandle == VK_NULL_HANDLE
|
||||
? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT
|
||||
: VK_PIPELINE_CREATE_DERIVATIVE_BIT;
|
||||
info.flags = createFlags;
|
||||
info.stageCount = stages.size();
|
||||
info.pStages = stages.data();
|
||||
info.pVertexInputState = &viInfo;
|
||||
@ -344,6 +348,10 @@ namespace dxvk {
|
||||
info.basePipelineHandle = baseHandle;
|
||||
info.basePipelineIndex = -1;
|
||||
|
||||
info.flags |= baseHandle == VK_NULL_HANDLE
|
||||
? VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT
|
||||
: VK_PIPELINE_CREATE_DERIVATIVE_BIT;
|
||||
|
||||
if (tsInfo.patchControlPoints == 0)
|
||||
info.pTessellationState = nullptr;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "dxvk_binding.h"
|
||||
#include "dxvk_constant_state.h"
|
||||
#include "dxvk_pipecache.h"
|
||||
#include "dxvk_pipecompiler.h"
|
||||
#include "dxvk_pipelayout.h"
|
||||
#include "dxvk_renderpass.h"
|
||||
#include "dxvk_resource.h"
|
||||
@ -175,13 +176,14 @@ namespace dxvk {
|
||||
public:
|
||||
|
||||
DxvkGraphicsPipeline(
|
||||
const DxvkDevice* device,
|
||||
const Rc<DxvkPipelineCache>& cache,
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs);
|
||||
const DxvkDevice* device,
|
||||
const Rc<DxvkPipelineCache>& cache,
|
||||
const Rc<DxvkPipelineCompiler>& compiler,
|
||||
const Rc<DxvkShader>& vs,
|
||||
const Rc<DxvkShader>& tcs,
|
||||
const Rc<DxvkShader>& tes,
|
||||
const Rc<DxvkShader>& gs,
|
||||
const Rc<DxvkShader>& fs);
|
||||
~DxvkGraphicsPipeline();
|
||||
|
||||
/**
|
||||
@ -218,7 +220,7 @@ namespace dxvk {
|
||||
* and makes it available to the system.
|
||||
* \param [in] instance The pipeline instance
|
||||
*/
|
||||
void compilePipelineInstance(
|
||||
void compileInstance(
|
||||
const Rc<DxvkGraphicsPipelineInstance>& instance);
|
||||
|
||||
private:
|
||||
@ -232,8 +234,9 @@ namespace dxvk {
|
||||
const DxvkDevice* const m_device;
|
||||
const Rc<vk::DeviceFn> m_vkd;
|
||||
|
||||
Rc<DxvkPipelineCache> m_cache;
|
||||
Rc<DxvkPipelineLayout> m_layout;
|
||||
Rc<DxvkPipelineCache> m_cache;
|
||||
Rc<DxvkPipelineCompiler> m_compiler;
|
||||
Rc<DxvkPipelineLayout> m_layout;
|
||||
|
||||
Rc<DxvkShaderModule> m_vs;
|
||||
Rc<DxvkShaderModule> m_tcs;
|
||||
@ -256,6 +259,7 @@ namespace dxvk {
|
||||
VkPipeline compilePipeline(
|
||||
const DxvkGraphicsPipelineStateInfo& state,
|
||||
VkRenderPass renderPass,
|
||||
VkPipelineCreateFlags createFlags,
|
||||
VkPipeline baseHandle) const;
|
||||
|
||||
bool validatePipelineState(
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "dxvk_graphics.h"
|
||||
#include "dxvk_pipecompiler.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
@ -6,10 +6,13 @@
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
|
||||
#include "dxvk_graphics.h"
|
||||
#include "dxvk_include.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class DxvkGraphicsPipeline;
|
||||
class DxvkGraphicsPipelineInstance;
|
||||
|
||||
/**
|
||||
* \brief Pipeline compiler
|
||||
*
|
||||
|
@ -39,7 +39,9 @@ namespace dxvk {
|
||||
|
||||
|
||||
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())
|
||||
return pair->second;
|
||||
|
||||
const Rc<DxvkGraphicsPipeline> pipeline
|
||||
= new DxvkGraphicsPipeline(m_device, m_cache, vs, tcs, tes, gs, fs);
|
||||
Rc<DxvkGraphicsPipeline> pipeline = new DxvkGraphicsPipeline(
|
||||
m_device, m_cache, m_compiler, vs, tcs, tes, gs, fs);
|
||||
|
||||
m_graphicsPipelines.insert(std::make_pair(key, pipeline));
|
||||
return pipeline;
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "dxvk_compute.h"
|
||||
#include "dxvk_graphics.h"
|
||||
#include "dxvk_pipecompiler.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
@ -96,8 +97,9 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
const DxvkDevice* m_device;
|
||||
const Rc<DxvkPipelineCache> m_cache;
|
||||
const DxvkDevice* m_device;
|
||||
const Rc<DxvkPipelineCache> m_cache;
|
||||
const Rc<DxvkPipelineCompiler> m_compiler;
|
||||
|
||||
std::mutex m_mutex;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user