@@ -763,110 +763,6 @@ bool vkIsBitCompatibleColorDepthFormat(VkFormat format1, VkFormat format2)
763
763
return false ;
764
764
}
765
765
766
- void VulkanRenderer::surfaceCopy_viaBuffer (LatteTextureVk* srcTextureVk, sint32 texSrcMip, sint32 texSrcSlice, LatteTextureVk* dstTextureVk, sint32 texDstMip, sint32 texDstSlice, sint32 effectiveCopyWidth, sint32 effectiveCopyHeight)
767
- {
768
- cemu_assert_debug (false ); // not used currently
769
-
770
- cemu_assert_debug (m_featureControl.mode .useBufferSurfaceCopies );
771
-
772
- if (srcTextureVk->dim == Latte::E_DIM::DIM_3D)
773
- {
774
- cemu_assert_debug (false );
775
- return ;
776
- }
777
- if (dstTextureVk->dim == Latte::E_DIM::DIM_3D)
778
- {
779
- cemu_assert_debug (false );
780
- return ;
781
- }
782
-
783
- draw_endRenderPass ();
784
-
785
- // calculate buffer size required for copy
786
- VkDeviceSize copySize = std::max (srcTextureVk->getAllocation ()->getAllocationSize (), dstTextureVk->getAllocation ()->getAllocationSize ());
787
-
788
- // make sure allocated buffer is large enough
789
- if (m_surfaceCopyBuffer == VK_NULL_HANDLE || copySize > m_surfaceCopyBufferSize)
790
- {
791
- if (m_surfaceCopyBuffer != VK_NULL_HANDLE)
792
- {
793
- // free existing buffer
794
- destroyDeviceMemory (m_surfaceCopyBufferMemory);
795
- m_surfaceCopyBufferMemory = VK_NULL_HANDLE;
796
- destroyBuffer (m_surfaceCopyBuffer);
797
- m_surfaceCopyBuffer = VK_NULL_HANDLE;
798
- }
799
- VkDeviceSize allocSize = (copySize + 1024ull * 1024ull - 1ull ) & ~(1024ull * 1024ull - 1ull ); // align to whole MB
800
- m_surfaceCopyBufferSize = allocSize;
801
- memoryManager->CreateBuffer (m_surfaceCopyBufferSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, m_surfaceCopyBuffer, m_surfaceCopyBufferMemory);
802
- if (m_surfaceCopyBuffer == VK_NULL_HANDLE)
803
- {
804
- cemuLog_log (LogType::Force, " Vulkan: Failed to allocate surface copy buffer with size {}" , allocSize);
805
- return ;
806
- }
807
- }
808
- if (m_surfaceCopyBuffer == VK_NULL_HANDLE)
809
- return ;
810
-
811
- auto vkObjSrcTexture = srcTextureVk->GetImageObj ();
812
- auto vkObjDstTexture = dstTextureVk->GetImageObj ();
813
- vkObjSrcTexture->flagForCurrentCommandBuffer ();
814
- vkObjDstTexture->flagForCurrentCommandBuffer ();
815
-
816
- VkBufferImageCopy region{};
817
- region.bufferOffset = 0 ;
818
- region.bufferRowLength = effectiveCopyWidth;
819
- region.bufferImageHeight = effectiveCopyHeight;
820
-
821
- if (srcTextureVk->isDepth )
822
- region.imageSubresource .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
823
- else
824
- region.imageSubresource .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
825
- region.imageSubresource .baseArrayLayer = texSrcSlice;
826
- region.imageSubresource .layerCount = 1 ;
827
- region.imageSubresource .mipLevel = texSrcMip;
828
-
829
- region.imageOffset = { 0 ,0 ,0 };
830
- region.imageExtent = { (uint32)effectiveCopyWidth, (uint32)effectiveCopyHeight, 1 };
831
-
832
- // make sure all write operations to the src image have finished
833
- barrier_image<SYNC_OP::IMAGE_WRITE | SYNC_OP::ANY_TRANSFER, SYNC_OP::ANY_TRANSFER>(srcTextureVk, region.imageSubresource , VK_IMAGE_LAYOUT_GENERAL);
834
-
835
- vkCmdCopyImageToBuffer (getCurrentCommandBuffer (), vkObjSrcTexture->m_image , VK_IMAGE_LAYOUT_GENERAL, m_surfaceCopyBuffer, 1 , ®ion);
836
-
837
- // copy buffer to image
838
-
839
- VkBufferImageCopy imageRegion[2 ]{};
840
- sint32 imageRegionCount = 0 ;
841
-
842
- // color or depth only copy
843
- imageRegion[0 ].bufferOffset = 0 ;
844
- imageRegion[0 ].imageExtent .width = effectiveCopyWidth;
845
- imageRegion[0 ].imageExtent .height = effectiveCopyHeight;
846
- imageRegion[0 ].imageExtent .depth = 1 ;
847
-
848
- imageRegion[0 ].imageSubresource .mipLevel = texDstMip;
849
- if (dstTextureVk->isDepth )
850
- imageRegion[0 ].imageSubresource .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
851
- else
852
- imageRegion[0 ].imageSubresource .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
853
- imageRegion[0 ].imageSubresource .baseArrayLayer = texDstSlice;
854
- imageRegion[0 ].imageSubresource .layerCount = 1 ;
855
-
856
- imageRegionCount = 1 ;
857
-
858
- // make sure the transfer to the buffer finished
859
- barrier_bufferRange<SYNC_OP::ANY_TRANSFER, SYNC_OP::ANY_TRANSFER>(m_surfaceCopyBuffer, 0 , VK_WHOLE_SIZE);
860
-
861
- // make sure all read and write operations to the dst image have finished
862
- barrier_image<SYNC_OP::IMAGE_READ | SYNC_OP::IMAGE_WRITE | SYNC_OP::ANY_TRANSFER, SYNC_OP::ANY_TRANSFER>(dstTextureVk, imageRegion[0 ].imageSubresource , VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
863
-
864
- vkCmdCopyBufferToImage (m_state.currentCommandBuffer , m_surfaceCopyBuffer, vkObjDstTexture->m_image , VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, imageRegionCount, imageRegion);
865
-
866
- // make sure transfer has finished before any other operation
867
- barrier_image<SYNC_OP::ANY_TRANSFER, SYNC_OP::ANY_TRANSFER | SYNC_OP::IMAGE_READ | SYNC_OP::IMAGE_WRITE>(dstTextureVk, imageRegion[0 ].imageSubresource , VK_IMAGE_LAYOUT_GENERAL);
868
- }
869
-
870
766
void VulkanRenderer::surfaceCopy_copySurfaceWithFormatConversion (LatteTexture* sourceTexture, sint32 srcMip, sint32 srcSlice, LatteTexture* destinationTexture, sint32 dstMip, sint32 dstSlice, sint32 width, sint32 height)
871
767
{
872
768
// scale copy size to effective size
@@ -899,28 +795,7 @@ void VulkanRenderer::surfaceCopy_copySurfaceWithFormatConversion(LatteTexture* s
899
795
return ;
900
796
}
901
797
902
- VkFormat srcFormatVk = srcTextureVk->GetFormat ();
903
- VkFormat dstFormatVk = dstTextureVk->GetFormat ();
904
-
905
- if ((srcTextureVk->isDepth && !dstTextureVk->isDepth ) ||
906
- !srcTextureVk->isDepth && dstTextureVk->isDepth )
907
- {
908
- // depth to color or
909
- // color to depth
910
- if (m_featureControl.mode .useBufferSurfaceCopies && vkIsBitCompatibleColorDepthFormat (srcFormatVk, dstFormatVk))
911
- surfaceCopy_viaBuffer (srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight);
912
- else
913
- surfaceCopy_viaDrawcall (srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight);
914
- }
915
- else
916
- {
917
- // depth to depth or
918
- // color to color
919
- if (m_featureControl.mode .useBufferSurfaceCopies && srcFormatVk == dstFormatVk)
920
- surfaceCopy_viaBuffer (srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight);
921
- else
922
- surfaceCopy_viaDrawcall (srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight);
923
- }
798
+ surfaceCopy_viaDrawcall (srcTextureVk, texSrcMip, texSrcSlice, dstTextureVk, texDstMip, texDstSlice, effectiveCopyWidth, effectiveCopyHeight);
924
799
}
925
800
926
801
// called whenever a texture is destroyed
0 commit comments