MCPcopy Create free account
hub / github.com/baldurk/renderdoc / FillWithDiscardPatternOnHost

Method FillWithDiscardPatternOnHost

renderdoc/driver/vulkan/vk_debug.cpp:2635–2707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2633}
2634
2635void VulkanDebugManager::FillWithDiscardPatternOnHost(VkDevice device, DiscardType type,
2636 VkImage image, VkImageLayout curLayout,
2637 VkImageSubresourceRange discardRange,
2638 VkRect2D discardRect)
2639{
2640 // State tracking will not be accurate during loading
2641 if(IsLoading(m_pDriver->m_State))
2642 return;
2643
2644 const VulkanCreationInfo::Image &imInfo = GetImageInfo(GetResID(image));
2645 const VkImageAspectFlags aspectFlags = discardRange.aspectMask & FormatImageAspects(imInfo.format);
2646
2647 // Not supported for multisampled images.
2648 if(imInfo.samples > 1)
2649 {
2650 RDCWARN("Skipping discard pattern for MSAA image as host copy is unimplemented");
2651 return;
2652 }
2653
2654 VkFormat format = imInfo.format;
2655 if(format == VK_FORMAT_X8_D24_UNORM_PACK32)
2656 format = VK_FORMAT_D24_UNORM_S8_UINT;
2657 if(format == VK_FORMAT_S8_UINT)
2658 format = VK_FORMAT_D32_SFLOAT_S8_UINT;
2659
2660 BlockShape shape = GetBlockShape(format, 0);
2661 if((DiscardPatternWidth % shape.width) != 0 || (DiscardPatternHeight % shape.height) != 0)
2662 {
2663 RDCWARN("Skipping discard pattern for %s as block size is incompatible (%d * %d)",
2664 ToStr(MakeResourceFormat(format).type).c_str(), shape.width, shape.height);
2665 return;
2666 }
2667
2668 bytebuf pattern = GetDiscardPattern(type, MakeResourceFormat(format));
2669
2670 rdcarray<VkBufferImageCopy> mainCopies, stencilCopies;
2671 GetDiscardPatternCopyRegions(imInfo, aspectFlags, discardRange, discardRect, DiscardPatternWidth,
2672 DiscardPatternHeight, mainCopies, stencilCopies);
2673
2674 VkMemoryToImageCopy hostCopy = {
2675 VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY, NULL, pattern.data(),
2676 // The rest of the parameters are copied from `mainCopies` and `stencilCopies`.
2677 };
2678
2679 VkCopyMemoryToImageInfo info = {
2680 VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO, NULL, 0, Unwrap(image), curLayout, 1, &hostCopy,
2681 };
2682
2683 for(const VkBufferImageCopy &copy : mainCopies)
2684 {
2685 hostCopy.memoryRowLength = copy.bufferRowLength;
2686 hostCopy.memoryImageHeight = copy.bufferImageHeight;
2687 hostCopy.imageSubresource = copy.imageSubresource;
2688 hostCopy.imageOffset = copy.imageOffset;
2689 hostCopy.imageExtent = copy.imageExtent;
2690
2691 ObjDisp(device)->CopyMemoryToImage(Unwrap(device), &info);
2692 }

Callers 1

Calls 12

IsLoadingFunction · 0.85
FormatImageAspectsFunction · 0.85
ToStrFunction · 0.85
GetDiscardPatternFunction · 0.85
ObjDispFunction · 0.85
GetResIDFunction · 0.70
GetBlockShapeFunction · 0.70
MakeResourceFormatFunction · 0.70
UnwrapFunction · 0.70
c_strMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected