Commit ad65826a by Nicolas Capens Committed by Nicolas Capens

Fix copying of multiple image layers

Only a single layer was being copied in the case of 2D array to 2D array copies. In the case of 2D array to 3D image copies, or vice-versa, the extent depth is the same as the layer count as per the Vulkan requirements, but this relied on the layer pitch to be the same as the slice pitch, which isn't true when layers contain multiple mipmap levels. Both issues have been addressed by adding a loop to iterate over the layers, adjusting the pitch in case a layer is copied to/from a slice. The inner loop for copying slices to slices is used for 3D image to 3D image copies, and for multisample 2D image to multisample 2D image copies (which can also have multiple layers). Also clarify the Image::getLastLayerIndex() and getLastMipLevel() methods should not be used for VkImageSubresourceLayers structures used by copy, blit, and resolve operations (they require explicit layer and level counts). VkImageSubresourceRange is only for image view creation, memory barriers, and clear operations, which accept the use of VK_REMAINING_ARRAY_LAYERS and VK_REMAINING_MIP_LEVELS. Bug: b/159666631 Bug: swiftshader:152 Change-Id: If998795e2b5e55950cc9fa23373a7300b6d2e0fc Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46132 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 avatarAntonio Maiorano <amaiorano@google.com>
parent 2aace0d7
......@@ -65,14 +65,18 @@ public:
void clear(const VkClearColorValue &color, const VkImageSubresourceRange &subresourceRange);
void clear(const VkClearDepthStencilValue &color, const VkImageSubresourceRange &subresourceRange);
// Get the last layer and mipmap level, handling VK_REMAINING_ARRAY_LAYERS and
// VK_REMAINING_MIP_LEVELS, respectively. Note VkImageSubresourceLayers does not
// allow these symbolic values, so only VkImageSubresourceRange is accepted.
uint32_t getLastLayerIndex(const VkImageSubresourceRange &subresourceRange) const;
uint32_t getLastMipLevel(const VkImageSubresourceRange &subresourceRange) const;
VkImageType getImageType() const { return imageType; }
const Format &getFormat() const { return format; }
Format getFormat(VkImageAspectFlagBits aspect) const;
uint32_t getArrayLayers() const { return arrayLayers; }
uint32_t getMipLevels() const { return mipLevels; }
VkImageUsageFlags getUsage() const { return usage; }
uint32_t getLastLayerIndex(const VkImageSubresourceRange &subresourceRange) const;
uint32_t getLastMipLevel(const VkImageSubresourceRange &subresourceRange) const;
VkSampleCountFlagBits getSampleCountFlagBits() const { return samples; }
VkExtent3D getMipLevelExtent(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
int rowPitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
......
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