diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index f328884ae..d6a847eb7 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -4004,7 +4004,7 @@ namespace dxvk { const VkClearValue* clearValues) { const DxvkFramebufferSize fbSize = framebufferInfo.size(); - Rc framebuffer = m_device->createFramebuffer(framebufferInfo); + Rc framebuffer = this->lookupFramebuffer(framebufferInfo); VkRect2D renderArea; renderArea.offset = VkOffset2D { 0, 0 }; @@ -5347,6 +5347,18 @@ namespace dxvk { } + Rc DxvkContext::lookupFramebuffer( + const DxvkFramebufferInfo& framebufferInfo) { + DxvkFramebufferKey key = framebufferInfo.key(); + size_t idx = key.hash() % m_framebufferCache.size(); + + if (m_framebufferCache[idx] == nullptr || !m_framebufferCache[idx]->key().eq(key)) + m_framebufferCache[idx] = m_device->createFramebuffer(framebufferInfo); + + return m_framebufferCache[idx]; + } + + Rc DxvkContext::createZeroBuffer( VkDeviceSize size) { if (m_zeroBuffer != nullptr && m_zeroBuffer->info().size >= size) diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index eb49bf030..3f1d91906 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1108,6 +1108,7 @@ namespace dxvk { std::array m_rc; std::array m_gpLookupCache = { }; std::array m_cpLookupCache = { }; + std::array, 512> m_framebufferCache = { }; void blitImageFb( const Rc& dstImage, @@ -1353,6 +1354,9 @@ namespace dxvk { DxvkComputePipeline* lookupComputePipeline( const DxvkComputePipelineShaders& shaders); + + Rc lookupFramebuffer( + const DxvkFramebufferInfo& framebufferInfo); Rc createZeroBuffer( VkDeviceSize size);