From 01014c1a2b22fe66cfaf175a34e6e1025b61d486 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 10 Aug 2022 17:20:25 +0200 Subject: [PATCH] [dxvk] Rework checkGfx*Barrier methods --- src/dxvk/dxvk_context.cpp | 39 +++++++++++++++++++++++++++++---------- src/dxvk/dxvk_context.h | 10 ++++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 56778c045..14c13111b 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -5582,7 +5582,7 @@ namespace dxvk { for (uint32_t i = 0; i < slices.size() && !requiresBarrier; i++) { if ((slices[i]->length()) && (slices[i]->bufferInfo().access & storageBufferAccess)) { - requiresBarrier = this->checkGfxBufferBarrier(*slices[i], + requiresBarrier = this->checkBufferBarrier(*slices[i], VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT, VK_ACCESS_INDIRECT_COMMAND_READ_BIT).test(DxvkAccess::Write); } @@ -5596,7 +5596,7 @@ namespace dxvk { if ((indexBufferSlice.length()) && (indexBufferSlice.bufferInfo().access & storageBufferAccess)) { - requiresBarrier = this->checkGfxBufferBarrier(indexBufferSlice, + requiresBarrier = this->checkBufferBarrier(indexBufferSlice, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_INDEX_READ_BIT).test(DxvkAccess::Write); } @@ -5612,7 +5612,7 @@ namespace dxvk { if ((vertexBufferSlice.length()) && (vertexBufferSlice.bufferInfo().access & storageBufferAccess)) { - requiresBarrier = this->checkGfxBufferBarrier(vertexBufferSlice, + requiresBarrier = this->checkBufferBarrier(vertexBufferSlice, VK_PIPELINE_STAGE_VERTEX_INPUT_BIT, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT).test(DxvkAccess::Write); } @@ -5628,12 +5628,12 @@ namespace dxvk { const auto& xfbCounterSlice = m_state.xfb.counters[i]; if (xfbBufferSlice.length()) { - requiresBarrier = this->checkGfxBufferBarrier(xfbBufferSlice, + requiresBarrier = this->checkBufferBarrier(xfbBufferSlice, VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT, VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT) != 0; if (xfbCounterSlice.length()) { - requiresBarrier |= this->checkGfxBufferBarrier(xfbCounterSlice, + requiresBarrier |= this->checkBufferBarrier(xfbCounterSlice, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT, VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT | @@ -5661,7 +5661,7 @@ namespace dxvk { case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: if ((slot.bufferSlice.length()) && (slot.bufferSlice.bufferInfo().access & storageBufferAccess)) { - srcAccess = this->checkGfxBufferBarrier(slot.bufferSlice, + srcAccess = this->checkBufferBarrier(slot.bufferSlice, util::pipelineStages(binding.stages), binding.access); } break; @@ -5670,7 +5670,7 @@ namespace dxvk { case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: if ((slot.bufferView != nullptr) && (slot.bufferView->bufferInfo().access & storageBufferAccess)) { - srcAccess = this->checkGfxBufferBarrier(slot.bufferView->slice(), + srcAccess = this->checkBufferViewBarrier(slot.bufferView, util::pipelineStages(binding.stages), binding.access); } break; @@ -5680,7 +5680,7 @@ namespace dxvk { case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: if ((slot.imageView != nullptr) && (slot.imageView->imageInfo().access & storageImageAccess)) { - srcAccess = this->checkGfxImageBarrier(slot.imageView, + srcAccess = this->checkImageViewBarrier(slot.imageView, util::pipelineStages(binding.stages), binding.access); } break; @@ -5710,7 +5710,7 @@ namespace dxvk { template - DxvkAccessFlags DxvkContext::checkGfxBufferBarrier( + DxvkAccessFlags DxvkContext::checkBufferBarrier( const DxvkBufferSlice& slice, VkPipelineStageFlags stages, VkAccessFlags access) { @@ -5728,7 +5728,26 @@ namespace dxvk { template - DxvkAccessFlags DxvkContext::checkGfxImageBarrier( + DxvkAccessFlags DxvkContext::checkBufferViewBarrier( + const Rc& view, + VkPipelineStageFlags stages, + VkAccessFlags access) { + if constexpr (DoEmit) { + m_execBarriers.accessBuffer( + view->getSliceHandle(), + stages, access, + view->bufferInfo().stages, + view->bufferInfo().access); + return DxvkAccessFlags(); + } else { + return m_execBarriers.getBufferAccess( + view->getSliceHandle()); + } + } + + + template + DxvkAccessFlags DxvkContext::checkImageViewBarrier( const Rc& imageView, VkPipelineStageFlags stages, VkAccessFlags access) { diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 3d5c5c437..cc3b7ba34 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1542,13 +1542,19 @@ namespace dxvk { void commitGraphicsBarriers(); template - DxvkAccessFlags checkGfxBufferBarrier( + DxvkAccessFlags checkBufferBarrier( const DxvkBufferSlice& slice, VkPipelineStageFlags stages, VkAccessFlags access); template - DxvkAccessFlags checkGfxImageBarrier( + DxvkAccessFlags checkBufferViewBarrier( + const Rc& slice, + VkPipelineStageFlags stages, + VkAccessFlags access); + + template + DxvkAccessFlags checkImageViewBarrier( const Rc& imageView, VkPipelineStageFlags stages, VkAccessFlags access);