Skip to content

Commit

Permalink
[d3d11] Add compile-time debug flag for lazy binding
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Feb 19, 2025
1 parent 7031a44 commit 99d3e57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/d3d11/d3d11_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/d3d11/d3d11_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions src/d3d11/d3d11_context_imm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 99d3e57

Please sign in to comment.