1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 22:29:15 +01:00

[d3d11] Avoid buffer ref count changes when only changing offsets

Saves a few CPU cycles in the somewhat common situation where the
currently bound vertex, index or constant buffer is re-bound with
a different offset.
This commit is contained in:
Philip Rebohle 2019-06-04 17:45:59 +02:00
parent f501ebce97
commit 7e66dc61b9

View File

@ -1587,11 +1587,15 @@ namespace dxvk {
for (uint32_t i = 0; i < NumBuffers; i++) { for (uint32_t i = 0; i < NumBuffers; i++) {
auto newBuffer = static_cast<D3D11Buffer*>(ppVertexBuffers[i]); auto newBuffer = static_cast<D3D11Buffer*>(ppVertexBuffers[i]);
bool needsUpdate = m_state.ia.vertexBuffers[StartSlot + i].buffer != newBuffer;
if (m_state.ia.vertexBuffers[StartSlot + i].buffer != newBuffer
|| m_state.ia.vertexBuffers[StartSlot + i].offset != pOffsets[i] if (needsUpdate)
|| m_state.ia.vertexBuffers[StartSlot + i].stride != pStrides[i]) {
m_state.ia.vertexBuffers[StartSlot + i].buffer = newBuffer; m_state.ia.vertexBuffers[StartSlot + i].buffer = newBuffer;
needsUpdate |= m_state.ia.vertexBuffers[StartSlot + i].offset != pOffsets[i]
|| m_state.ia.vertexBuffers[StartSlot + i].stride != pStrides[i];
if (needsUpdate) {
m_state.ia.vertexBuffers[StartSlot + i].offset = pOffsets[i]; m_state.ia.vertexBuffers[StartSlot + i].offset = pOffsets[i];
m_state.ia.vertexBuffers[StartSlot + i].stride = pStrides[i]; m_state.ia.vertexBuffers[StartSlot + i].stride = pStrides[i];
@ -1608,11 +1612,15 @@ namespace dxvk {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
auto newBuffer = static_cast<D3D11Buffer*>(pIndexBuffer); auto newBuffer = static_cast<D3D11Buffer*>(pIndexBuffer);
bool needsUpdate = m_state.ia.indexBuffer.buffer != newBuffer;
if (m_state.ia.indexBuffer.buffer != newBuffer
|| m_state.ia.indexBuffer.offset != Offset if (needsUpdate)
|| m_state.ia.indexBuffer.format != Format) {
m_state.ia.indexBuffer.buffer = newBuffer; m_state.ia.indexBuffer.buffer = newBuffer;
needsUpdate |= m_state.ia.indexBuffer.offset != Offset
|| m_state.ia.indexBuffer.format != Format;
if (needsUpdate) {
m_state.ia.indexBuffer.offset = Offset; m_state.ia.indexBuffer.offset = Offset;
m_state.ia.indexBuffer.format = Format; m_state.ia.indexBuffer.format = Format;
@ -3465,11 +3473,16 @@ namespace dxvk {
constantCount = 0; constantCount = 0;
constantBound = 0; constantBound = 0;
} }
bool needsUpdate = Bindings[StartSlot + i].buffer != newBuffer;
if (needsUpdate)
Bindings[StartSlot + i].buffer = newBuffer;
needsUpdate |= Bindings[StartSlot + i].constantOffset != constantOffset
|| Bindings[StartSlot + i].constantCount != constantCount;
if (Bindings[StartSlot + i].buffer != newBuffer if (needsUpdate) {
|| Bindings[StartSlot + i].constantOffset != constantOffset
|| Bindings[StartSlot + i].constantCount != constantCount) {
Bindings[StartSlot + i].buffer = newBuffer;
Bindings[StartSlot + i].constantOffset = constantOffset; Bindings[StartSlot + i].constantOffset = constantOffset;
Bindings[StartSlot + i].constantCount = constantCount; Bindings[StartSlot + i].constantCount = constantCount;
Bindings[StartSlot + i].constantBound = constantBound; Bindings[StartSlot + i].constantBound = constantBound;