1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-12 03:02:33 +02:00

[dxvk] Ignore state cache for pipelines that can be fast linked

This commit is contained in:
Philip Rebohle 2022-07-11 16:23:14 +02:00
parent ca52c5a67f
commit 52038b2f83
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 18 additions and 6 deletions

View File

@ -542,12 +542,17 @@ namespace dxvk {
if (!instance) { if (!instance) {
// Keep pipeline object locked, at worst we're going to stall // Keep pipeline object locked, at worst we're going to stall
// a state cache worker and the current thread needs priority. // a state cache worker and the current thread needs priority.
instance = this->createInstance(state); bool canCreateBasePipeline = this->canCreateBasePipeline(state);
this->writePipelineStateToCache(state); instance = this->createInstance(state, canCreateBasePipeline);
// If necessary, compile an optimized pipeline variant // If necessary, compile an optimized pipeline variant
if (!instance->fastHandle.load()) if (!instance->fastHandle.load())
m_workers->compileGraphicsPipeline(this, state); m_workers->compileGraphicsPipeline(this, state);
// Only store pipelines in the state cache that cannot benefit
// from pipeline libraries, or if that feature is disabled.
if (!canCreateBasePipeline)
this->writePipelineStateToCache(state);
} }
} }
@ -575,12 +580,17 @@ namespace dxvk {
if (!this->validatePipelineState(state, false)) if (!this->validatePipelineState(state, false))
return; return;
// Do not compile if this pipeline can be fast linked. This essentially
// disables the state cache for pipelines that do not benefit from it.
if (this->canCreateBasePipeline(state))
return;
// Prevent other threads from adding new instances and check again // Prevent other threads from adding new instances and check again
std::lock_guard<dxvk::mutex> lock(m_mutex); std::lock_guard<dxvk::mutex> lock(m_mutex);
instance = this->findInstance(state); instance = this->findInstance(state);
if (!instance) if (!instance)
instance = this->createInstance(state); instance = this->createInstance(state, false);
} }
// Exit if another thread is already compiling // Exit if another thread is already compiling
@ -599,11 +609,12 @@ namespace dxvk {
DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance( DxvkGraphicsPipelineInstance* DxvkGraphicsPipeline::createInstance(
const DxvkGraphicsPipelineStateInfo& state) { const DxvkGraphicsPipelineStateInfo& state,
bool doCreateBasePipeline) {
VkPipeline baseHandle = VK_NULL_HANDLE; VkPipeline baseHandle = VK_NULL_HANDLE;
VkPipeline fastHandle = VK_NULL_HANDLE; VkPipeline fastHandle = VK_NULL_HANDLE;
if (this->canCreateBasePipeline(state)) { if (doCreateBasePipeline) {
// Try to create an optimized pipeline from the cache // Try to create an optimized pipeline from the cache
// first, since this is expected to be the fastest path. // first, since this is expected to be the fastest path.
if (m_device->canUsePipelineCacheControl()) { if (m_device->canUsePipelineCacheControl()) {

View File

@ -410,7 +410,8 @@ namespace dxvk {
sync::List<DxvkGraphicsPipelineBaseInstance> m_basePipelines; sync::List<DxvkGraphicsPipelineBaseInstance> m_basePipelines;
DxvkGraphicsPipelineInstance* createInstance( DxvkGraphicsPipelineInstance* createInstance(
const DxvkGraphicsPipelineStateInfo& state); const DxvkGraphicsPipelineStateInfo& state,
bool doCreateBasePipeline);
DxvkGraphicsPipelineInstance* findInstance( DxvkGraphicsPipelineInstance* findInstance(
const DxvkGraphicsPipelineStateInfo& state); const DxvkGraphicsPipelineStateInfo& state);