1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxvk] Discard slices from old physical buffers

Improves effectiveness of an optimization that allows
using dynamic buffer offsets for descriptor sets.
This commit is contained in:
Philip Rebohle 2018-06-22 00:27:52 +02:00
parent 79a1703aea
commit 32cd85dc11
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 10 additions and 4 deletions

View File

@ -42,11 +42,11 @@ namespace dxvk {
// If there are still no slices available, create a new // If there are still no slices available, create a new
// physical buffer and add all slices to the free list. // physical buffer and add all slices to the free list.
if (m_freeSlices.size() == 0) { if (m_freeSlices.size() == 0) {
const Rc<DxvkPhysicalBuffer> buffer std::unique_lock<std::mutex> swapLock(m_swapMutex);
= this->allocPhysicalBuffer(m_physSliceCount); m_physBuffer = this->allocPhysicalBuffer(m_physSliceCount);
for (uint32_t i = 0; i < m_physSliceCount; i++) { for (uint32_t i = 0; i < m_physSliceCount; i++) {
m_freeSlices.push_back(buffer->slice( m_freeSlices.push_back(m_physBuffer->slice(
m_physSliceStride * i, m_physSliceStride * i,
m_physSliceLength)); m_physSliceLength));
} }
@ -64,7 +64,11 @@ namespace dxvk {
void DxvkBuffer::freePhysicalSlice(const DxvkPhysicalBufferSlice& slice) { void DxvkBuffer::freePhysicalSlice(const DxvkPhysicalBufferSlice& slice) {
// Add slice to a separate free list to reduce lock contention. // Add slice to a separate free list to reduce lock contention.
std::unique_lock<std::mutex> swapLock(m_swapMutex); std::unique_lock<std::mutex> swapLock(m_swapMutex);
m_nextSlices.push_back(slice);
// Discard slices allocated from other physical buffers.
// This may make descriptor set binding more efficient.
if (m_physBuffer->handle() == slice.handle())
m_nextSlices.push_back(slice);
} }

View File

@ -149,6 +149,8 @@ namespace dxvk {
VkDeviceSize m_physSliceLength = 0; VkDeviceSize m_physSliceLength = 0;
VkDeviceSize m_physSliceStride = 0; VkDeviceSize m_physSliceStride = 0;
VkDeviceSize m_physSliceCount = 2; VkDeviceSize m_physSliceCount = 2;
Rc<DxvkPhysicalBuffer> m_physBuffer;
Rc<DxvkPhysicalBuffer> allocPhysicalBuffer( Rc<DxvkPhysicalBuffer> allocPhysicalBuffer(
VkDeviceSize sliceCount) const; VkDeviceSize sliceCount) const;