Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions layers/core_checks/cc_device_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion layers/core_checks/core_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/android_hardware_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ TEST_F(NegativeAndroidHardwareBuffer, AllocationSize) {
memory_allocate_info.memoryTypeIndex++;
#if defined(VVL_MOCK_ANDROID)
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);
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/tile_memory_heap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down