1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 22:29:15 +01:00

[dxvk] Remove barrier argument from render target transition functions

We're always using the same barrier set anyway.
This commit is contained in:
Philip Rebohle 2022-07-20 16:57:27 +02:00
parent 16eae7adde
commit a178c57aea
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 26 additions and 34 deletions

View File

@ -195,8 +195,8 @@ namespace dxvk {
const VkImageBlit& region, const VkImageBlit& region,
VkFilter filter) { VkFilter filter) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(region.dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(region.dstSubresource));
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(region.srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(region.srcSubresource));
auto mapping = util::resolveSrcComponentMapping(dstMapping, srcMapping); auto mapping = util::resolveSrcComponentMapping(dstMapping, srcMapping);
@ -230,7 +230,7 @@ namespace dxvk {
VkImageSubresourceRange subresources = image->getAvailableSubresources(); VkImageSubresourceRange subresources = image->getAvailableSubresources();
this->prepareImage(m_execBarriers, image, subresources); this->prepareImage(image, subresources);
if (m_execBarriers.isImageDirty(image, subresources, DxvkAccess::Write)) if (m_execBarriers.isImageDirty(image, subresources, DxvkAccess::Write))
m_execBarriers.recordCommands(m_cmd); m_execBarriers.recordCommands(m_cmd);
@ -393,7 +393,7 @@ namespace dxvk {
// will indirectly emit barriers for the given render target. // will indirectly emit barriers for the given render target.
// If there is overlap, we need to explicitly transition affected attachments. // If there is overlap, we need to explicitly transition affected attachments.
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, imageView->image(), imageView->subresources(), false); this->prepareImage(imageView->image(), imageView->subresources(), false);
} else if (!m_state.om.framebufferInfo.isWritable(attachmentIndex, clearAspects)) { } else if (!m_state.om.framebufferInfo.isWritable(attachmentIndex, clearAspects)) {
// We cannot inline clears if the clear aspects are not writable // We cannot inline clears if the clear aspects are not writable
this->spillRenderPass(true); this->spillRenderPass(true);
@ -542,7 +542,7 @@ namespace dxvk {
VkDeviceSize rowAlignment, VkDeviceSize rowAlignment,
VkDeviceSize sliceAlignment) { VkDeviceSize sliceAlignment) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(dstSubresource));
auto srcSlice = srcBuffer->getSliceHandle(srcOffset, 0); auto srcSlice = srcBuffer->getSliceHandle(srcOffset, 0);
@ -612,8 +612,8 @@ namespace dxvk {
if (this->copyImageClear(dstImage, dstSubresource, dstOffset, extent, srcImage, srcSubresource)) if (this->copyImageClear(dstImage, dstSubresource, dstOffset, extent, srcImage, srcSubresource))
return; return;
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(dstSubresource));
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(srcSubresource));
bool useFb = dstSubresource.aspectMask != srcSubresource.aspectMask; bool useFb = dstSubresource.aspectMask != srcSubresource.aspectMask;
@ -713,7 +713,7 @@ namespace dxvk {
VkOffset3D srcOffset, VkOffset3D srcOffset,
VkExtent3D srcExtent) { VkExtent3D srcExtent) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(srcSubresource));
auto dstSlice = dstBuffer->getSliceHandle(dstOffset, 0); auto dstSlice = dstBuffer->getSliceHandle(dstOffset, 0);
@ -775,7 +775,7 @@ namespace dxvk {
VkExtent2D srcExtent, VkExtent2D srcExtent,
VkFormat format) { VkFormat format) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(srcSubresource));
this->invalidateState(); this->invalidateState();
@ -1063,7 +1063,7 @@ namespace dxvk {
this->spillRenderPass(true); this->spillRenderPass(true);
this->invalidateState(); this->invalidateState();
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(dstSubresource));
if (m_execBarriers.isBufferDirty(srcBuffer->getSliceHandle(), DxvkAccess::Read) if (m_execBarriers.isBufferDirty(srcBuffer->getSliceHandle(), DxvkAccess::Read)
|| m_execBarriers.isImageDirty(dstImage, vk::makeSubresourceRange(dstSubresource), DxvkAccess::Write)) || m_execBarriers.isImageDirty(dstImage, vk::makeSubresourceRange(dstSubresource), DxvkAccess::Write))
@ -1806,8 +1806,8 @@ namespace dxvk {
const VkImageResolve& region, const VkImageResolve& region,
VkFormat format) { VkFormat format) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(region.dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(region.dstSubresource));
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(region.srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(region.srcSubresource));
if (format == VK_FORMAT_UNDEFINED) if (format == VK_FORMAT_UNDEFINED)
format = srcImage->info().format; format = srcImage->info().format;
@ -1839,8 +1839,8 @@ namespace dxvk {
VkResolveModeFlagBits depthMode, VkResolveModeFlagBits depthMode,
VkResolveModeFlagBits stencilMode) { VkResolveModeFlagBits stencilMode) {
this->spillRenderPass(true); this->spillRenderPass(true);
this->prepareImage(m_execBarriers, dstImage, vk::makeSubresourceRange(region.dstSubresource)); this->prepareImage(dstImage, vk::makeSubresourceRange(region.dstSubresource));
this->prepareImage(m_execBarriers, srcImage, vk::makeSubresourceRange(region.srcSubresource)); this->prepareImage(srcImage, vk::makeSubresourceRange(region.srcSubresource));
// Technically legal, but no-op // Technically legal, but no-op
if (!depthMode && !stencilMode) if (!depthMode && !stencilMode)
@ -2154,7 +2154,7 @@ namespace dxvk {
} }
} }
this->transitionRenderTargetLayouts(m_execBarriers, true); this->transitionRenderTargetLayouts(true);
} }
@ -2590,7 +2590,7 @@ namespace dxvk {
srcStages |= r.first->info().stages; srcStages |= r.first->info().stages;
srcAccess |= r.first->info().access; srcAccess |= r.first->info().access;
this->prepareImage(m_execBarriers, r.first, r.first->getAvailableSubresources()); this->prepareImage(r.first, r.first->getAvailableSubresources());
} }
m_execBarriers.accessMemory(srcStages, srcAccess, m_execBarriers.accessMemory(srcStages, srcAccess,
@ -4136,14 +4136,14 @@ namespace dxvk {
if (suspend) if (suspend)
m_flags.set(DxvkContextFlag::GpRenderPassSuspended); m_flags.set(DxvkContextFlag::GpRenderPassSuspended);
else else
this->transitionRenderTargetLayouts(m_execBarriers, false); this->transitionRenderTargetLayouts(false);
m_execBarriers.recordCommands(m_cmd); m_execBarriers.recordCommands(m_cmd);
} else if (!suspend) { } else if (!suspend) {
// We may end a previously suspended render pass // We may end a previously suspended render pass
if (m_flags.test(DxvkContextFlag::GpRenderPassSuspended)) { if (m_flags.test(DxvkContextFlag::GpRenderPassSuspended)) {
m_flags.clr(DxvkContextFlag::GpRenderPassSuspended); m_flags.clr(DxvkContextFlag::GpRenderPassSuspended);
this->transitionRenderTargetLayouts(m_execBarriers, false); this->transitionRenderTargetLayouts(false);
m_execBarriers.recordCommands(m_cmd); m_execBarriers.recordCommands(m_cmd);
} }
@ -4936,13 +4936,12 @@ namespace dxvk {
void DxvkContext::transitionRenderTargetLayouts( void DxvkContext::transitionRenderTargetLayouts(
DxvkBarrierSet& barriers,
bool sharedOnly) { bool sharedOnly) {
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) { for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
const DxvkAttachment& color = m_state.om.framebufferInfo.getColorTarget(i); const DxvkAttachment& color = m_state.om.framebufferInfo.getColorTarget(i);
if (color.view != nullptr && (!sharedOnly || color.view->imageInfo().shared)) { if (color.view != nullptr && (!sharedOnly || color.view->imageInfo().shared)) {
this->transitionColorAttachment(barriers, color, m_rtLayouts.color[i]); this->transitionColorAttachment(color, m_rtLayouts.color[i]);
m_rtLayouts.color[i] = color.view->imageInfo().layout; m_rtLayouts.color[i] = color.view->imageInfo().layout;
} }
} }
@ -4950,18 +4949,17 @@ namespace dxvk {
const DxvkAttachment& depth = m_state.om.framebufferInfo.getDepthTarget(); const DxvkAttachment& depth = m_state.om.framebufferInfo.getDepthTarget();
if (depth.view != nullptr && (!sharedOnly || depth.view->imageInfo().shared)) { if (depth.view != nullptr && (!sharedOnly || depth.view->imageInfo().shared)) {
this->transitionDepthAttachment(barriers, depth, m_rtLayouts.depth); this->transitionDepthAttachment(depth, m_rtLayouts.depth);
m_rtLayouts.depth = depth.view->imageInfo().layout; m_rtLayouts.depth = depth.view->imageInfo().layout;
} }
} }
void DxvkContext::transitionColorAttachment( void DxvkContext::transitionColorAttachment(
DxvkBarrierSet& barriers,
const DxvkAttachment& attachment, const DxvkAttachment& attachment,
VkImageLayout oldLayout) { VkImageLayout oldLayout) {
if (oldLayout != attachment.view->imageInfo().layout) { if (oldLayout != attachment.view->imageInfo().layout) {
barriers.accessImage( m_execBarriers.accessImage(
attachment.view->image(), attachment.view->image(),
attachment.view->imageSubresources(), oldLayout, attachment.view->imageSubresources(), oldLayout,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
@ -4976,11 +4974,10 @@ namespace dxvk {
void DxvkContext::transitionDepthAttachment( void DxvkContext::transitionDepthAttachment(
DxvkBarrierSet& barriers,
const DxvkAttachment& attachment, const DxvkAttachment& attachment,
VkImageLayout oldLayout) { VkImageLayout oldLayout) {
if (oldLayout != attachment.view->imageInfo().layout) { if (oldLayout != attachment.view->imageInfo().layout) {
barriers.accessImage( m_execBarriers.accessImage(
attachment.view->image(), attachment.view->image(),
attachment.view->imageSubresources(), oldLayout, attachment.view->imageSubresources(), oldLayout,
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
@ -5030,7 +5027,7 @@ namespace dxvk {
} }
if (!found && m_flags.test(DxvkContextFlag::GpRenderPassSuspended)) if (!found && m_flags.test(DxvkContextFlag::GpRenderPassSuspended))
this->transitionColorAttachment(m_execBarriers, oldAttachment, m_rtLayouts.color[i]); this->transitionColorAttachment(oldAttachment, m_rtLayouts.color[i]);
} }
} }
@ -5046,7 +5043,7 @@ namespace dxvk {
if (found) if (found)
layouts.depth = m_rtLayouts.depth; layouts.depth = m_rtLayouts.depth;
else if (m_flags.test(DxvkContextFlag::GpRenderPassSuspended)) else if (m_flags.test(DxvkContextFlag::GpRenderPassSuspended))
this->transitionDepthAttachment(m_execBarriers, oldAttachment, m_rtLayouts.depth); this->transitionDepthAttachment(oldAttachment, m_rtLayouts.depth);
} }
m_rtLayouts = layouts; m_rtLayouts = layouts;
@ -5054,7 +5051,6 @@ namespace dxvk {
void DxvkContext::prepareImage( void DxvkContext::prepareImage(
DxvkBarrierSet& barriers,
const Rc<DxvkImage>& image, const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources, const VkImageSubresourceRange& subresources,
bool flushClears) { bool flushClears) {
@ -5082,7 +5078,7 @@ namespace dxvk {
if (attachment.view != nullptr && attachment.view->image() == image if (attachment.view != nullptr && attachment.view->image() == image
&& (is3D || vk::checkSubresourceRangeOverlap(attachment.view->subresources(), subresources))) { && (is3D || vk::checkSubresourceRangeOverlap(attachment.view->subresources(), subresources))) {
this->transitionColorAttachment(barriers, attachment, m_rtLayouts.color[i]); this->transitionColorAttachment(attachment, m_rtLayouts.color[i]);
m_rtLayouts.color[i] = image->info().layout; m_rtLayouts.color[i] = image->info().layout;
} }
} }
@ -5091,7 +5087,7 @@ namespace dxvk {
if (attachment.view != nullptr && attachment.view->image() == image if (attachment.view != nullptr && attachment.view->image() == image
&& (is3D || vk::checkSubresourceRangeOverlap(attachment.view->subresources(), subresources))) { && (is3D || vk::checkSubresourceRangeOverlap(attachment.view->subresources(), subresources))) {
this->transitionDepthAttachment(barriers, attachment, m_rtLayouts.depth); this->transitionDepthAttachment(attachment, m_rtLayouts.depth);
m_rtLayouts.depth = image->info().layout; m_rtLayouts.depth = image->info().layout;
} }
} }

View File

@ -1346,16 +1346,13 @@ namespace dxvk {
void applyRenderTargetStoreLayouts(); void applyRenderTargetStoreLayouts();
void transitionRenderTargetLayouts( void transitionRenderTargetLayouts(
DxvkBarrierSet& barriers,
bool sharedOnly); bool sharedOnly);
void transitionColorAttachment( void transitionColorAttachment(
DxvkBarrierSet& barriers,
const DxvkAttachment& attachment, const DxvkAttachment& attachment,
VkImageLayout oldLayout); VkImageLayout oldLayout);
void transitionDepthAttachment( void transitionDepthAttachment(
DxvkBarrierSet& barriers,
const DxvkAttachment& attachment, const DxvkAttachment& attachment,
VkImageLayout oldLayout); VkImageLayout oldLayout);
@ -1364,7 +1361,6 @@ namespace dxvk {
const DxvkFramebufferInfo& oldFb); const DxvkFramebufferInfo& oldFb);
void prepareImage( void prepareImage(
DxvkBarrierSet& barriers,
const Rc<DxvkImage>& image, const Rc<DxvkImage>& image,
const VkImageSubresourceRange& subresources, const VkImageSubresourceRange& subresources,
bool flushClears = true); bool flushClears = true);