diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 708d5262..0c8353a7 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -801,25 +801,22 @@ namespace dxvk { cSrcImage, cSrcLayers, VkOffset3D { 0, 0, 0 }, cDstImage->mipLevelExtent(cDstLayers.mipLevel)); }); - } else if (!srcFormatInfo.flags.test(DxgiFormatFlag::Typeless) - && !dstFormatInfo.flags.test(DxgiFormatFlag::Typeless)) { - if (dstDesc.Format != srcDesc.Format) { - Logger::err("D3D11: ResolveSubresource: Incompatible formats"); - return; - } + } else { + const VkFormat format = m_parent->LookupFormat( + Format, DxgiFormatMode::Any).format; EmitCs([ cDstImage = dstTextureInfo->image, cSrcImage = srcTextureInfo->image, cDstSubres = dstSubresourceLayers, - cSrcSubres = srcSubresourceLayers + cSrcSubres = srcSubresourceLayers, + cFormat = format ] (DxvkContext* ctx) { ctx->resolveImage( cDstImage, cDstSubres, - cSrcImage, cSrcSubres); + cSrcImage, cSrcSubres, + cFormat); }); - } else { - Logger::err("D3D11: ResolveSubresource with typeless images currently not supported"); } } diff --git a/src/dxgi/dxgi_presenter.cpp b/src/dxgi/dxgi_presenter.cpp index b2d137fd..d8515807 100644 --- a/src/dxgi/dxgi_presenter.cpp +++ b/src/dxgi/dxgi_presenter.cpp @@ -171,7 +171,8 @@ namespace dxvk { if (m_backBufferResolve != nullptr) { m_context->resolveImage( m_backBufferResolve, resolveSubresources, - m_backBuffer, resolveSubresources); + m_backBuffer, resolveSubresources, + VK_FORMAT_UNDEFINED); } const DxvkSwapSemaphores sem = m_swapchain->getSemaphorePair(); diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 3764ed5d..05ae0f7f 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -897,9 +897,13 @@ namespace dxvk { const Rc& dstImage, const VkImageSubresourceLayers& dstSubresources, const Rc& srcImage, - const VkImageSubresourceLayers& srcSubresources) { + const VkImageSubresourceLayers& srcSubresources, + VkFormat format) { this->renderPassEnd(); - + + if (format == VK_FORMAT_UNDEFINED) + format = srcImage->info().format; + VkImageSubresourceRange dstSubresourceRange = { dstSubresources.aspectMask, dstSubresources.mipLevel, 1, @@ -932,19 +936,24 @@ namespace dxvk { VK_ACCESS_TRANSFER_READ_BIT); m_barriers.recordCommands(m_cmd); - VkImageResolve imageRegion; - imageRegion.srcSubresource = srcSubresources; - imageRegion.srcOffset = VkOffset3D { 0, 0, 0 }; - imageRegion.dstSubresource = dstSubresources; - imageRegion.dstOffset = VkOffset3D { 0, 0, 0 }; - imageRegion.extent = srcImage->mipLevelExtent(srcSubresources.mipLevel); - - m_cmd->cmdResolveImage( - srcImage->handle(), - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - dstImage->handle(), - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, &imageRegion); + if (srcImage->info().format == format + && dstImage->info().format == format) { + VkImageResolve imageRegion; + imageRegion.srcSubresource = srcSubresources; + imageRegion.srcOffset = VkOffset3D { 0, 0, 0 }; + imageRegion.dstSubresource = dstSubresources; + imageRegion.dstOffset = VkOffset3D { 0, 0, 0 }; + imageRegion.extent = srcImage->mipLevelExtent(srcSubresources.mipLevel); + + m_cmd->cmdResolveImage( + srcImage->handle(), + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + dstImage->handle(), + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + 1, &imageRegion); + } else { + // TODO implement + } m_barriers.accessImage( dstImage, dstSubresourceRange, diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index f39d9d65..8627aaee 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -405,17 +405,22 @@ namespace dxvk { * * Resolves a multisampled image into a non-multisampled * image. The subresources of both images must have the - * same size and compatible formats + * same size and compatible formats. + * A format can be specified for the resolve operation. + * If it is \c VK_FORMAT_UNDEFINED, the resolve operation + * will use the source image format. * \param [in] dstImage Destination image * \param [in] dstSubresources Subresources to write to * \param [in] srcImage Source image * \param [in] srcSubresources Subresources to read from + * \param [in] format Format for the resolve operation */ void resolveImage( const Rc& dstImage, const VkImageSubresourceLayers& dstSubresources, const Rc& srcImage, - const VkImageSubresourceLayers& srcSubresources); + const VkImageSubresourceLayers& srcSubresources, + VkFormat format); /** * \brief Updates a buffer