|
|
@ -1532,12 +1532,17 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, |
|
|
|
|
|
|
|
|
// Handle MSAA upload if necessary
|
|
|
// Handle MSAA upload if necessary
|
|
|
if (info.num_samples > 1 && runtime->CanUploadMSAA()) { |
|
|
if (info.num_samples > 1 && runtime->CanUploadMSAA()) { |
|
|
|
|
|
// Only use MSAA copy pass for color formats
|
|
|
|
|
|
// Depth/stencil formats need special handling
|
|
|
|
|
|
if (aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) { |
|
|
// Create a temporary non-MSAA image to upload the data first
|
|
|
// Create a temporary non-MSAA image to upload the data first
|
|
|
ImageInfo temp_info = info; |
|
|
ImageInfo temp_info = info; |
|
|
temp_info.num_samples = 1; |
|
|
temp_info.num_samples = 1; |
|
|
|
|
|
|
|
|
vk::Image temp_image = MakeImage(runtime->device, runtime->memory_allocator, temp_info, |
|
|
|
|
|
runtime->ViewFormats(info.format)); |
|
|
|
|
|
|
|
|
// Create image with same usage flags as the target image to avoid validation errors
|
|
|
|
|
|
VkImageCreateInfo image_ci = MakeImageCreateInfo(runtime->device, temp_info); |
|
|
|
|
|
image_ci.usage = original_image.UsageFlags(); |
|
|
|
|
|
vk::Image temp_image = runtime->memory_allocator.CreateImage(image_ci); |
|
|
|
|
|
|
|
|
// Upload to the temporary non-MSAA image
|
|
|
// Upload to the temporary non-MSAA image
|
|
|
scheduler->RequestOutsideRenderPassOperationContext(); |
|
|
scheduler->RequestOutsideRenderPassOperationContext(); |
|
|
@ -1571,6 +1576,9 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset, |
|
|
// Use MSAACopyPass to convert from non-MSAA to MSAA
|
|
|
// Use MSAACopyPass to convert from non-MSAA to MSAA
|
|
|
runtime->msaa_copy_pass->CopyImage(*this, temp_wrapper, image_copies, false); |
|
|
runtime->msaa_copy_pass->CopyImage(*this, temp_wrapper, image_copies, false); |
|
|
std::exchange(initialized, true); |
|
|
std::exchange(initialized, true); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// For depth/stencil formats, fall back to regular upload
|
|
|
} else { |
|
|
} else { |
|
|
// Regular non-MSAA upload
|
|
|
// Regular non-MSAA upload
|
|
|
scheduler->RequestOutsideRenderPassOperationContext(); |
|
|
scheduler->RequestOutsideRenderPassOperationContext(); |
|
|
@ -1614,12 +1622,17 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<size_t> o |
|
|
|
|
|
|
|
|
// Handle MSAA download if necessary
|
|
|
// Handle MSAA download if necessary
|
|
|
if (info.num_samples > 1 && runtime->msaa_copy_pass) { |
|
|
if (info.num_samples > 1 && runtime->msaa_copy_pass) { |
|
|
|
|
|
// Only use MSAA copy pass for color formats
|
|
|
|
|
|
// Depth/stencil formats need special handling
|
|
|
|
|
|
if (aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT) { |
|
|
// Create a temporary non-MSAA image to download the data
|
|
|
// Create a temporary non-MSAA image to download the data
|
|
|
ImageInfo temp_info = info; |
|
|
ImageInfo temp_info = info; |
|
|
temp_info.num_samples = 1; |
|
|
temp_info.num_samples = 1; |
|
|
|
|
|
|
|
|
vk::Image temp_image = MakeImage(runtime->device, runtime->memory_allocator, temp_info, |
|
|
|
|
|
runtime->ViewFormats(info.format)); |
|
|
|
|
|
|
|
|
// Create image with same usage flags as the target image to avoid validation errors
|
|
|
|
|
|
VkImageCreateInfo image_ci = MakeImageCreateInfo(runtime->device, temp_info); |
|
|
|
|
|
image_ci.usage = original_image.UsageFlags(); |
|
|
|
|
|
vk::Image temp_image = runtime->memory_allocator.CreateImage(image_ci); |
|
|
|
|
|
|
|
|
// Create a wrapper Image for the temporary image
|
|
|
// Create a wrapper Image for the temporary image
|
|
|
Image temp_wrapper(*runtime, temp_info, 0, 0); |
|
|
Image temp_wrapper(*runtime, temp_info, 0, 0); |
|
|
@ -1709,6 +1722,9 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<size_t> o |
|
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
|
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
|
|
0, memory_write_barrier, nullptr, image_write_barrier); |
|
|
0, memory_write_barrier, nullptr, image_write_barrier); |
|
|
}); |
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// For depth/stencil formats, fall back to regular download
|
|
|
} else { |
|
|
} else { |
|
|
// Regular non-MSAA download
|
|
|
// Regular non-MSAA download
|
|
|
boost::container::small_vector<VkBuffer, 8> buffers_vector{}; |
|
|
boost::container::small_vector<VkBuffer, 8> buffers_vector{}; |
|
|
|