From ffd22ce89038a7befec6d6ab916baa924fd4b65c Mon Sep 17 00:00:00 2001 From: Shih-Hsin Li Date: Tue, 23 Nov 2021 16:32:38 -0800 Subject: [PATCH] Pick correct memoryTypeIndex for AHB Pick the right memoryTypeIndex for protected allocations so that protected memory is allocated when createFlag has protected bit set. This fixed some bindImageMemory failure caused by binding non-protected memory in testAndroidHardwareBufferImageFormat. Affects: dEQP-VK.api.external.memory.android_hardware_buffer.image_formats.* Components: Vulkan Change-Id: Ib50a97d248930b6cc6538d1c7b84e84cddfde40e --- .../vulkan/api/vktApiExternalMemoryTests.cpp | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp index 65d0818..f5d4d41 100644 --- a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp +++ b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp @@ -4252,26 +4252,27 @@ tcu::TestStatus testAndroidHardwareBufferImageFormat (Context& context, vk::VkF {64u, 64u}, {1024u, 2096u}, }; - for (size_t i = 0; i < DE_LENGTH_OF_ARRAY(sizes); i++) + + deUint32 exportedMemoryTypeIndex = 0; + + if (createFlag & vk::VK_IMAGE_CREATE_PROTECTED_BIT) { - const vk::Unique image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, sizes[i].width, sizes[i].height, tiling, createFlag, usage)); - const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image, externalMemoryType)); - deUint32 exportedMemoryTypeIndex = 0; + const vk::VkPhysicalDeviceMemoryProperties memProperties(vk::getPhysicalDeviceMemoryProperties(vki, physicalDevice)); - if (createFlag & vk::VK_IMAGE_CREATE_PROTECTED_BIT) + for (deUint32 memoryTypeIndex = 0; memoryTypeIndex < VK_MAX_MEMORY_TYPES; memoryTypeIndex++) { - const vk::VkPhysicalDeviceMemoryProperties memProperties(vk::getPhysicalDeviceMemoryProperties(vki, physicalDevice)); - - for (deUint32 memoryTypeIndex = 0; memoryTypeIndex < VK_MAX_MEMORY_TYPES; memoryTypeIndex++) + if (memProperties.memoryTypes[memoryTypeIndex].propertyFlags & vk::VK_MEMORY_PROPERTY_PROTECTED_BIT) { - if (memProperties.memoryTypes[memoryTypeIndex].propertyFlags & vk::VK_MEMORY_PROPERTY_PROTECTED_BIT) - { - exportedMemoryTypeIndex = memoryTypeIndex; - break; - } + exportedMemoryTypeIndex = memoryTypeIndex; + break; } } + } + for (size_t i = 0; i < DE_LENGTH_OF_ARRAY(sizes); i++) + { + const vk::Unique image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, sizes[i].width, sizes[i].height, tiling, createFlag, usage)); + const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image, externalMemoryType)); const vk::Unique memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image)); NativeHandle handle; @@ -4292,7 +4293,6 @@ tcu::TestStatus testAndroidHardwareBufferImageFormat (Context& context, vk::VkF { const vk::Unique image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, 64u, 64u, tiling, createFlag, usage, 7u)); const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image, externalMemoryType)); - const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits)); const vk::Unique memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image)); NativeHandle handle; @@ -4310,7 +4310,6 @@ tcu::TestStatus testAndroidHardwareBufferImageFormat (Context& context, vk::VkF { const vk::Unique image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, 64u, 64u, tiling, createFlag, usage, 1u, properties.imageFormatProperties.maxArrayLayers)); const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image, externalMemoryType)); - const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits)); const vk::Unique memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image)); NativeHandle handle; -- 2.7.4