From 8cc4497f1143d00fac4d5d6bd15e857696a93525 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 17 Jan 2019 03:13:14 +0100 Subject: [PATCH] [dxvk] Only update index buffer for indexed draws This is somewhat uncommon, but we sometimes bind an index buffer in a render pass that doesn't get used at all. --- src/dxvk/dxvk_context.cpp | 14 +++++++------- src/dxvk/dxvk_context.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index d78395e6..92102ac4 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1130,7 +1130,7 @@ namespace dxvk { uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { - this->commitGraphicsState(); + this->commitGraphicsState(false); if (this->validateGraphicsState()) { m_cmd->cmdDraw( @@ -1148,7 +1148,7 @@ namespace dxvk { VkDeviceSize offset, uint32_t count, uint32_t stride) { - this->commitGraphicsState(); + this->commitGraphicsState(false); if (this->validateGraphicsState()) { auto descriptor = m_state.id.argBuffer.getDescriptor(); @@ -1172,7 +1172,7 @@ namespace dxvk { uint32_t firstIndex, uint32_t vertexOffset, uint32_t firstInstance) { - this->commitGraphicsState(); + this->commitGraphicsState(true); if (this->validateGraphicsState()) { m_cmd->cmdDrawIndexed( @@ -1191,7 +1191,7 @@ namespace dxvk { VkDeviceSize offset, uint32_t count, uint32_t stride) { - this->commitGraphicsState(); + this->commitGraphicsState(true); if (this->validateGraphicsState()) { auto descriptor = m_state.id.argBuffer.getDescriptor(); @@ -1213,7 +1213,7 @@ namespace dxvk { const DxvkBufferSlice& counterBuffer, uint32_t counterDivisor, uint32_t counterBias) { - this->commitGraphicsState(); + this->commitGraphicsState(false); if (this->validateGraphicsState()) { auto physSlice = counterBuffer.getSliceHandle(); @@ -3100,7 +3100,7 @@ namespace dxvk { } - void DxvkContext::commitGraphicsState() { + void DxvkContext::commitGraphicsState(bool indexed) { if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer)) this->updateFramebuffer(); @@ -3110,7 +3110,7 @@ namespace dxvk { if (m_flags.test(DxvkContextFlag::GpDirtyPipeline)) this->updateGraphicsPipeline(); - if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer)) + if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer) && indexed) this->updateIndexBufferBinding(); if (m_flags.test(DxvkContextFlag::GpDirtyVertexBuffers)) diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 8bfcb877..e0573555 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -892,7 +892,7 @@ namespace dxvk { bool validateGraphicsState(); void commitComputeState(); - void commitGraphicsState(); + void commitGraphicsState(bool indexed); void commitComputeInitBarriers(); void commitComputePostBarriers();