From 69171873fa7cda4a61cb8e6ae0e937fe93abcec2 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 19 Feb 2025 16:16:13 +0100 Subject: [PATCH] [d3d11] Add compile-time debug flag for lazy binding --- src/d3d11/d3d11_context.cpp | 8 ++++++-- src/d3d11/d3d11_context.h | 5 +++++ src/d3d11/d3d11_context_imm.cpp | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 59d5b72c4..f722211d9 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3548,7 +3548,7 @@ namespace dxvk { m_state.lazy.shadersUsed.set(ShaderStage); m_state.lazy.bindingsUsed[ShaderStage] = pShaderModule->GetBindingMask(); - if (!m_state.lazy.shadersDirty.test(ShaderStage)) { + if (!m_state.lazy.shadersDirty.test(ShaderStage) && (DebugLazyBinding != Tristate::False)) { if (!(m_state.lazy.bindingsDirty[ShaderStage] & m_state.lazy.bindingsUsed[ShaderStage]).empty()) m_state.lazy.shadersDirty.set(ShaderStage); } @@ -4368,11 +4368,15 @@ namespace dxvk { T& DirtyMask, T DirtyBit, bool IsNull) { + // Forward immediately if lazy binding is forced off + if (DebugLazyBinding == Tristate::False) + return false; + if ((BoundMask & ~DirtyMask) & DirtyBit) { // If we're binding a non-null resource to an active slot that has not been // marked for lazy binding yet, forward the call immediately in order to // avoid tracking overhead. This is by far the most common case. - if (likely(!IsNull)) + if (likely(!IsNull && DebugLazyBinding != Tristate::True)) return false; // If we are binding a null resource to an active slot, the app will likely diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 0577c314d..5c376d195 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -75,6 +75,11 @@ namespace dxvk { // Use a local staging buffer to handle tiny uploads, most // of the time we're fine with hitting the global allocator constexpr static VkDeviceSize StagingBufferSize = 256ull << 10; + + protected: + // Compile-time debug flag to force lazy binding on (True) or off (False) + constexpr static Tristate DebugLazyBinding = Tristate::Auto; + public: D3D11CommonContext( diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index e6f6cd0da..538e3789c 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -1053,6 +1053,10 @@ namespace dxvk { void D3D11ImmediateContext::ConsiderFlush( GpuFlushType FlushType) { + // In stress test mode, behave as if this would always flush + if (DebugLazyBinding == Tristate::True) + ApplyDirtyNullBindings(); + uint64_t chunkId = GetCurrentSequenceNumber(); uint64_t submissionId = m_submissionFence->value();