From d8e78dd757dd60992d694fb3063953875c5f2f31 Mon Sep 17 00:00:00 2001 From: pboyle Date: Mon, 22 Dec 2025 12:30:19 -0800 Subject: [PATCH 1/2] layers: Add AllocateMemory VU for VK_QCOM_tile_memory_heap --- layers/core_checks/cc_device_memory.cpp | 17 +++++++++++++---- layers/core_checks/core_validation.h | 2 +- tests/unit/android_hardware_buffer.cpp | 1 + tests/unit/tile_memory_heap.cpp | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/layers/core_checks/cc_device_memory.cpp b/layers/core_checks/cc_device_memory.cpp index 74f1ea22d5e..5c4dd9f4b5b 100644 --- a/layers/core_checks/cc_device_memory.cpp +++ b/layers/core_checks/cc_device_memory.cpp @@ -384,6 +384,16 @@ bool CoreChecks::PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAl pAllocateInfo->allocationSize, phys_dev_props_core11.maxMemoryAllocationSize); } + if (!enabled_features.tileMemoryHeap && HasTileMemoryType(pAllocateInfo->memoryTypeIndex)) { + skip |= + LogError("VUID-VkTileMemoryBindInfoQCOM-memoryTypeIndex-10976", device, allocate_info_loc.dot(Field::memoryTypeIndex), + "(%" PRIu32 + ") identifies a memory type that corresponds to a VkMemoryHeap with the" + " VK_MEMORY_HEAP_TILE_MEMORY_BIT_QCOM property, but the tileMemory feature " + "is not enabled.", + pAllocateInfo->memoryTypeIndex); + } + if (IsExtEnabled(extensions.vk_android_external_memory_android_hardware_buffer)) { skip |= ValidateAllocateMemoryANDROID(*pAllocateInfo, allocate_info_loc); } else { @@ -824,8 +834,7 @@ bool CoreChecks::ValidateMemoryTypes(const vvl::DeviceMemory &mem_info, const ui return skip; } -bool CoreChecks::IsDeviceTileMemory(const vvl::DeviceMemory &mem_info) const { - const uint32_t memory_type_index = mem_info.allocate_info.memoryTypeIndex; +bool CoreChecks::HasTileMemoryType(uint32_t memory_type_index) const { const uint32_t memory_heap_index = phys_dev_mem_props.memoryTypes[memory_type_index].heapIndex; return (phys_dev_mem_props.memoryHeaps[memory_heap_index].flags & VK_MEMORY_HEAP_TILE_MEMORY_BIT_QCOM); } @@ -868,7 +877,7 @@ bool CoreChecks::ValidateBindBufferMemory(VkBuffer buffer, VkDeviceMemory memory const char *mem_type_vuid = bind_buffer_mem_2 ? "VUID-VkBindBufferMemoryInfo-memory-01035" : "VUID-vkBindBufferMemory-memory-01035"; - if (!IsDeviceTileMemory(*mem_info)) { + if (!HasTileMemoryType(mem_info->allocate_info.memoryTypeIndex)) { skip |= ValidateMemoryTypes(*mem_info, buffer_state->requirements.memoryTypeBits, loc.dot(Field::buffer), mem_type_vuid); @@ -1767,7 +1776,7 @@ bool CoreChecks::ValidateBindImageMemory(uint32_t bindInfoCount, const VkBindIma const char* vuid_mem_type = bind_image_mem_2 ? "VUID-VkBindImageMemoryInfo-pNext-01615" : "VUID-vkBindImageMemory-memory-01047"; // Validate memory requirements alignment - if (!IsDeviceTileMemory(*mem_info)) { + if (!HasTileMemoryType(mem_info->allocate_info.memoryTypeIndex)) { // Validate memory type used skip |= ValidateMemoryTypes(*mem_info, mem_req.memoryTypeBits, loc.dot(Field::image), vuid_mem_type); diff --git a/layers/core_checks/core_validation.h b/layers/core_checks/core_validation.h index a6804821f38..bf8a9c9b58f 100644 --- a/layers/core_checks/core_validation.h +++ b/layers/core_checks/core_validation.h @@ -2831,7 +2831,7 @@ class CoreChecks : public vvl::DeviceProxy { const VkConvertCooperativeVectorMatrixInfoNV* pInfos, const ErrorObject& error_obj) const override; - bool IsDeviceTileMemory(const vvl::DeviceMemory& mem_info) const; + bool HasTileMemoryType(uint32_t memory_type_index) const; void Created(vvl::CommandBuffer& cb) override; void Created(vvl::Queue& queue) override; diff --git a/tests/unit/android_hardware_buffer.cpp b/tests/unit/android_hardware_buffer.cpp index 8be29a62c69..7f98902b121 100644 --- a/tests/unit/android_hardware_buffer.cpp +++ b/tests/unit/android_hardware_buffer.cpp @@ -220,6 +220,7 @@ TEST_F(NegativeAndroidHardwareBuffer, AllocationSize) { memory_allocate_info.allocationSize = ahb_props.allocationSize; memory_allocate_info.memoryTypeIndex++; #if defined(VVL_MOCK_ANDROID) + memory_allocate_info.memoryTypeIndex = 0xFFFFFFFF; m_errorMonitor->SetUnexpectedError("VUID-vkAllocateMemory-pAllocateInfo-01714"); // incase at last index #endif m_errorMonitor->SetDesiredError("VUID-VkMemoryAllocateInfo-memoryTypeIndex-02385"); diff --git a/tests/unit/tile_memory_heap.cpp b/tests/unit/tile_memory_heap.cpp index 454a3e813d5..51af6ec8811 100644 --- a/tests/unit/tile_memory_heap.cpp +++ b/tests/unit/tile_memory_heap.cpp @@ -55,6 +55,27 @@ TEST_F(NegativeTileMemoryHeap, CreateBufferTestIndexUsageFlags) { CreateBufferTest(buffer_ci, "VUID-VkBufferCreateInfo-usage-10764"); } +TEST_F(NegativeTileMemoryHeap, AllocateMemory) { + TEST_DESCRIPTION("Allocate Tile Memory without the Tile Memory feature enabled."); + + AddRequiredExtensions(VK_QCOM_TILE_MEMORY_HEAP_EXTENSION_NAME); + + RETURN_IF_SKIP(Init()); + + VkMemoryAllocateInfo alloc_info = vku::InitStructHelper(); + alloc_info.allocationSize = 256; + + bool pass = m_device->Physical().SetMemoryType(0xFFFFFFFF, &alloc_info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 0, + VK_MEMORY_HEAP_TILE_MEMORY_BIT_QCOM); + if (!pass) { + GTEST_SKIP() << "Could not find an eligible Tile Memory Type."; + } + + m_errorMonitor->SetDesiredError("VUID-VkTileMemoryBindInfoQCOM-memoryTypeIndex-10976"); + vkt::DeviceMemory buffer_memory(*m_device, alloc_info); + m_errorMonitor->VerifyFound(); +} + TEST_F(NegativeTileMemoryHeap, BindBufferMemorySize) { TEST_DESCRIPTION("Bind Tile Memory to a Buffer with too small of size"); SetTargetApiVersion(VK_API_VERSION_1_1); From 040c62a54f983e5e59926cbe3a74065259dac942 Mon Sep 17 00:00:00 2001 From: pboyle Date: Mon, 22 Dec 2025 15:15:39 -0800 Subject: [PATCH 2/2] tests: Fix AHB memory type test --- tests/unit/android_hardware_buffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/android_hardware_buffer.cpp b/tests/unit/android_hardware_buffer.cpp index 7f98902b121..0f61e78f77c 100644 --- a/tests/unit/android_hardware_buffer.cpp +++ b/tests/unit/android_hardware_buffer.cpp @@ -220,8 +220,10 @@ TEST_F(NegativeAndroidHardwareBuffer, AllocationSize) { memory_allocate_info.allocationSize = ahb_props.allocationSize; memory_allocate_info.memoryTypeIndex++; #if defined(VVL_MOCK_ANDROID) - memory_allocate_info.memoryTypeIndex = 0xFFFFFFFF; m_errorMonitor->SetUnexpectedError("VUID-vkAllocateMemory-pAllocateInfo-01714"); // incase at last index + // With TestICD, the next memory index in a tileMemory type, so just ignore + m_errorMonitor->SetUnexpectedError("VUID-VkTileMemoryBindInfoQCOM-memoryTypeIndex-10976"); + #endif m_errorMonitor->SetDesiredError("VUID-VkMemoryAllocateInfo-memoryTypeIndex-02385"); vkt::DeviceMemory memory(*m_device, memory_allocate_info);