Skip to content

Commit 91ede49

Browse files
ziga-lunargspencer-lunarg
authored andcommitted
layers: Update image flags tracking
1 parent 8506dcd commit 91ede49

40 files changed

Lines changed: 1206 additions & 709 deletions

BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ vvl_sources = [
478478
"layers/vulkan/generated/enum_flag_bits.h",
479479
"layers/vulkan/generated/error_location_helper.cpp",
480480
"layers/vulkan/generated/error_location_helper.h",
481+
"layers/vulkan/generated/extended_flags_helper_generator.h",
482+
"layers/vulkan/generated/extended_flags_helper_generator.cpp",
481483
"layers/vulkan/generated/feature_requirements_helper.cpp",
482484
"layers/vulkan/generated/feature_requirements_helper.h",
483485
"layers/vulkan/generated/feature_not_present.cpp",

layers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ target_sources(vvl PRIVATE
302302
${API_TYPE}/generated/thread_safety_instance_defs.h
303303
${API_TYPE}/generated/gpuav_offline_spirv.h
304304
${API_TYPE}/generated/gpuav_offline_spirv.cpp
305+
${API_TYPE}/generated/extended_flags_helper_generator.h
306+
${API_TYPE}/generated/extended_flags_helper_generator.cpp
305307
gpuav/core/gpuav.h
306308
gpuav/core/gpuav_constants.h
307309
gpuav/core/gpuav_features.cpp

layers/best_practices/bp_device_memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool BestPractices::ValidateBindImageMemory(VkImage image, VkDeviceMemory memory
184184
// make sure this type is actually used.
185185
// This warning will only trigger if this layer is run on a platform that supports LAZILY_ALLOCATED_BIT
186186
// (i.e.most tile - based renderers)
187-
if (image_state->create_info.usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) {
187+
if (image_state->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) {
188188
bool supports_lazy = false;
189189
uint32_t suggested_type = 0;
190190

layers/best_practices/bp_framebuffer.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* Copyright (c) 2015-2025 The Khronos Group Inc.
2-
* Copyright (c) 2015-2025 Valve Corporation
3-
* Copyright (c) 2015-2025 LunarG, Inc.
1+
/* Copyright (c) 2015-2026 The Khronos Group Inc.
2+
* Copyright (c) 2015-2026 Valve Corporation
3+
* Copyright (c) 2015-2026 LunarG, Inc.
44
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
55
* Modifications Copyright (C) 2022 RasterGrid Kft.
66
*
@@ -40,9 +40,7 @@ bool BestPractices::ValidateAttachments(const VkRenderPassCreateInfo2* rpci, uin
4040
auto view_state = Get<vvl::ImageView>(attachments[i]);
4141
ASSERT_AND_CONTINUE(view_state);
4242

43-
const auto& ici = view_state->image_state->create_info;
44-
45-
const bool image_is_transient = (ici.usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0;
43+
const bool image_is_transient = (view_state->image_state->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0;
4644

4745
// The check for an image that should not be transient applies to all GPUs
4846
if (!attachment_should_be_transient && image_is_transient) {

layers/best_practices/bp_synchronization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool BestPractices::ValidateImageMemoryBarrier(const Location& loc, VkCommandBuf
232232
"A queue family ownership transfer is being performed on %s, but this %s. Image was "
233233
"created with VK_IMAGE_TILING_LINEAR.",
234234
FormatHandle(image).c_str(), warning);
235-
} else if ((image_state->create_info.usage &
235+
} else if ((image_state->usage &
236236
(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
237237
VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
238238
VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT | VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR)) ==
@@ -341,7 +341,7 @@ bool BestPractices::PreCallValidateCmdPipelineBarrier(
341341
// general with no storage
342342
if (VendorCheckEnabled(kBPVendorAMD) && image_barrier.newLayout == VK_IMAGE_LAYOUT_GENERAL) {
343343
auto image_state = Get<vvl::Image>(pImageMemoryBarriers[i].image);
344-
if (image_state && !(image_state->create_info.usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
344+
if (image_state && !(image_state->usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
345345
const LogObjectList objlist(commandBuffer, pImageMemoryBarriers[i].image);
346346
skip |= LogPerformanceWarning("BestPractices-AMD-vkImage-AvoidGeneral", objlist,
347347
error_obj.location.dot(Field::pImageMemoryBarriers, i).dot(Field::image),

layers/core_checks/cc_android.cpp

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)