diff --git a/src/d3d11/d3d11_context_imm.h b/src/d3d11/d3d11_context_imm.h index fbdf912b..92fcb1bc 100644 --- a/src/d3d11/d3d11_context_imm.h +++ b/src/d3d11/d3d11_context_imm.h @@ -42,13 +42,14 @@ namespace dxvk { ID3D11Resource* pResource, UINT Subresource) final; - void Synchronize(); - void SynchronizeCs(); private: DxvkCsThread m_csThread; + void Synchronize(); + void SynchronizeCs(); + void EmitCsChunk(); }; diff --git a/src/d3d11/d3d11_present.cpp b/src/d3d11/d3d11_present.cpp index 0a2e24a4..dfaa9899 100644 --- a/src/d3d11/d3d11_present.cpp +++ b/src/d3d11/d3d11_present.cpp @@ -1,4 +1,3 @@ -#include "d3d11_context_imm.h" #include "d3d11_device.h" #include "d3d11_present.h" @@ -55,12 +54,10 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D11PresentDevice::FlushRenderingCommands() { - Com ctx = nullptr; - m_device->GetImmediateContext(&ctx); + Com deviceContext = nullptr; + m_device->GetImmediateContext(&deviceContext); - auto immediateContext = static_cast(ctx.ptr()); - immediateContext->Flush(); - immediateContext->SynchronizeCs(); + deviceContext->Flush(); return S_OK; } diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index 5a749f78..925723a1 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -23,33 +23,33 @@ namespace dxvk { DxvkPhysicalBufferSlice DxvkBuffer::allocPhysicalSlice() { -// if (m_physSliceId >= m_physBuffers[m_physBufferId]->sliceCount()) { -// m_physBufferId = (m_physBufferId + 1) % m_physBuffers.size(); -// m_physSliceId = 0; -// -// if ((m_physBuffers[m_physBufferId] == nullptr) -// || (m_physBuffers[m_physBufferId]->sliceCount() < m_physSliceCount)) { -// // Make sure that all buffers have the same size. If we don't do this, -// // one of the physical buffers may grow indefinitely while the others -// // remain small, depending on the usage pattern of the application. -// m_physBuffers[m_physBufferId] = this->allocPhysicalBuffer(m_physSliceCount); -// } else if (m_physBuffers[m_physBufferId]->isInUse()) { -// // Allocate a new physical buffer if the current one is still in use. -// // This also indicates that the buffer gets updated frequently, so we -// // will double the size of the physical buffers to accomodate for it. -// if (m_physBufferId == 0) -// m_physSliceCount *= 2; -// -// m_physBuffers[m_physBufferId] = this->allocPhysicalBuffer(m_physSliceCount); -// } -// } -// -// return m_physBuffers[m_physBufferId]->slice(m_physSliceId++); - return allocPhysicalBuffer(1)->slice(0); + if (m_physSliceId >= m_physBuffers[m_physBufferId]->sliceCount()) { + m_physBufferId = (m_physBufferId + 1) % m_physBuffers.size(); + m_physSliceId = 0; + + if ((m_physBuffers[m_physBufferId] == nullptr) + || (m_physBuffers[m_physBufferId]->sliceCount() < m_physSliceCount)) { + // Make sure that all buffers have the same size. If we don't do this, + // one of the physical buffers may grow indefinitely while the others + // remain small, depending on the usage pattern of the application. + m_physBuffers[m_physBufferId] = this->allocPhysicalBuffer(m_physSliceCount); + } else if (m_physBuffers[m_physBufferId]->isInUse()) { + // Allocate a new physical buffer if the current one is still in use. + // This also indicates that the buffer gets updated frequently, so we + // will double the size of the physical buffers to accomodate for it. + if (m_physBufferId == 0) + m_physSliceCount *= 2; + + m_physBuffers[m_physBufferId] = this->allocPhysicalBuffer(m_physSliceCount); + } + } + + return m_physBuffers[m_physBufferId]->slice(m_physSliceId++); } Rc DxvkBuffer::allocPhysicalBuffer(VkDeviceSize sliceCount) const { + TRACE(this, sliceCount); return m_device->allocPhysicalBuffer(m_info, sliceCount, m_memFlags); }