From: Oivind Boge Date: Tue, 16 May 2017 14:04:01 +0000 (+0200) Subject: Fixed invalid usage of VkBufferImageCopy struct X-Git-Tag: upstream/0.1.0~9^2~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83bc8cd7cd72732e96b68476a00b3cd35f350d8b;p=platform%2Fupstream%2FVK-GL-CTS.git Fixed invalid usage of VkBufferImageCopy struct The offset member of VkBufferImageCopy was violating the valid usage. The offset is now calculated using lowest common denominator between the pixelSize and 4. Affects: dEQP-VK.api.image_clearing.* Components: Vulkan VK-GL-CTS issue: 422 Change-Id: I1ef07e06f790a9ed403941b1d94c7840485cec3e --- diff --git a/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp index e63bc72..08f1baa 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiImageClearingTests.cpp @@ -74,6 +74,27 @@ deUint32 getNumMipLevels (const VkExtent3D& baseExtent, const deUint32 maxMipLev return std::min(static_cast(deFloatLog2(static_cast(widestEdge))) + 1u, maxMipLevels); } +deUint32 greatestCommonDivisor (const deUint32 a, const deUint32 b) +{ + /* Find GCD */ + deUint32 temp; + deUint32 x=a; + deUint32 y=b; + + while (x%b != 0) + { + temp = y; + y = x%y; + x = temp; + } + return y; +} + +deUint32 lowestCommonMultiple (const deUint32 a, const deUint32 b) +{ + return (a*b)/greatestCommonDivisor(a,b); +} + std::vector getImageMipLevelSizes (const deUint32 pixelSize, const VkExtent3D& baseExtent, const deUint32 numMipLevels, const deUint32 perLevelAlignment = 1u) { std::vector results(numMipLevels); @@ -81,7 +102,8 @@ std::vector getImageMipLevelSizes (const deUint32 pixelSize, const VkE for (deUint32 mipLevel = 0; mipLevel < numMipLevels; ++mipLevel) { const VkExtent3D extent = getMipLevelExtent(baseExtent, mipLevel); - results[mipLevel] = static_cast(deAlignSize(extent.width * extent.height * extent.depth * pixelSize, perLevelAlignment)); + results[mipLevel] = static_cast(extent.width * extent.height * extent.depth * pixelSize); + results[mipLevel] = ((results[mipLevel] + perLevelAlignment-1) / perLevelAlignment) * perLevelAlignment; } return results; @@ -772,7 +794,11 @@ de::MovePtr ImageClearingTestInstance::readImage (VkImageAs aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT ? getStencilCopyFormat(m_params.imageFormat) : TextureFormat(); const deUint32 pixelSize = getPixelSize(tcuFormat); - const deUint32 alignment = 4; // subsequent mip levels aligned to 4 bytes + deUint32 alignment = 4; // subsequent mip levels aligned to 4 bytes + + if (!getIsDepthFormat(m_params.imageFormat) && !getIsStencilFormat(m_params.imageFormat)) + alignment = lowestCommonMultiple(pixelSize, alignment); // alignment must be multiple of pixel size, if not D/S. + const std::vector mipLevelSizes = getImageMipLevelSizes(pixelSize, m_params.imageExtent, m_imageMipLevels, alignment); const VkDeviceSize imageTotalSize = std::accumulate(mipLevelSizes.begin(), mipLevelSizes.end(), 0u);