vkGetImageSubresourceLayout implementation
The Image class now contains all the required functions to fill
out the VkSubresourceLayout structure, so this simply hooks the
proper calls to implement vkGetImageSubresourceLayout.
Bug b/119620767
Change-Id: I104811be4a5be31ef5db7ad55965ba263dd110ed
Reviewed-on: https://swiftshader-review.googlesource.com/c/24051
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index 39c941c..89887a4 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -60,6 +60,16 @@
memoryOffset = pMemoryOffset;
}
+void Image::getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) const
+{
+ uint32_t bpp = bytesPerTexel(flags);
+ pLayout->offset = getMemoryOffset(flags, pSubresource->mipLevel, pSubresource->arrayLayer);
+ pLayout->size = getMipLevelSize(flags, pSubresource->mipLevel);
+ pLayout->rowPitch = rowPitchBytes(flags, pSubresource->mipLevel);
+ pLayout->depthPitch = slicePitchBytes(flags, pSubresource->mipLevel);
+ pLayout->arrayPitch = getLayerSize(flags);
+}
+
void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
{
// Image copy does not perform any conversion, it simply copies memory from
diff --git a/src/Vulkan/VkImage.hpp b/src/Vulkan/VkImage.hpp
index ae263e0..badca58 100644
--- a/src/Vulkan/VkImage.hpp
+++ b/src/Vulkan/VkImage.hpp
@@ -38,6 +38,7 @@
static size_t ComputeRequiredAllocationSize(const VkImageCreateInfo* pCreateInfo);
const VkMemoryRequirements getMemoryRequirements() const;
+ void getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) const;
void bind(VkDeviceMemory pDeviceMemory, VkDeviceSize pMemoryOffset);
void copyTo(VkImage dstImage, const VkImageCopy& pRegion);
void copyTo(VkBuffer dstBuffer, const VkBufferImageCopy& region);
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 63230d7..e222213 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -830,8 +830,10 @@
VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)
{
- TRACE("()");
- UNIMPLEMENTED();
+ TRACE("(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)",
+ device, image, pSubresource, pLayout);
+
+ vk::Cast(image)->getSubresourceLayout(pSubresource, pLayout);
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)