mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-04-06 00:57:40 +02:00
[dxvk] Use new barrier helpers for shader execution barriers
This commit is contained in:
parent
4b94b8989d
commit
56a58095fe
@ -5904,7 +5904,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (requiresBarrier) {
|
if (requiresBarrier) {
|
||||||
m_execBarriers.recordCommands(m_cmd);
|
flushBarriers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6052,23 +6052,15 @@ namespace dxvk {
|
|||||||
VkPipelineStageFlags stages,
|
VkPipelineStageFlags stages,
|
||||||
VkAccessFlags access) {
|
VkAccessFlags access) {
|
||||||
if constexpr (DoEmit) {
|
if constexpr (DoEmit) {
|
||||||
m_execBarriers.accessBuffer(
|
accessBuffer(DxvkCmdBuffer::ExecBuffer,
|
||||||
bufferSlice.getSliceHandle(),
|
*bufferSlice.buffer(), bufferSlice.offset(),
|
||||||
stages, access,
|
bufferSlice.length(), stages, access);
|
||||||
bufferSlice.bufferInfo().stages,
|
|
||||||
bufferSlice.bufferInfo().access);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
DxvkAccessFlags dstAccess = DxvkBarrierSet::getAccessTypes(access);
|
return checkResourceBarrier([this, &bufferSlice] (DxvkAccess access) {
|
||||||
|
return resourceHasAccess(*bufferSlice.buffer(),
|
||||||
bool dirty = m_execBarriers.isBufferDirty(
|
bufferSlice.offset(), bufferSlice.length(), access);
|
||||||
bufferSlice.getSliceHandle(), dstAccess);
|
}, stages, access);
|
||||||
|
|
||||||
if (!dirty || dstAccess.test(DxvkAccess::Read) || !this->canIgnoreWawHazards(stages))
|
|
||||||
return dirty;
|
|
||||||
|
|
||||||
DxvkAccessFlags srcAccess = m_execBarriers.getBufferAccess(bufferSlice.getSliceHandle());
|
|
||||||
return srcAccess.test(DxvkAccess::Read);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6079,23 +6071,13 @@ namespace dxvk {
|
|||||||
VkPipelineStageFlags stages,
|
VkPipelineStageFlags stages,
|
||||||
VkAccessFlags access) {
|
VkAccessFlags access) {
|
||||||
if constexpr (DoEmit) {
|
if constexpr (DoEmit) {
|
||||||
m_execBarriers.accessBuffer(
|
accessBuffer(DxvkCmdBuffer::ExecBuffer,
|
||||||
bufferView->getSliceHandle(),
|
*bufferView, stages, access);
|
||||||
stages, access,
|
|
||||||
bufferView->buffer()->info().stages,
|
|
||||||
bufferView->buffer()->info().access);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
DxvkAccessFlags dstAccess = DxvkBarrierSet::getAccessTypes(access);
|
return checkResourceBarrier([this, &bufferView] (DxvkAccess access) {
|
||||||
|
return resourceHasAccess(*bufferView, access);
|
||||||
bool dirty = m_execBarriers.isBufferDirty(
|
}, stages, access);
|
||||||
bufferView->getSliceHandle(), dstAccess);
|
|
||||||
|
|
||||||
if (!dirty || dstAccess.test(DxvkAccess::Read) || !this->canIgnoreWawHazards(stages))
|
|
||||||
return dirty;
|
|
||||||
|
|
||||||
DxvkAccessFlags srcAccess = m_execBarriers.getBufferAccess(bufferView->getSliceHandle());
|
|
||||||
return srcAccess.test(DxvkAccess::Read);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6106,29 +6088,16 @@ namespace dxvk {
|
|||||||
VkPipelineStageFlags stages,
|
VkPipelineStageFlags stages,
|
||||||
VkAccessFlags access) {
|
VkAccessFlags access) {
|
||||||
if constexpr (DoEmit) {
|
if constexpr (DoEmit) {
|
||||||
m_execBarriers.accessImage(
|
accessImage(DxvkCmdBuffer::ExecBuffer,
|
||||||
imageView->image(),
|
*imageView->image(),
|
||||||
imageView->imageSubresources(),
|
imageView->imageSubresources(),
|
||||||
imageView->image()->info().layout,
|
imageView->image()->info().layout,
|
||||||
stages, access,
|
stages, access);
|
||||||
imageView->image()->info().layout,
|
|
||||||
imageView->image()->info().stages,
|
|
||||||
imageView->image()->info().access);
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
DxvkAccessFlags dstAccess = DxvkBarrierSet::getAccessTypes(access);
|
return checkResourceBarrier([this, &imageView] (DxvkAccess access) {
|
||||||
|
return resourceHasAccess(*imageView, access);
|
||||||
bool dirty = m_execBarriers.isImageDirty(
|
}, stages, access);
|
||||||
imageView->image(),
|
|
||||||
imageView->imageSubresources(),
|
|
||||||
dstAccess);
|
|
||||||
|
|
||||||
if (!dirty || dstAccess.test(DxvkAccess::Read) || !this->canIgnoreWawHazards(stages))
|
|
||||||
return dirty;
|
|
||||||
|
|
||||||
DxvkAccessFlags srcAccess = m_execBarriers.getImageAccess(
|
|
||||||
imageView->image(), imageView->imageSubresources());
|
|
||||||
return srcAccess.test(DxvkAccess::Read);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6857,6 +6826,15 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DxvkContext::resourceHasAccess(
|
||||||
|
DxvkBufferView& bufferView,
|
||||||
|
DxvkAccess access) {
|
||||||
|
return resourceHasAccess(*bufferView.buffer(),
|
||||||
|
bufferView.info().offset,
|
||||||
|
bufferView.info().size, access);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DxvkContext::resourceHasAccess(
|
bool DxvkContext::resourceHasAccess(
|
||||||
DxvkImageView& imageView,
|
DxvkImageView& imageView,
|
||||||
DxvkAccess access) {
|
DxvkAccess access) {
|
||||||
|
@ -1892,13 +1892,35 @@ namespace dxvk {
|
|||||||
DxvkAccess access);
|
DxvkAccess access);
|
||||||
|
|
||||||
bool resourceHasAccess(
|
bool resourceHasAccess(
|
||||||
DxvkBufferView& buffer,
|
DxvkBufferView& bufferView,
|
||||||
DxvkAccess access);
|
DxvkAccess access);
|
||||||
|
|
||||||
bool resourceHasAccess(
|
bool resourceHasAccess(
|
||||||
DxvkImageView& imageView,
|
DxvkImageView& imageView,
|
||||||
DxvkAccess access);
|
DxvkAccess access);
|
||||||
|
|
||||||
|
template<typename Pred>
|
||||||
|
bool checkResourceBarrier(
|
||||||
|
const Pred& pred,
|
||||||
|
VkPipelineStageFlags stages,
|
||||||
|
VkAccessFlags access) {
|
||||||
|
// Check for read-after-write first, this is common
|
||||||
|
bool hasPendingWrite = pred(DxvkAccess::Write);
|
||||||
|
|
||||||
|
if (access & vk::AccessReadMask)
|
||||||
|
return hasPendingWrite;
|
||||||
|
|
||||||
|
// Check for a write-after-write hazard, but
|
||||||
|
// ignore it if there are no reads involved.
|
||||||
|
bool ignoreWaW = canIgnoreWawHazards(stages);
|
||||||
|
|
||||||
|
if (hasPendingWrite && !ignoreWaW)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Check whether there are any pending reads.
|
||||||
|
return pred(DxvkAccess::Read);
|
||||||
|
}
|
||||||
|
|
||||||
static bool formatsAreCopyCompatible(
|
static bool formatsAreCopyCompatible(
|
||||||
VkFormat imageFormat,
|
VkFormat imageFormat,
|
||||||
VkFormat bufferFormat);
|
VkFormat bufferFormat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user