1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
|
/*
* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (c) 2015-2025 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
#include "../framework/layer_validation_tests.h"
#include "../framework/android_hardware_buffer.h"
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
class PositiveAndroidHardwareBuffer : public VkLayerTest {};
TEST_F(PositiveAndroidHardwareBuffer, MemoryRequirements) {
TEST_DESCRIPTION("Verify AndroidHardwareBuffer doesn't conflict with memory requirements.");
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
vkt::AHB ahb(AHARDWAREBUFFER_FORMAT_BLOB, AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER, 64);
VkExternalMemoryBufferCreateInfo ext_buf_info = vku::InitStructHelper();
ext_buf_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = VK_NULL_HANDLE;
VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info = vku::InitStructHelper(&memory_dedicated_info);
import_ahb_Info.buffer = ahb.handle();
VkAndroidHardwareBufferPropertiesANDROID ahb_props = vku::InitStructHelper();
vk::GetAndroidHardwareBufferPropertiesANDROID(device(), ahb.handle(), &ahb_props);
VkMemoryAllocateInfo memory_allocate_info = vku::InitStructHelper(&import_ahb_Info);
if (!SetAllocationInfoImportAHB(m_device, ahb_props, memory_allocate_info)) {
GTEST_SKIP() << "No valid memory type index could be found";
}
VkBufferCreateInfo buffer_create_info = vku::InitStructHelper(&ext_buf_info);
buffer_create_info.size = memory_allocate_info.allocationSize;
buffer_create_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
vkt::Buffer buffer(*m_device, buffer_create_info, vkt::no_mem);
memory_dedicated_info.buffer = buffer;
// Should be able to bind memory with no error
vkt::DeviceMemory memory(*m_device, memory_allocate_info);
vk::BindBufferMemory(device(), buffer, memory, 0);
}
TEST_F(PositiveAndroidHardwareBuffer, DepthStencil) {
TEST_DESCRIPTION("Verify AndroidHardwareBuffer can import Depth/Stencil");
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
vkt::AHB ahb(AHARDWAREBUFFER_FORMAT_D16_UNORM, AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER, 64);
if (!ahb.handle()) {
GTEST_SKIP() << "Failed to Allocate AHB";
}
// Incase it hits the below driver bug, catch the false VUID error thrown from driver not creating valid AHB
m_errorMonitor->SetUnexpectedError("VUID-vkGetAndroidHardwareBufferPropertiesANDROID-buffer-01884");
VkAndroidHardwareBufferFormatPropertiesANDROID ahb_fmt_props = vku::InitStructHelper();
VkAndroidHardwareBufferPropertiesANDROID ahb_props = vku::InitStructHelper(&ahb_fmt_props);
vk::GetAndroidHardwareBufferPropertiesANDROID(device(), ahb.handle(), &ahb_props);
VkExternalMemoryImageCreateInfo ext_image_info = vku::InitStructHelper();
ext_image_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
if (ahb_fmt_props.format != VK_FORMAT_D16_UNORM) {
GTEST_SKIP() << "Driver bug: Didn't turn AHB format into VK_FORMAT_D16_UNORM";
}
// Create a Depth/Stencil image
VkImageCreateInfo image_create_info = vku::InitStructHelper(&ext_image_info);
image_create_info.flags = 0;
image_create_info.imageType = VK_IMAGE_TYPE_2D;
image_create_info.format = ahb_fmt_props.format;
image_create_info.extent = {64, 1, 1};
image_create_info.mipLevels = 1;
image_create_info.arrayLayers = 1;
image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
vkt::Image ds_image(*m_device, image_create_info, vkt::no_mem);
if (ds_image.handle() == VK_NULL_HANDLE) {
GTEST_SKIP() << "Was not able to create a D16 AHB framebuffer";
}
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = ds_image;
memory_dedicated_info.buffer = VK_NULL_HANDLE;
VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info =
vku::InitStructHelper(&memory_dedicated_info);
import_ahb_Info.buffer = ahb.handle();
VkMemoryAllocateInfo memory_allocate_info = vku::InitStructHelper(&import_ahb_Info);
if (!SetAllocationInfoImportAHB(m_device, ahb_props, memory_allocate_info)) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_allocate_info);
vk::BindImageMemory(device(), ds_image, memory, 0);
}
TEST_F(PositiveAndroidHardwareBuffer, BindBufferMemory) {
TEST_DESCRIPTION("Verify AndroidHardwareBuffer Buffers can be queried for mem requirements while unbound.");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
VkExternalMemoryBufferCreateInfo ext_buf_info = vku::InitStructHelper();
ext_buf_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkBufferCreateInfo buffer_create_info = vku::InitStructHelper(&ext_buf_info);
buffer_create_info.size = 8192; // greater than the 4k AHB usually are
buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
vkt::Buffer buffer(*m_device, buffer_create_info, vkt::no_mem);
// Try to get memory requirements prior to binding memory
VkMemoryRequirements mem_reqs;
vk::GetBufferMemoryRequirements(device(), buffer, &mem_reqs);
// Test bind memory 2 extension
VkBufferMemoryRequirementsInfo2 buffer_mem_reqs2 = vku::InitStructHelper();
buffer_mem_reqs2.buffer = buffer;
VkMemoryRequirements2 mem_reqs2 = vku::InitStructHelper();
vk::GetBufferMemoryRequirements2(device(), &buffer_mem_reqs2, &mem_reqs2);
// Allocate an AHardwareBuffer to match the size
vkt::AHB ahb(AHARDWAREBUFFER_FORMAT_BLOB, AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER, mem_reqs.size);
// Get real values
VkAndroidHardwareBufferPropertiesANDROID ahb_props = vku::InitStructHelper();
vk::GetAndroidHardwareBufferPropertiesANDROID(device(), ahb.handle(), &ahb_props);
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = VK_NULL_HANDLE;
memory_dedicated_info.buffer = buffer;
VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info = vku::InitStructHelper(&memory_dedicated_info);
import_ahb_Info.buffer = ahb.handle();
VkMemoryAllocateInfo memory_allocate_info = vku::InitStructHelper(&import_ahb_Info);
if (!SetAllocationInfoImportAHB(m_device, ahb_props, memory_allocate_info)) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_allocate_info);
vk::BindBufferMemory(device(), buffer, memory, 0);
}
TEST_F(PositiveAndroidHardwareBuffer, ExportBuffer) {
TEST_DESCRIPTION("Verify VkBuffers can export to an AHB.");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
// Create VkBuffer to be exported to an AHB
VkExternalMemoryBufferCreateInfo ext_buf_info = vku::InitStructHelper();
ext_buf_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkBufferCreateInfo buffer_create_info = vku::InitStructHelper(&ext_buf_info);
buffer_create_info.size = 4096;
buffer_create_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
vkt::Buffer buffer(*m_device, buffer_create_info, vkt::no_mem);
VkMemoryRequirements mem_reqs;
vk::GetBufferMemoryRequirements(device(), buffer, &mem_reqs);
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = VK_NULL_HANDLE;
memory_dedicated_info.buffer = buffer;
VkExportMemoryAllocateInfo export_memory_info = vku::InitStructHelper(&memory_dedicated_info);
export_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkMemoryAllocateInfo memory_info = vku::InitStructHelper(&export_memory_info);
memory_info.allocationSize = mem_reqs.size;
bool has_memtype =
m_device->Physical().SetMemoryType(mem_reqs.memoryTypeBits, &memory_info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
if (!has_memtype) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_info);
vk::BindBufferMemory(device(), buffer, memory, 0);
// Export memory to AHB
AHardwareBuffer *ahb = nullptr;
VkMemoryGetAndroidHardwareBufferInfoANDROID get_ahb_info = vku::InitStructHelper();
get_ahb_info.memory = memory;
vk::GetMemoryAndroidHardwareBufferANDROID(device(), &get_ahb_info, &ahb);
// App in charge of releasing after exporting
AHardwareBuffer_release(ahb);
}
TEST_F(PositiveAndroidHardwareBuffer, ExportImage) {
TEST_DESCRIPTION("Verify VkImages can export to an AHB.");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
// Create VkImage to be exported to an AHB
VkExternalMemoryImageCreateInfo ext_image_info = vku::InitStructHelper();
ext_image_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkImageCreateInfo image_create_info = vku::InitStructHelper(&ext_image_info);
image_create_info.flags = 0;
image_create_info.imageType = VK_IMAGE_TYPE_2D;
image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM;
image_create_info.extent = {64, 1, 1};
image_create_info.mipLevels = 1;
image_create_info.arrayLayers = 1;
image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_create_info.tiling = VK_IMAGE_TILING_LINEAR;
image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
vkt::Image image(*m_device, image_create_info, vkt::no_mem);
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = image;
memory_dedicated_info.buffer = VK_NULL_HANDLE;
VkExportMemoryAllocateInfo export_memory_info = vku::InitStructHelper(&memory_dedicated_info);
export_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkMemoryAllocateInfo memory_info = vku::InitStructHelper(&export_memory_info);
// "When allocating new memory for an image that can be exported to an Android hardware buffer, the memory’s allocationSize must
// be zero":
memory_info.allocationSize = 0;
// Use any DEVICE_LOCAL memory found
bool has_memtype = m_device->Physical().SetMemoryType(0xFFFFFFFF, &memory_info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
if (!has_memtype) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_info);
vk::BindImageMemory(device(), image, memory, 0);
// Export memory to AHB
AHardwareBuffer *ahb = nullptr;
VkMemoryGetAndroidHardwareBufferInfoANDROID get_ahb_info = vku::InitStructHelper();
get_ahb_info.memory = memory;
vk::GetMemoryAndroidHardwareBufferANDROID(device(), &get_ahb_info, &ahb);
// App in charge of releasing after exporting
AHardwareBuffer_release(ahb);
}
TEST_F(PositiveAndroidHardwareBuffer, ExternalImage) {
TEST_DESCRIPTION("Verify AndroidHardwareBuffer can import AHB with external format");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
// FORMAT_Y8Cb8Cr8_420 is a known/public valid AHB Format but does not have a Vulkan mapping to it
// Will use the external image feature to get access to it
vkt::AHB ahb(AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420, AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE, 64, 64);
if (!ahb.handle()) {
GTEST_SKIP() << "could not allocate AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420";
}
VkAndroidHardwareBufferFormatPropertiesANDROID ahb_fmt_props = vku::InitStructHelper();
VkAndroidHardwareBufferPropertiesANDROID ahb_props = vku::InitStructHelper(&ahb_fmt_props);
vk::GetAndroidHardwareBufferPropertiesANDROID(device(), ahb.handle(), &ahb_props);
// The spec says the driver must not return zero, even if a VkFormat is returned with it, some older drivers do as a driver bug
if (ahb_fmt_props.externalFormat == 0) {
GTEST_SKIP() << "externalFormat was zero which is not valid";
}
// Create an image w/ external format
VkExternalFormatANDROID ext_format = vku::InitStructHelper();
ext_format.externalFormat = ahb_fmt_props.externalFormat;
VkExternalMemoryImageCreateInfo ext_image_info = vku::InitStructHelper(&ext_format);
ext_image_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkImageCreateInfo image_create_info = vku::InitStructHelper(&ext_image_info);
image_create_info.flags = 0;
image_create_info.imageType = VK_IMAGE_TYPE_2D;
image_create_info.format = VK_FORMAT_UNDEFINED;
image_create_info.extent = {64, 64, 1};
image_create_info.mipLevels = 1;
image_create_info.arrayLayers = 1;
image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
vkt::Image image(*m_device, image_create_info, vkt::no_mem);
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = image;
memory_dedicated_info.buffer = VK_NULL_HANDLE;
VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info =
vku::InitStructHelper(&memory_dedicated_info);
import_ahb_Info.buffer = ahb.handle();
VkMemoryAllocateInfo memory_allocate_info = vku::InitStructHelper(&import_ahb_Info);
if (!SetAllocationInfoImportAHB(m_device, ahb_props, memory_allocate_info)) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_allocate_info);
vk::BindImageMemory(device(), image, memory, 0);
}
TEST_F(PositiveAndroidHardwareBuffer, ExternalCameraFormat) {
TEST_DESCRIPTION("Verify AndroidHardwareBuffer can import AHB with external format");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
// Simulate camera usage of AHB
AHardwareBuffer_Desc ahb_desc = {};
ahb_desc.format = AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED;
ahb_desc.usage =
AHARDWAREBUFFER_USAGE_CAMERA_WRITE | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN;
ahb_desc.width = 64;
ahb_desc.height = 64;
ahb_desc.layers = 1;
ahb_desc.stride = 1;
vkt::AHB ahb(&ahb_desc);
if (!ahb.handle()) {
GTEST_SKIP() << "could not allocate AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED";
}
VkAndroidHardwareBufferFormatPropertiesANDROID ahb_fmt_props = vku::InitStructHelper();
VkAndroidHardwareBufferPropertiesANDROID ahb_props = vku::InitStructHelper(&ahb_fmt_props);
vk::GetAndroidHardwareBufferPropertiesANDROID(device(), ahb.handle(), &ahb_props);
// The spec says the driver must not return zero, even if a VkFormat is returned with it, some older drivers do as a driver bug
if (ahb_fmt_props.externalFormat == 0) {
GTEST_SKIP() << "externalFormat was zero which is not valid";
}
// Create an image w/ external format
VkExternalFormatANDROID ext_format = vku::InitStructHelper();
ext_format.externalFormat = ahb_fmt_props.externalFormat;
VkExternalMemoryImageCreateInfo ext_image_info = vku::InitStructHelper(&ext_format);
ext_image_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
VkImageCreateInfo image_create_info = vku::InitStructHelper(&ext_image_info);
image_create_info.flags = 0;
image_create_info.imageType = VK_IMAGE_TYPE_2D;
image_create_info.format = VK_FORMAT_UNDEFINED;
image_create_info.extent = {64, 64, 1};
image_create_info.mipLevels = 1;
image_create_info.arrayLayers = 1;
image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
vkt::Image image(*m_device, image_create_info, vkt::no_mem);
VkMemoryDedicatedAllocateInfo memory_dedicated_info = vku::InitStructHelper();
memory_dedicated_info.image = image;
memory_dedicated_info.buffer = VK_NULL_HANDLE;
VkImportAndroidHardwareBufferInfoANDROID import_ahb_Info =
vku::InitStructHelper(&memory_dedicated_info);
import_ahb_Info.buffer = ahb.handle();
VkMemoryAllocateInfo memory_allocate_info = vku::InitStructHelper(&import_ahb_Info);
if (!SetAllocationInfoImportAHB(m_device, ahb_props, memory_allocate_info)) {
GTEST_SKIP() << "No valid memory type index could be found";
}
vkt::DeviceMemory memory(*m_device, memory_allocate_info);
vk::BindImageMemory(device(), image, memory, 0);
}
TEST_F(PositiveAndroidHardwareBuffer, DeviceImageMemoryReq) {
TEST_DESCRIPTION("Call vkGetDeviceImageMemoryRequirementsKHR with externalFormat of zero.");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_MAINTENANCE_4_EXTENSION_NAME);
RETURN_IF_SKIP(Init());
VkExternalFormatANDROID external_format = vku::InitStructHelper();
external_format.externalFormat = 0;
VkImageCreateInfo image_create_info = vku::InitStructHelper(&external_format);
image_create_info.imageType = VK_IMAGE_TYPE_2D;
image_create_info.arrayLayers = 1;
image_create_info.extent = {64, 64, 1};
image_create_info.format = VK_FORMAT_UNDEFINED;
image_create_info.mipLevels = 1;
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
image_create_info.samples = VK_SAMPLE_COUNT_1_BIT;
image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
VkDeviceImageMemoryRequirements image_memory_req = vku::InitStructHelper();
image_memory_req.pCreateInfo = &image_create_info;
image_memory_req.planeAspect = VK_IMAGE_ASPECT_COLOR_BIT;
VkMemoryRequirements2 out_memory_req = vku::InitStructHelper();
vk::GetDeviceImageMemoryRequirementsKHR(device(), &image_memory_req, &out_memory_req);
}
#endif // VK_USE_PLATFORM_ANDROID_KHR
|