From 64b782f62988a7712e682dfeb06e3f0ff3113bfd Mon Sep 17 00:00:00 2001 From: sean Date: Sat, 2 Mar 2024 12:30:49 +0100 Subject: [PATCH] Fix: Test PVRTC extension and always use power-of-two dimensions --- .../framework/vulkan/vkImageUtil.cpp | 19 +++++++++++++++++ .../framework/vulkan/vkImageUtil.hpp | 1 + ...vktApiMemoryRequirementInvarianceTests.cpp | 21 ++++++++++++++----- .../vulkancts/modules/vulkan/vktTestCase.cpp | 1 + framework/delibs/debase/deInt32.h | 6 +++--- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.cpp b/external/vulkancts/framework/vulkan/vkImageUtil.cpp index c2953bd851..c55a54a2e6 100644 --- a/external/vulkancts/framework/vulkan/vkImageUtil.cpp +++ b/external/vulkancts/framework/vulkan/vkImageUtil.cpp @@ -474,6 +474,25 @@ bool isPvrtcFormat (VkFormat format) return false; } +bool isPvrtc1Format (VkFormat format) +{ +#ifndef CTS_USES_VULKANSC + switch (format) + { + case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: + return true; + default: + return false; + } +#else + DE_UNREF(format); +#endif + return false; +} + const std::map spirvFormats = { { VK_FORMAT_R32G32B32A32_SFLOAT, "Rgba32f" }, { VK_FORMAT_R32G32_SFLOAT, "Rg32f" }, diff --git a/external/vulkancts/framework/vulkan/vkImageUtil.hpp b/external/vulkancts/framework/vulkan/vkImageUtil.hpp index 7ecb53dcd1..fe13d883ef 100644 --- a/external/vulkancts/framework/vulkan/vkImageUtil.hpp +++ b/external/vulkancts/framework/vulkan/vkImageUtil.hpp @@ -176,6 +176,7 @@ bool isYCbCrFormat (VkFormat format); bool isYCbCrExtensionFormat (VkFormat format); bool isYCbCrConversionFormat (VkFormat format); bool isPvrtcFormat (VkFormat format); +bool isPvrtc1Format (VkFormat format); PlanarFormatDescription getPlanarFormatDescription (VkFormat format); int getPlaneCount (VkFormat format); deUint32 getMipmapCount (VkFormat format, diff --git a/external/vulkancts/modules/vulkan/api/vktApiMemoryRequirementInvarianceTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiMemoryRequirementInvarianceTests.cpp index 6e2723fe35..5c87e911df 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiMemoryRequirementInvarianceTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiMemoryRequirementInvarianceTests.cpp @@ -180,12 +180,23 @@ ImageAllocator::ImageAllocator (deRandom& random, deBool dedicated, std::vector< else m_colorFormat = (VkFormat)optimalformats[deRandom_getUint32(&random) % optimalformats.size()]; - int widthAlignment = (isYCbCr420Format(m_colorFormat) || isYCbCr422Format(m_colorFormat)) ? 2 : 1; - int heightAlignment = isYCbCr420Format(m_colorFormat) ? 2 : 1; + if (isPvrtc1Format(m_colorFormat)) + { + // See VUID-VkImageCreateInfo-format-09583 and VUID-VkImageCreateInfo-format-09584 + // PVRTC1 textures have to have both a width and height that is a power of 2. + m_size = tcu::IVec2(1 << (deRandom_getUint32(&random) % 4 + 1), + 1 << (deRandom_getUint32(&random) % 4 + 1)); + } + else + { + int widthAlignment = (isYCbCr420Format(m_colorFormat) || isYCbCr422Format(m_colorFormat)) ? 2 : 1; + int heightAlignment = isYCbCr420Format(m_colorFormat) ? 2 : 1; + + // Random small size for causing potential alignment issues + m_size = tcu::IVec2((deRandom_getUint32(&random) % 16 + 3) & ~(widthAlignment - 1), + (deRandom_getUint32(&random) % 16 + 3) & ~(heightAlignment - 1)); + } - // Random small size for causing potential alignment issues - m_size = tcu::IVec2((deRandom_getUint32(&random) % 16 + 3) & ~(widthAlignment - 1), - (deRandom_getUint32(&random) % 16 + 3) & ~(heightAlignment - 1)); // Pick random memory type from the supported set m_memoryType = memoryTypes[deRandom_getUint32(&random) % memoryTypes.size()]; } diff --git a/external/vulkancts/modules/vulkan/vktTestCase.cpp b/external/vulkancts/modules/vulkan/vktTestCase.cpp index 4ab6fb5f90..eccc430351 100644 --- a/external/vulkancts/modules/vulkan/vktTestCase.cpp +++ b/external/vulkancts/modules/vulkan/vktTestCase.cpp @@ -103,6 +103,7 @@ vector filterExtensions (const vector& extensions "VK_NV_representative_fragment_test", "VK_NV_shader_atomic_float16_vector", "VK_MVK_macos_surface", + "VK_IMG_format_pvrtc" }; const char* exclusions[] = diff --git a/framework/delibs/debase/deInt32.h b/framework/delibs/debase/deInt32.h index 10a7468f85..5532790ed6 100644 --- a/framework/delibs/debase/deInt32.h +++ b/framework/delibs/debase/deInt32.h @@ -248,7 +248,7 @@ DE_INLINE deBool deIsPowerOfTwoSize (size_t a) } /*--------------------------------------------------------------------*//*! - * \brief Roud a value up to a power-of-two. + * \brief Round a value up to a power-of-two. * \param a Input value. * \return Smallest power-of-two value that is greater or equal to an input value. *//*--------------------------------------------------------------------*/ @@ -264,7 +264,7 @@ DE_INLINE deUint32 deSmallestGreaterOrEquallPowerOfTwoU32 (deUint32 a) } /*--------------------------------------------------------------------*//*! - * \brief Roud a value up to a power-of-two. + * \brief Round a value up to a power-of-two. * \param a Input value. * \return Smallest power-of-two value that is greater or equal to an input value. *//*--------------------------------------------------------------------*/ @@ -281,7 +281,7 @@ DE_INLINE deUint64 deSmallestGreaterOrEquallPowerOfTwoU64 (deUint64 a) } /*--------------------------------------------------------------------*//*! - * \brief Roud a value up to a power-of-two. + * \brief Round a value up to a power-of-two. * \param a Input value. * \return Smallest power-of-two value that is greater or equal to an input value. *//*--------------------------------------------------------------------*/