diff --git a/src/dxvk/dxvk_barrier.cpp b/src/dxvk/dxvk_barrier.cpp index eaa2cf56..b0be24d0 100644 --- a/src/dxvk/dxvk_barrier.cpp +++ b/src/dxvk/dxvk_barrier.cpp @@ -87,7 +87,8 @@ namespace dxvk { m_imgBarriers.push_back(barrier); } - this->insertImageSlice({ image->handle(), subresources, access }); + m_imgSlices.insert(image->handle(), + DxvkBarrierImageSlice(subresources, access)); } @@ -168,8 +169,10 @@ namespace dxvk { acquire.m_imgBarriers.push_back(barrier); DxvkAccessFlags access(DxvkAccess::Read, DxvkAccess::Write); - release.m_imgSlices.push_back({ image->handle(), subresources, access }); - acquire.m_imgSlices.push_back({ image->handle(), subresources, access }); + release.m_imgSlices.insert(image->handle(), + DxvkBarrierImageSlice(subresources, access)); + acquire.m_imgSlices.insert(image->handle(), + DxvkBarrierImageSlice(subresources, access)); } @@ -185,19 +188,8 @@ namespace dxvk { const Rc& image, const VkImageSubresourceRange& imgSubres, DxvkAccessFlags imgAccess) { - bool result = false; - - for (uint32_t i = 0; i < m_imgSlices.size() && !result; i++) { - const VkImageSubresourceRange& dstSubres = m_imgSlices[i].subres; - - result = (image->handle() == m_imgSlices[i].image) && (imgAccess | m_imgSlices[i].access).test(DxvkAccess::Write) - && (imgSubres.baseArrayLayer < dstSubres.baseArrayLayer + dstSubres.layerCount) - && (imgSubres.baseArrayLayer + imgSubres.layerCount > dstSubres.baseArrayLayer) - && (imgSubres.baseMipLevel < dstSubres.baseMipLevel + dstSubres.levelCount) - && (imgSubres.baseMipLevel + imgSubres.levelCount > dstSubres.baseMipLevel); - } - - return result; + return m_imgSlices.isDirty(image->handle(), + DxvkBarrierImageSlice(imgSubres, imgAccess)); } @@ -211,20 +203,8 @@ namespace dxvk { DxvkAccessFlags DxvkBarrierSet::getImageAccess( const Rc& image, const VkImageSubresourceRange& imgSubres) { - DxvkAccessFlags access; - - for (uint32_t i = 0; i < m_imgSlices.size(); i++) { - const VkImageSubresourceRange& dstSubres = m_imgSlices[i].subres; - - if ((image->handle() == m_imgSlices[i].image) - && (imgSubres.baseArrayLayer < dstSubres.baseArrayLayer + dstSubres.layerCount) - && (imgSubres.baseArrayLayer + imgSubres.layerCount > dstSubres.baseArrayLayer) - && (imgSubres.baseMipLevel < dstSubres.baseMipLevel + dstSubres.levelCount) - && (imgSubres.baseMipLevel + imgSubres.levelCount > dstSubres.baseMipLevel)) - access = access | m_imgSlices[i].access; - } - - return access; + return m_imgSlices.getAccess(image->handle(), + DxvkBarrierImageSlice(imgSubres, 0)); } @@ -270,22 +250,10 @@ namespace dxvk { m_imgBarriers.resize(0); m_bufSlices.clear(); - m_imgSlices.resize(0); + m_imgSlices.clear(); } - 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 VkAccessFlags rflags = VK_ACCESS_INDIRECT_COMMAND_READ_BIT diff --git a/src/dxvk/dxvk_barrier.h b/src/dxvk/dxvk_barrier.h index 258c9c3f..378070f4 100644 --- a/src/dxvk/dxvk_barrier.h +++ b/src/dxvk/dxvk_barrier.h @@ -564,11 +564,8 @@ namespace dxvk { std::vector m_bufBarriers; std::vector m_imgBarriers; - std::vector m_imgSlices; - DxvkBarrierSubresourceSet m_bufSlices; - - void insertImageSlice(ImgSlice slice); + DxvkBarrierSubresourceSet m_imgSlices; };