1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Optimize meta copy barriers

This commit is contained in:
Philip Rebohle 2019-03-25 17:34:41 +01:00
parent fd0daa5ec7
commit 7627f6e3ed
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 24 additions and 28 deletions

View File

@ -2033,9 +2033,12 @@ namespace dxvk {
VkImageSubresourceLayers srcSubresource, VkImageSubresourceLayers srcSubresource,
VkOffset3D srcOffset, VkOffset3D srcOffset,
VkExtent3D extent) { VkExtent3D extent) {
m_barriers.recordCommands(m_cmd); auto dstSubresourceRange = vk::makeSubresourceRange(dstSubresource);
auto srcSubresourceRange = vk::makeSubresourceRange(srcSubresource); auto srcSubresourceRange = vk::makeSubresourceRange(srcSubresource);
if (m_barriers.isImageDirty(dstImage, dstSubresourceRange, DxvkAccess::Write)
|| m_barriers.isImageDirty(srcImage, srcSubresourceRange, DxvkAccess::Write))
m_barriers.recordCommands(m_cmd);
// Source image needs to be readable // Source image needs to be readable
if (!(srcImage->info().usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { if (!(srcImage->info().usage & VK_IMAGE_USAGE_SAMPLED_BIT)) {
@ -2208,21 +2211,26 @@ namespace dxvk {
m_cmd->cmdDraw(1, tgtSubresource.layerCount, 0, 0); m_cmd->cmdDraw(1, tgtSubresource.layerCount, 0, 0);
m_cmd->cmdEndRenderPass(); m_cmd->cmdEndRenderPass();
m_barriers.accessImage(
srcImage, srcSubresourceRange,
srcLayout,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
VK_ACCESS_SHADER_READ_BIT,
srcImage->info().layout,
srcImage->info().stages,
srcImage->info().access);
m_barriers.accessImage(
dstImage, dstSubresourceRange,
dstImage->info().layout,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0,
dstImage->info().layout,
dstImage->info().stages,
dstImage->info().access);
m_cmd->trackResource(tgtImage); m_cmd->trackResource(tgtImage);
m_cmd->trackResource(srcImage); m_cmd->trackResource(srcImage);
m_cmd->trackResource(fb); m_cmd->trackResource(fb);
// If necessary, transition source image back
if (srcImage->info().layout != srcLayout) {
m_barriers.accessImage(
srcImage, srcSubresourceRange,
srcLayout,
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
VK_ACCESS_SHADER_READ_BIT,
srcImage->info().layout,
srcImage->info().stages,
srcImage->info().access);
}
// If necessary, copy the temporary image // If necessary, copy the temporary image
// to the original destination image // to the original destination image

View File

@ -35,18 +35,6 @@ namespace dxvk {
VkRenderPass DxvkMetaCopyRenderPass::createRenderPass(bool discard) const { VkRenderPass DxvkMetaCopyRenderPass::createRenderPass(bool discard) const {
auto aspect = m_dstImageView->info().aspect; auto aspect = m_dstImageView->info().aspect;
std::array<VkSubpassDependency, 2> subpassDeps = {{
{ VK_SUBPASS_EXTERNAL, 0,
m_dstImageView->imageInfo().stages,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, 0 },
{ 0, VK_SUBPASS_EXTERNAL,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
m_dstImageView->imageInfo().stages,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
m_dstImageView->imageInfo().access, 0 },
}};
VkAttachmentDescription attachment; VkAttachmentDescription attachment;
attachment.flags = 0; attachment.flags = 0;
attachment.format = m_dstImageView->info().format; attachment.format = m_dstImageView->info().format;
@ -96,8 +84,8 @@ namespace dxvk {
info.pAttachments = &attachment; info.pAttachments = &attachment;
info.subpassCount = 1; info.subpassCount = 1;
info.pSubpasses = &subpass; info.pSubpasses = &subpass;
info.dependencyCount = subpassDeps.size(); info.dependencyCount = 0;
info.pDependencies = subpassDeps.data(); info.pDependencies = nullptr;
VkRenderPass result = VK_NULL_HANDLE; VkRenderPass result = VK_NULL_HANDLE;
if (m_vkd->vkCreateRenderPass(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS) if (m_vkd->vkCreateRenderPass(m_vkd->device(), &info, nullptr, &result) != VK_SUCCESS)