mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +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:
parent
f501ebce97
commit
7e66dc61b9
@ -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
|
if (needsUpdate)
|
||||||
|| m_state.ia.vertexBuffers[StartSlot + i].offset != pOffsets[i]
|
|
||||||
|| 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
|
if (needsUpdate)
|
||||||
|| m_state.ia.indexBuffer.offset != Offset
|
|
||||||
|| 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;
|
||||||
|
|
||||||
@ -3466,10 +3474,15 @@ namespace dxvk {
|
|||||||
constantBound = 0;
|
constantBound = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bindings[StartSlot + i].buffer != newBuffer
|
bool needsUpdate = Bindings[StartSlot + i].buffer != newBuffer;
|
||||||
|| Bindings[StartSlot + i].constantOffset != constantOffset
|
|
||||||
|| Bindings[StartSlot + i].constantCount != constantCount) {
|
if (needsUpdate)
|
||||||
Bindings[StartSlot + i].buffer = newBuffer;
|
Bindings[StartSlot + i].buffer = newBuffer;
|
||||||
|
|
||||||
|
needsUpdate |= Bindings[StartSlot + i].constantOffset != constantOffset
|
||||||
|
|| Bindings[StartSlot + i].constantCount != constantCount;
|
||||||
|
|
||||||
|
if (needsUpdate) {
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user