From 94b5cfc3d891f26507d9cd599578f5e805ab8faf Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 10 Feb 2025 21:34:34 +0100 Subject: [PATCH] [dxvk] Don't use secondary command buffers for certain render passes If we can't use any store/resolve op optimizations on a render pass, there is no reason to pay for the overhead of secondary command buffers. --- src/dxvk/dxvk_context.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 1a969b2e9..abd2c5fb4 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -5250,7 +5250,15 @@ namespace dxvk { renderingInheritance.stencilAttachmentFormat = depthStencilFormat; } - if (m_device->perfHints().preferRenderPassOps) { + // On drivers that don't natively support secondary command buffers, only + // use them to enable MSAA resolve attachments. Also ignore color-only + // render passes here since we almost certainly need the output anyway. + bool useSecondaryCmdBuffer = m_device->perfHints().preferRenderPassOps; + + if (useSecondaryCmdBuffer && (m_device->perfHints().preferPrimaryCmdBufs || !depthStencilAspects)) + useSecondaryCmdBuffer = renderingInheritance.rasterizationSamples > VK_SAMPLE_COUNT_1_BIT; + + if (useSecondaryCmdBuffer) { // Begin secondary command buffer on tiling GPUs so that subsequent // resolve, discard and clear commands can modify render pass ops. m_flags.set(DxvkContextFlag::GpRenderPassSecondaryCmd);