@@ -309,56 +309,56 @@ bool CoreChecks::ValidateAllocateMemoryANDROID(const VkMemoryAllocateInfo& alloc
309309
310310 auto image_state = Get<vvl::Image>(mem_ded_alloc_info->image );
311311 ASSERT_AND_RETURN_SKIP (image_state);
312- const auto * ici = &image_state->create_info ;
313312 const Location& dedicated_image_loc = allocate_info_loc.dot (Struct::VkMemoryDedicatedAllocateInfo, Field::image);
314313
315- dedicated_image_usage = ici ->usage ;
314+ dedicated_image_usage = image_state ->usage ;
316315
317316 // the format of image must be VK_FORMAT_UNDEFINED or the format returned by
318317 // vkGetAndroidHardwareBufferPropertiesANDROID
319- if (VK_FORMAT_UNDEFINED != ici-> format ) {
318+ if (VK_FORMAT_UNDEFINED != image_state-> GetFormat () ) {
320319 // Mali drivers will not return a valid VkAndroidHardwareBufferPropertiesANDROID::allocationSize if the
321320 // FormatPropertiesANDROID is passed in as well so need to query again for the format
322321 VkAndroidHardwareBufferFormatPropertiesANDROID ahb_format_props = vku::InitStructHelper ();
323322 VkAndroidHardwareBufferPropertiesANDROID dummy_ahb_props = vku::InitStructHelper (&ahb_format_props);
324323 DispatchGetAndroidHardwareBufferPropertiesANDROID (device, import_ahb_info->buffer , &dummy_ahb_props);
325- if (ici-> format != ahb_format_props.format ) {
324+ if (image_state-> GetFormat () != ahb_format_props.format ) {
326325 skip |= LogError (
327326 " VUID-VkMemoryAllocateInfo-pNext-02387" , mem_ded_alloc_info->image , dedicated_image_loc,
328327 " was created with format (%s) which does not match the %s AHardwareBuffer's format (%s). (AHB = %p)." ,
329- string_VkFormat (ici-> format ), ahb_loc.Fields ().c_str (), string_VkFormat (ahb_format_props.format ),
328+ string_VkFormat (image_state-> GetFormat () ), ahb_loc.Fields ().c_str (), string_VkFormat (ahb_format_props.format ),
330329 import_ahb_info->buffer );
331330 }
332331 }
333332
334333 // The width, height, and array layer dimensions of image and the Android hardwarebuffer must be identical
335- if ((ici-> extent .width != ahb_desc.width ) || (ici-> extent .height != ahb_desc.height ) ||
336- (ici-> arrayLayers != ahb_desc.layers )) {
334+ if ((image_state-> GetExtent () .width != ahb_desc.width ) || (image_state-> GetExtent () .height != ahb_desc.height ) ||
335+ (image_state-> GetArrayLayers () != ahb_desc.layers )) {
337336 skip |=
338337 LogError (" VUID-VkMemoryAllocateInfo-pNext-02388" , mem_ded_alloc_info->image , dedicated_image_loc,
339338 " was created with width (%" PRId32 " ), height (%" PRId32 " ), and arrayLayers (%" PRId32
340339 " ) which not match those of the %s AHardwareBuffer (%" PRId32 " %" PRId32 " %" PRId32 " ). (AHB = %p)." ,
341- ici-> extent .width , ici-> extent .height , ici-> arrayLayers , ahb_loc. Fields (). c_str (), ahb_desc. width ,
342- ahb_desc.height , ahb_desc.layers , import_ahb_info->buffer );
340+ image_state-> GetExtent () .width , image_state-> GetExtent () .height , image_state-> GetArrayLayers () ,
341+ ahb_loc. Fields (). c_str (), ahb_desc. width , ahb_desc.height , ahb_desc.layers , import_ahb_info->buffer );
343342 }
344343
345344 if ((ahb_desc.usage & AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE) != 0 ) {
346- if ((ici->mipLevels != 1 ) && (ici->mipLevels != FullMipChainLevels (ici->extent ))) {
345+ if ((image_state->GetMipLevels () != 1 ) &&
346+ (image_state->GetMipLevels () != FullMipChainLevels (image_state->GetExtent ()))) {
347347 skip |= LogError (" VUID-VkMemoryAllocateInfo-pNext-02389" , mem_ded_alloc_info->image , ahb_loc,
348348 " AHardwareBuffer_Desc's usage (0x%" PRIx64
349349 " ) includes AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE but %s mipLevels (%" PRIu32
350350 " ) is neither 1 nor full mip chain levels (%" PRIu32 " ). (AHB = %p)." ,
351- ahb_desc.usage , dedicated_image_loc.Fields ().c_str (), ici-> mipLevels ,
352- FullMipChainLevels (ici-> extent ), import_ahb_info->buffer );
351+ ahb_desc.usage , dedicated_image_loc.Fields ().c_str (), image_state-> GetMipLevels () ,
352+ FullMipChainLevels (image_state-> GetExtent () ), import_ahb_info->buffer );
353353 }
354354 } else {
355- if (ici-> mipLevels != 1 ) {
356- skip |=
357- LogError ( " VUID-VkMemoryAllocateInfo-pNext-02586" , mem_ded_alloc_info->image , ahb_loc,
358- " AHardwareBuffer_Desc's usage (0x%" PRIx64
359- " ) is missing 0x4000000 (AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE) but %s mipLevels is %" PRIu32
360- " . (AHB = %p)." ,
361- ahb_desc.usage , dedicated_image_loc.Fields ().c_str (), ici-> mipLevels , import_ahb_info->buffer );
355+ if (image_state-> GetMipLevels () != 1 ) {
356+ skip |= LogError (
357+ " VUID-VkMemoryAllocateInfo-pNext-02586" , mem_ded_alloc_info->image , ahb_loc,
358+ " AHardwareBuffer_Desc's usage (0x%" PRIx64
359+ " ) is missing 0x4000000 (AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE) but %s mipLevels is %" PRIu32
360+ " . (AHB = %p)." ,
361+ ahb_desc.usage , dedicated_image_loc.Fields ().c_str (), image_state-> GetMipLevels () , import_ahb_info->buffer );
362362 }
363363 }
364364
@@ -367,11 +367,11 @@ bool CoreChecks::ValidateAllocateMemoryANDROID(const VkMemoryAllocateInfo& alloc
367367 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
368368 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
369369 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT;
370- if (ici ->usage & ~(valid_vk_usages)) {
371- skip |=
372- LogError ( " VUID-VkMemoryAllocateInfo-pNext-02390" , mem_ded_alloc_info->image , dedicated_image_loc,
373- " was created with %s which are not listed in the AHardwareBuffer Usage Equivalence table. (AHB = %p)." ,
374- string_VkImageUsageFlags (ici ->usage & ~(valid_vk_usages)).c_str (), import_ahb_info->buffer );
370+ if (image_state ->usage & ~(valid_vk_usages)) {
371+ skip |= LogError (
372+ " VUID-VkMemoryAllocateInfo-pNext-02390" , mem_ded_alloc_info->image , dedicated_image_loc,
373+ " was created with %s which are not listed in the AHardwareBuffer Usage Equivalence table. (AHB = %p)." ,
374+ string_VkImageUsageFlags (image_state ->usage & ~(valid_vk_usages)).c_str (), import_ahb_info->buffer );
375375 }
376376
377377 // Based on vkspec.html#memory-external-android-hardware-buffer-usage
@@ -384,7 +384,7 @@ bool CoreChecks::ValidateAllocateMemoryANDROID(const VkMemoryAllocateInfo& alloc
384384 };
385385
386386 for (const auto & [vk_usage, ahb_usage] : ahb_usage_map_v2a) {
387- if (ici ->usage & vk_usage) {
387+ if (image_state ->usage & vk_usage) {
388388 if (0 == (ahb_usage & ahb_desc.usage )) {
389389 skip |= LogError (" VUID-VkMemoryAllocateInfo-pNext-02390" , mem_ded_alloc_info->image , dedicated_image_loc,
390390 " was created with %s, but the AHB equivalent 0x%" PRIx64
@@ -534,7 +534,8 @@ bool CoreChecks::ValidateTensorImportedHandleANDROID(VkExternalMemoryHandleTypeF
534534}
535535
536536// Validate creating an image with an external format
537- bool CoreChecks::ValidateCreateImageANDROID (const VkImageCreateInfo& create_info, const Location& create_info_loc) const {
537+ bool CoreChecks::ValidateCreateImageANDROID (const VkImageCreateInfo& create_info, const Location& create_info_loc,
538+ const VkImageCreateFlags create_flags, const VkImageUsageFlags usage) const {
538539 bool skip = false ;
539540
540541 const VkExternalFormatANDROID* ext_fmt_android = vku::FindStructInPNextChain<VkExternalFormatANDROID>(create_info.pNext );
@@ -546,27 +547,27 @@ bool CoreChecks::ValidateCreateImageANDROID(const VkImageCreateInfo& create_info
546547 string_VkFormat (create_info.format ));
547548 }
548549
549- if (0 != (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT & create_info. flags )) {
550+ if (0 != (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT & create_flags )) {
550551 skip |= LogError (" VUID-VkImageCreateInfo-pNext-02396" , device,
551552 create_info_loc.pNext (Struct::VkExternalFormatANDROID, Field::externalFormat),
552553 " (%" PRIu64 " ) is non-zero, but flags is %s." , ext_fmt_android->externalFormat ,
553- string_VkImageCreateFlags (create_info. flags ).c_str ());
554+ string_VkImageCreateFlags (create_flags ).c_str ());
554555 }
555556
556- if (0 != (~(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) &
557- create_info. usage )) {
557+ if (0 !=
558+ (~(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) & usage)) {
558559 skip |= LogError (" VUID-VkImageCreateInfo-pNext-02397" , device,
559560 create_info_loc.pNext (Struct::VkExternalFormatANDROID, Field::externalFormat),
560561 " (%" PRIu64 " ) is non-zero, but usage is %s." , ext_fmt_android->externalFormat ,
561- string_VkImageUsageFlags (create_info. usage ).c_str ());
562+ string_VkImageUsageFlags (usage).c_str ());
562563 } else if (!enabled_features.externalFormatResolve &&
563- ((VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) & create_info. usage )) {
564+ ((VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) & usage)) {
564565 skip |= LogError (
565566 " VUID-VkImageCreateInfo-pNext-09457" , device,
566567 create_info_loc.pNext (Struct::VkExternalFormatANDROID, Field::externalFormat),
567568 " (%" PRIu64
568569 " ) is non-zero, but usage is %s (without externalFormatResolve, only VK_IMAGE_USAGE_SAMPLED_BIT is allowed)." ,
569- ext_fmt_android->externalFormat , string_VkImageUsageFlags (create_info. usage ).c_str ());
570+ ext_fmt_android->externalFormat , string_VkImageUsageFlags (usage).c_str ());
570571 }
571572
572573 if (VK_IMAGE_TILING_OPTIMAL != create_info.tiling ) {
@@ -695,7 +696,8 @@ bool CoreChecks::ValidateTensorImportedHandleANDROID(VkExternalMemoryHandleTypeF
695696 return false ;
696697}
697698
698- bool CoreChecks::ValidateCreateImageANDROID (const VkImageCreateInfo& create_info, const Location& create_info_loc) const {
699+ bool CoreChecks::ValidateCreateImageANDROID (const VkImageCreateInfo& create_info, const Location& create_info_loc,
700+ const VkImageCreateFlags create_flags, const VkImageUsageFlags usage) const {
699701 return false ;
700702}
701703
0 commit comments