mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-06 20:58:37 +01:00
[dxvk] Add helpers for transfer queue release barriers
This commit is contained in:
parent
9d45d5e49b
commit
83023cb63d
2 changed files with 98 additions and 0 deletions
|
@ -8087,6 +8087,56 @@ namespace dxvk {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::accessImageTransfer(
|
||||||
|
DxvkImage& image,
|
||||||
|
const VkImageSubresourceRange& subresources,
|
||||||
|
VkImageLayout srcLayout,
|
||||||
|
VkPipelineStageFlags2 srcStages,
|
||||||
|
VkAccessFlags2 srcAccess) {
|
||||||
|
auto& transferBatch = getBarrierBatch(DxvkCmdBuffer::SdmaBuffer);
|
||||||
|
auto& graphicsBatch = getBarrierBatch(DxvkCmdBuffer::InitBarriers);
|
||||||
|
|
||||||
|
if (srcLayout == VK_IMAGE_LAYOUT_UNDEFINED || srcLayout == VK_IMAGE_LAYOUT_PREINITIALIZED)
|
||||||
|
image.trackInitialization(subresources);
|
||||||
|
|
||||||
|
if (m_device->hasDedicatedTransferQueue()) {
|
||||||
|
VkImageMemoryBarrier2 barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 };
|
||||||
|
barrier.srcStageMask = srcStages;
|
||||||
|
barrier.srcAccessMask = srcAccess;
|
||||||
|
barrier.dstStageMask = srcStages;
|
||||||
|
barrier.dstAccessMask = VK_ACCESS_2_NONE;
|
||||||
|
barrier.oldLayout = srcLayout;
|
||||||
|
barrier.newLayout = image.info().layout;
|
||||||
|
barrier.srcQueueFamilyIndex = m_device->queues().transfer.queueFamily;
|
||||||
|
barrier.dstQueueFamilyIndex = m_device->queues().graphics.queueFamily;
|
||||||
|
barrier.image = image.handle();
|
||||||
|
barrier.subresourceRange = subresources;
|
||||||
|
|
||||||
|
transferBatch.addImageBarrier(barrier);
|
||||||
|
|
||||||
|
barrier.srcAccessMask = VK_ACCESS_2_NONE;
|
||||||
|
barrier.dstStageMask = image.info().stages;
|
||||||
|
barrier.dstAccessMask = image.info().access;
|
||||||
|
|
||||||
|
graphicsBatch.addImageBarrier(barrier);
|
||||||
|
} else {
|
||||||
|
VkImageMemoryBarrier2 barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 };
|
||||||
|
barrier.srcStageMask = srcStages;
|
||||||
|
barrier.srcAccessMask = srcAccess;
|
||||||
|
barrier.dstStageMask = image.info().stages;
|
||||||
|
barrier.dstAccessMask = image.info().access;
|
||||||
|
barrier.oldLayout = srcLayout;
|
||||||
|
barrier.newLayout = image.info().layout;
|
||||||
|
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
|
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||||
|
barrier.image = image.handle();
|
||||||
|
barrier.subresourceRange = subresources;
|
||||||
|
|
||||||
|
transferBatch.addImageBarrier(barrier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::accessBuffer(
|
void DxvkContext::accessBuffer(
|
||||||
DxvkCmdBuffer cmdBuffer,
|
DxvkCmdBuffer cmdBuffer,
|
||||||
DxvkBuffer& buffer,
|
DxvkBuffer& buffer,
|
||||||
|
@ -8206,6 +8256,42 @@ namespace dxvk {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkContext::accessBufferTransfer(
|
||||||
|
DxvkBuffer& buffer,
|
||||||
|
VkPipelineStageFlags2 srcStages,
|
||||||
|
VkAccessFlags2 srcAccess) {
|
||||||
|
auto& transferBatch = getBarrierBatch(DxvkCmdBuffer::SdmaBuffer);
|
||||||
|
auto& graphicsBatch = getBarrierBatch(DxvkCmdBuffer::InitBarriers);
|
||||||
|
|
||||||
|
if (m_device->hasDedicatedTransferQueue()) {
|
||||||
|
// No queue ownership transfer necessary since buffers all
|
||||||
|
// use SHARING_MODE_CONCURRENT, but we need a split barrier.
|
||||||
|
VkMemoryBarrier2 barrier = { VK_STRUCTURE_TYPE_MEMORY_BARRIER_2 };
|
||||||
|
barrier.srcStageMask = srcStages;
|
||||||
|
barrier.srcAccessMask = srcAccess;
|
||||||
|
barrier.dstStageMask = srcStages;
|
||||||
|
barrier.dstAccessMask = VK_ACCESS_2_NONE;
|
||||||
|
|
||||||
|
transferBatch.addMemoryBarrier(barrier);
|
||||||
|
|
||||||
|
barrier.srcStageMask = srcStages;
|
||||||
|
barrier.srcAccessMask = VK_ACCESS_2_NONE;
|
||||||
|
barrier.dstStageMask = buffer.info().stages;
|
||||||
|
barrier.dstAccessMask = buffer.info().access;
|
||||||
|
|
||||||
|
graphicsBatch.addMemoryBarrier(barrier);
|
||||||
|
} else {
|
||||||
|
VkMemoryBarrier2 barrier = { VK_STRUCTURE_TYPE_MEMORY_BARRIER_2 };
|
||||||
|
barrier.srcStageMask = srcStages;
|
||||||
|
barrier.srcAccessMask = srcAccess;
|
||||||
|
barrier.dstStageMask = buffer.info().stages;
|
||||||
|
barrier.dstAccessMask = buffer.info().access;
|
||||||
|
|
||||||
|
transferBatch.addMemoryBarrier(barrier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::accessDrawBuffer(
|
void DxvkContext::accessDrawBuffer(
|
||||||
VkDeviceSize offset,
|
VkDeviceSize offset,
|
||||||
uint32_t count,
|
uint32_t count,
|
||||||
|
|
|
@ -1973,6 +1973,13 @@ namespace dxvk {
|
||||||
VkAccessFlags2 dstAccess,
|
VkAccessFlags2 dstAccess,
|
||||||
DxvkAccessOp accessOp);
|
DxvkAccessOp accessOp);
|
||||||
|
|
||||||
|
void accessImageTransfer(
|
||||||
|
DxvkImage& image,
|
||||||
|
const VkImageSubresourceRange& subresources,
|
||||||
|
VkImageLayout srcLayout,
|
||||||
|
VkPipelineStageFlags2 srcStages,
|
||||||
|
VkAccessFlags2 srcAccess);
|
||||||
|
|
||||||
void accessBuffer(
|
void accessBuffer(
|
||||||
DxvkCmdBuffer cmdBuffer,
|
DxvkCmdBuffer cmdBuffer,
|
||||||
DxvkBuffer& buffer,
|
DxvkBuffer& buffer,
|
||||||
|
@ -2025,6 +2032,11 @@ namespace dxvk {
|
||||||
VkAccessFlags2 dstAccess,
|
VkAccessFlags2 dstAccess,
|
||||||
DxvkAccessOp accessOp);
|
DxvkAccessOp accessOp);
|
||||||
|
|
||||||
|
void accessBufferTransfer(
|
||||||
|
DxvkBuffer& buffer,
|
||||||
|
VkPipelineStageFlags2 srcStages,
|
||||||
|
VkAccessFlags2 srcAccess);
|
||||||
|
|
||||||
void accessDrawBuffer(
|
void accessDrawBuffer(
|
||||||
VkDeviceSize offset,
|
VkDeviceSize offset,
|
||||||
uint32_t count,
|
uint32_t count,
|
||||||
|
|
Loading…
Add table
Reference in a new issue