1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 02:52:10 +01:00

[dxvk] Deduplicate buffer and image slices in barrier array

Fixes some major performance issues when dealing with many
consecutive dispatch calls.
This commit is contained in:
Philip Rebohle 2021-09-09 14:06:45 +02:00
parent f0e9700f34
commit fe68b43335
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 35 additions and 3 deletions

View File

@ -31,7 +31,7 @@ namespace dxvk {
m_srcAccess |= srcAccess;
m_dstAccess |= dstAccess;
m_bufSlices.push_back({ bufSlice, access });
this->insertBufferSlice({ bufSlice, access });
}
@ -73,7 +73,7 @@ namespace dxvk {
m_imgBarriers.push_back(barrier);
}
m_imgSlices.push_back({ image->handle(), subresources, access });
this->insertImageSlice({ image->handle(), subresources, access });
}
@ -277,6 +277,34 @@ namespace dxvk {
}
void DxvkBarrierSet::insertBufferSlice(BufSlice slice) {
for (auto i = m_bufSlices.begin(); i != m_bufSlices.end(); i++) {
// We could try to merge adjacent ranges, but for now,
// just make sure we don't have duplicate slices.
if (slice.slice.handle == i->slice.handle
&& slice.slice.offset == i->slice.offset
&& slice.slice.length == i->slice.length) {
i->access.set(slice.access);
return;
}
}
m_bufSlices.push_back(slice);
}
void DxvkBarrierSet::insertImageSlice(ImgSlice slice) {
for (auto i = m_imgSlices.begin(); i != m_imgSlices.end(); i++) {
if (slice.image == i->image && slice.subres == i->subres) {
i->access.set(slice.access);
return;
}
}
m_imgSlices.push_back(slice);
}
DxvkAccessFlags DxvkBarrierSet::getAccessTypes(VkAccessFlags flags) const {
const VkAccessFlags rflags
= VK_ACCESS_INDIRECT_COMMAND_READ_BIT

View File

@ -111,7 +111,11 @@ namespace dxvk {
std::vector<BufSlice> m_bufSlices;
std::vector<ImgSlice> m_imgSlices;
void insertBufferSlice(BufSlice slice);
void insertImageSlice(ImgSlice slice);
DxvkAccessFlags getAccessTypes(VkAccessFlags flags) const;
};