Commit 2d5bbdc4 by Nicolas Capens Committed by Nicolas Capens

Assert multisample resolve has equal input and output formats

While our generic Blitter routine can handle resolving any multisample format into any other format, the 'fastResolve()' method performs simple per-component sample averaging, thus assuming the input and output formats are identical. This is also demanded by the Vulkan specification: - vkCmdResolveImage: "srcImage and dstImage must have been created with the same image format." - VkSubpassDescription: "each resolve attachment that is not VK_ATTACHMENT_UNUSED must have the same VkFormat as its corresponding color attachment." This change adds an assert which would catch violations of that. Bug: b/147802090 Change-Id: I23d2d463efbbaed04a782a0cf61b255bf1c25b03 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48088 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent efbc5caf
...@@ -1882,6 +1882,17 @@ void Blitter::blit(const vk::Image *src, vk::Image *dst, VkImageBlit region, VkF ...@@ -1882,6 +1882,17 @@ void Blitter::blit(const vk::Image *src, vk::Image *dst, VkImageBlit region, VkF
void Blitter::resolve(const vk::Image *src, vk::Image *dst, VkImageResolve region) void Blitter::resolve(const vk::Image *src, vk::Image *dst, VkImageResolve region)
{ {
// "The aspectMask member of srcSubresource and dstSubresource must only contain VK_IMAGE_ASPECT_COLOR_BIT"
ASSERT(region.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
ASSERT(region.dstSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
// "The layerCount member of srcSubresource and dstSubresource must match"
ASSERT(region.srcSubresource.layerCount == region.dstSubresource.layerCount);
// We use this method both for explicit resolves from vkCmdResolveImage, and implicit ones for resolve attachments.
// - vkCmdResolveImage: "srcImage and dstImage must have been created with the same image format."
// - VkSubpassDescription: "each resolve attachment that is not VK_ATTACHMENT_UNUSED must have the same VkFormat as its corresponding color attachment."
ASSERT(src->getFormat() == dst->getFormat());
if(fastResolve(src, dst, region)) if(fastResolve(src, dst, region))
{ {
return; return;
...@@ -1913,11 +1924,6 @@ static inline uint32_t averageByte4(uint32_t x, uint32_t y) ...@@ -1913,11 +1924,6 @@ static inline uint32_t averageByte4(uint32_t x, uint32_t y)
bool Blitter::fastResolve(const vk::Image *src, vk::Image *dst, VkImageResolve region) bool Blitter::fastResolve(const vk::Image *src, vk::Image *dst, VkImageResolve region)
{ {
// "The aspectMask member of srcSubresource and dstSubresource must only contain VK_IMAGE_ASPECT_COLOR_BIT"
ASSERT(region.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
ASSERT(region.dstSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
ASSERT(region.srcSubresource.layerCount == region.dstSubresource.layerCount);
if(region.dstOffset != VkOffset3D{ 0, 0, 0 }) if(region.dstOffset != VkOffset3D{ 0, 0, 0 })
{ {
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment