diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 7c2d3a81..755c94f0 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -330,6 +330,35 @@ namespace dxvk { } + void DxvkContext::changeImageLayout( + const Rc& image, + VkImageLayout layout) { + if (image->info().layout != layout) { + this->spillRenderPass(); + + VkImageSubresourceRange subresources; + subresources.aspectMask = image->formatInfo()->aspectMask; + subresources.baseArrayLayer = 0; + subresources.baseMipLevel = 0; + subresources.layerCount = image->info().numLayers; + subresources.levelCount = image->info().mipLevels; + + if (m_barriers.isImageDirty(image, subresources, DxvkAccess::Write)) + m_barriers.recordCommands(m_cmd); + + m_barriers.accessImage(image, subresources, + image->info().layout, + image->info().stages, + image->info().access, + layout, + image->info().layout, + image->info().stages); + + image->setLayout(layout); + } + } + + void DxvkContext::clearBuffer( const Rc& buffer, VkDeviceSize offset, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 9daf2b4c..2a369a05 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -212,6 +212,18 @@ namespace dxvk { const VkImageBlit& region, VkFilter filter); + /** + * \brief Changes image layout + * + * Permanently changes the layout for a given + * image. Immediately performs the transition. + * \param [in] image The image to transition + * \param [in] layout New image layout + */ + void changeImageLayout( + const Rc& image, + VkImageLayout layout); + /** * \brief Clears a buffer with a fixed value * diff --git a/src/dxvk/dxvk_image.h b/src/dxvk/dxvk_image.h index df06930e..1035a23d 100644 --- a/src/dxvk/dxvk_image.h +++ b/src/dxvk/dxvk_image.h @@ -223,6 +223,14 @@ namespace dxvk { ? VK_IMAGE_LAYOUT_GENERAL : layout; } + /** + * \brief Changes image layout + * \param [in] layout New layout + */ + void setLayout(VkImageLayout layout) { + m_info.layout = layout; + } + /** * \brief Checks whether a subresource is entirely covered *