From e611dff45e405cb0262b43da12eab466fad2e9ac Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 18 Jul 2019 16:43:19 +0200 Subject: [PATCH] [dxvk] Support depth-stencil meta-copy operations --- src/dxvk/dxvk_context.cpp | 20 ++++++++++++++++---- src/dxvk/dxvk_meta_copy.cpp | 12 +++++++----- src/dxvk/dxvk_meta_copy.h | 8 +++++--- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index fff8afbe..fb00417a 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -2740,18 +2740,24 @@ namespace dxvk { srcViewInfo.type = viewType; srcViewInfo.format = srcImage->info().format; srcViewInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT; - srcViewInfo.aspect = srcSubresource.aspectMask; + srcViewInfo.aspect = srcSubresource.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_COLOR_BIT); srcViewInfo.minLevel = srcSubresource.mipLevel; srcViewInfo.numLevels = 1; srcViewInfo.minLayer = srcSubresource.baseArrayLayer; srcViewInfo.numLayers = srcSubresource.layerCount; - auto tgtImageView = m_device->createImageView(tgtImage, tgtViewInfo); - auto srcImageView = m_device->createImageView(srcImage, srcViewInfo); + Rc tgtImageView = m_device->createImageView(tgtImage, tgtViewInfo); + Rc srcImageView = m_device->createImageView(srcImage, srcViewInfo); + Rc srcStencilView; + + if (srcSubresource.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { + srcViewInfo.aspect = VK_IMAGE_ASPECT_STENCIL_BIT; + srcStencilView = m_device->createImageView(srcImage, srcViewInfo); + } // Create framebuffer and pipeline for the copy Rc fb = new DxvkMetaCopyRenderPass( - m_device->vkd(), tgtImageView, srcImageView, + m_device->vkd(), tgtImageView, srcImageView, srcStencilView, tgtImage->isFullSubresource(tgtSubresource, extent)); auto pipeInfo = m_metaCopy->getPipeline( @@ -2775,6 +2781,12 @@ namespace dxvk { descriptorWrite.dstSet = allocateDescriptorSet(pipeInfo.dsetLayout); m_cmd->updateDescriptorSets(1, &descriptorWrite); + + if (srcSubresource.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) { + descriptorImage.imageView = srcStencilView->handle(); + descriptorWrite.dstBinding = 1; + m_cmd->updateDescriptorSets(1, &descriptorWrite); + } VkViewport viewport; viewport.x = float(tgtOffset.x); diff --git a/src/dxvk/dxvk_meta_copy.cpp b/src/dxvk/dxvk_meta_copy.cpp index 9ae8d3ea..c3b0d775 100644 --- a/src/dxvk/dxvk_meta_copy.cpp +++ b/src/dxvk/dxvk_meta_copy.cpp @@ -19,12 +19,14 @@ namespace dxvk { const Rc& vkd, const Rc& dstImageView, const Rc& srcImageView, + const Rc& srcStencilView, bool discardDst) - : m_vkd (vkd), - m_dstImageView(dstImageView), - m_srcImageView(srcImageView), - m_renderPass (createRenderPass(discardDst)), - m_framebuffer (createFramebuffer()) { + : m_vkd (vkd), + m_dstImageView (dstImageView), + m_srcImageView (srcImageView), + m_srcStencilView(srcStencilView), + m_renderPass (createRenderPass(discardDst)), + m_framebuffer (createFramebuffer()) { } diff --git a/src/dxvk/dxvk_meta_copy.h b/src/dxvk/dxvk_meta_copy.h index 63ffea42..952323c1 100644 --- a/src/dxvk/dxvk_meta_copy.h +++ b/src/dxvk/dxvk_meta_copy.h @@ -63,6 +63,7 @@ namespace dxvk { const Rc& vkd, const Rc& dstImageView, const Rc& srcImageView, + const Rc& srcStencilView, bool discardDst); ~DxvkMetaCopyRenderPass(); @@ -77,10 +78,11 @@ namespace dxvk { private: - const Rc m_vkd; + Rc m_vkd; - const Rc m_dstImageView; - const Rc m_srcImageView; + Rc m_dstImageView; + Rc m_srcImageView; + Rc m_srcStencilView; VkRenderPass m_renderPass = VK_NULL_HANDLE; VkFramebuffer m_framebuffer = VK_NULL_HANDLE;