From cd5bdea66411cc2775806da17e432b2390f7004b Mon Sep 17 00:00:00 2001 From: Marc Alcala Prieto Date: Fri, 18 Nov 2022 16:10:41 +0100 Subject: [PATCH] Fixes for VK_EXT_image_compression_control tests Fix the validation logic to check planes depending on format, not compressionControlPlaneCount. Properly set compressionControlPlaneCount and pFixedRateFlags depending on compression flags. Components: Vulkan VK-GL-CTS issue: 4105 Affects: dEQP-VK.api.image_compression_control.* Change-Id: I492febb4163867ee722cd49e75cc8646aa8376f5 --- .../api/vktApiImageCompressionControlTests.cpp | 62 +++++++++++++--------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/external/vulkancts/modules/vulkan/api/vktApiImageCompressionControlTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiImageCompressionControlTests.cpp index 78c629c..b2c4e73 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiImageCompressionControlTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiImageCompressionControlTests.cpp @@ -93,14 +93,15 @@ static void checkImageCompressionControlSupport(Context& context) static void validate(Context& context, tcu::ResultCollector& results, VkDevice device, TestParams& testParams, VkImage image) { - - for (unsigned planeIndex = 0; planeIndex < testParams.control.compressionControlPlaneCount; planeIndex++) + constexpr VkImageAspectFlags planeAspects[]{ VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, + VK_IMAGE_ASPECT_PLANE_2_BIT }; + const bool isYCbCr = isYCbCrFormat(testParams.format); + const int numPlanes = isYCbCr ? getPlaneCount(testParams.format) : 1; + for (int planeIndex = 0; planeIndex < numPlanes; planeIndex++) { VkImageAspectFlags aspect = VK_IMAGE_ASPECT_COLOR_BIT; - if (isYCbCrFormat(testParams.format)) + if (isYCbCr) { - VkImageAspectFlags planeAspects[]{ VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, - VK_IMAGE_ASPECT_PLANE_2_BIT }; aspect = planeAspects[planeIndex]; } @@ -110,14 +111,19 @@ static void validate(Context& context, tcu::ResultCollector& results, VkDevice d VkSubresourceLayout2EXT subresourceLayout = initVulkanStructure(&compressionProperties); context.getDeviceInterface().getImageSubresourceLayout2EXT(device, image, &subresource, &subresourceLayout); + VkImageCompressionFixedRateFlagsEXT fixedRateFlags[3] = { + VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT, + VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT, + VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT + }; - VkImageCompressionControlEXT compressionEnabled = initVulkanStructure(); - compressionEnabled.compressionControlPlaneCount = testParams.control.compressionControlPlaneCount; - compressionEnabled.flags = testParams.control.flags; - VkImageCompressionFixedRateFlagsEXT fixedRateFlags[3] = { VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT, - VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT, - VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT }; - compressionEnabled.pFixedRateFlags = fixedRateFlags; + VkImageCompressionControlEXT compressionEnabled = initVulkanStructure(); + compressionEnabled.compressionControlPlaneCount = testParams.control.compressionControlPlaneCount; + compressionEnabled.flags = testParams.control.flags; + if (compressionEnabled.compressionControlPlaneCount > 0) + { + compressionEnabled.pFixedRateFlags = fixedRateFlags; + } VkPhysicalDeviceImageFormatInfo2 formatInfo = initVulkanStructure(&compressionEnabled); formatInfo.format = testParams.format; @@ -133,7 +139,6 @@ static void validate(Context& context, tcu::ResultCollector& results, VkDevice d if (testParams.useExtension) { - if ((compressionPropertiesSupported.imageCompressionFixedRateFlags & compressionProperties.imageCompressionFixedRateFlags) != compressionProperties.imageCompressionFixedRateFlags) @@ -217,19 +222,25 @@ static tcu::TestStatus ahbImageCreateTest(Context& context, TestParams testParam VkDevice device = context.getDevice(); tcu::TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results(log); + const bool is_fixed_rate_ex = testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT; + const uint32_t numPlanes = isYCbCrFormat(testParams.format) ? getPlaneCount(testParams.format) : 1; + + testParams.control.compressionControlPlaneCount = is_fixed_rate_ex ? numPlanes : 0; VkImageCompressionFixedRateFlagsEXT planeFlags[3]{}; - for (unsigned i{}; i < (testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT ? 24 : 1); i++) + for (unsigned i{}; i < (is_fixed_rate_ex ? 24 : 1); i++) { - planeFlags[0] ^= 3 << i; planeFlags[1] ^= 5 << i; planeFlags[2] ^= 7 << i; - if (testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT) + + if (is_fixed_rate_ex) { + testParams.control.compressionControlPlaneCount = numPlanes; testParams.control.pFixedRateFlags = planeFlags; } + const vk::VkExternalMemoryImageCreateInfo externalCreateInfo = { vk::VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO, &testParams.control, VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID @@ -276,16 +287,17 @@ static tcu::TestStatus imageCreateTest(Context& context, TestParams testParams) VkExtent3D extent = { 16, 16, 1 }; tcu::TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results(log); + const bool is_fixed_rate_ex = testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT; VkImageCompressionFixedRateFlagsEXT planeFlags[3]{}; - for (unsigned i{}; i < (testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT ? 24 : 1); i++) + for (unsigned i{}; i < (is_fixed_rate_ex ? 24 : 1); i++) { - planeFlags[0] ^= 3 << i; planeFlags[1] ^= 5 << i; planeFlags[2] ^= 7 << i; - if (testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT) + + if (is_fixed_rate_ex) { testParams.control.pFixedRateFlags = planeFlags; } @@ -324,6 +336,8 @@ static tcu::TestStatus imageCreateTest(Context& context, TestParams testParams) void addImageCompressionControlTests(tcu::TestCaseGroup* group, TestParams testParams) { + const bool is_fixed_rate_ex = testParams.control.flags == VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT; + static const struct { VkFormat begin; @@ -349,8 +363,10 @@ void addImageCompressionControlTests(tcu::TestCaseGroup* group, TestParams testP { if (isCompressedFormat(testParams.format)) continue; - testParams.control.compressionControlPlaneCount = - isYCbCrFormat(testParams.format) ? getPlaneCount(testParams.format) : 1; + + const uint32_t numPlanes = isYCbCrFormat(testParams.format) ? getPlaneCount(testParams.format) : 1; + testParams.control.compressionControlPlaneCount = is_fixed_rate_ex ? numPlanes : 0; + const char* const enumName = getFormatName(testParams.format); const string caseName = de::toLower(string(enumName).substr(10)); addFunctionCase(group, caseName, enumName, imageCreateTest, testParams); @@ -379,7 +395,7 @@ tcu::TestCaseGroup* createImageCompressionControlTests(tcu::TestContext& testCtx { const char* name; VkImageCompressionFlagsEXT flag; - } compression_flags[] = { + } constexpr compression_flags[] = { { "default", VK_IMAGE_COMPRESSION_DEFAULT_EXT }, { "fixed_rate_default", VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT }, { "disabled", VK_IMAGE_COMPRESSION_DISABLED_EXT }, @@ -395,8 +411,6 @@ tcu::TestCaseGroup* createImageCompressionControlTests(tcu::TestContext& testCtx } group->addChild(subgroup); - testParams.control.compressionControlPlaneCount = 1; - subgroup = new tcu::TestCaseGroup(testCtx, "android_hardware_buffer", "Test creating Android Hardware buffer with compression control struct"); for (auto& flag : compression_flags) -- 2.7.4