Skip to content

Commit c5aa26f

Browse files
committed
layers: More image flags and usage updates
1 parent 4be46d8 commit c5aa26f

File tree

10 files changed

+90
-110
lines changed

10 files changed

+90
-110
lines changed

layers/core_checks/cc_image.cpp

Lines changed: 27 additions & 25 deletions
Large diffs are not rendered by default.

layers/core_checks/cc_render_pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ bool CoreChecks::VerifyFramebufferAndRenderPassImageViews(const VkRenderPassBegi
11051105

11061106
if (fb_att_image_create_flags != image_state->create_flags) {
11071107
skip |= LogError("VUID-VkRenderPassBeginInfo-framebuffer-03209", objlist,
1108-
GetFramebufferAttachmentImageInfoFlagsLocation(image_state->GetPNext(), attachment_loc),
1108+
GetFlagsLocation(*framebuffer_attachment_image_info, attachment_loc),
11091109
"is %s, but the VkFramebuffer was created with "
11101110
"VkFramebufferAttachmentsCreateInfo::pAttachmentImageInfos[%" PRIu32 "].flags = %s",
11111111
string_VkImageCreateFlags(image_state->create_flags).c_str(), i,
@@ -1114,7 +1114,7 @@ bool CoreChecks::VerifyFramebufferAndRenderPassImageViews(const VkRenderPassBegi
11141114

11151115
if (fb_att_image_usage_flags != image_view_state->inherited_usage) {
11161116
skip |= LogError("VUID-VkRenderPassBeginInfo-framebuffer-04627", objlist,
1117-
GetFramebufferAttachmentImageInfoUsageLocation(image_state->GetPNext(), attachment_loc),
1117+
GetUsageLocation(*framebuffer_attachment_image_info, attachment_loc),
11181118
"is (%s), but the VkFramebuffer was created with "
11191119
"vkFramebufferAttachmentsCreateInfo::pAttachmentImageInfos[%" PRIu32 "].usage = %s.\n%s",
11201120
string_VkImageUsageFlags(image_state->usage).c_str(), i,

layers/core_checks/cc_video.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ bool CoreChecks::IsSupportedVideoFormat(VkImageCreateFlags flags, VkImageUsageFl
8686

8787
for (auto& format_props : format_props_list) {
8888
const VkImageCreateFlags allowed_flags = format_props.imageCreateFlags | VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR;
89-
const bool compatible_usage = (flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) ||
90-
((usage & format_props.imageUsageFlags) == usage);
91-
if (format == format_props.format && (flags & allowed_flags) == flags &&
92-
imageType == format_props.imageType && tiling == format_props.imageTiling && compatible_usage) {
89+
const bool compatible_usage =
90+
(flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) || ((usage & format_props.imageUsageFlags) == usage);
91+
if (format == format_props.format && (flags & allowed_flags) == flags && imageType == format_props.imageType &&
92+
tiling == format_props.imageTiling && compatible_usage) {
9393
return true;
9494
}
9595
}

layers/core_checks/cc_wsi.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,7 @@ bool CoreChecks::ValidateCreateSwapchain(const VkSwapchainCreateInfoKHR& create_
483483
// Validate pCreateInfo->imageUsage against VkSurfaceCapabilitiesKHR::supportedUsageFlags:
484484
// Shared Present Mode uses different set of capabilities to check imageUsage support
485485
if ((image_usage != (image_usage & surface_caps.supportedUsageFlags)) && !shared_present_mode) {
486-
if (LogError("VUID-VkSwapchainCreateInfoKHR-presentMode-01427", device,
487-
GetSwapchainCreateInfoKHRImageUsageLocation(create_info.pNext, create_info_loc),
486+
if (LogError("VUID-VkSwapchainCreateInfoKHR-presentMode-01427", device, GetImageUsageLocation(create_info, create_info_loc),
488487
"(%s) are not in supportedUsageFlags (%s).", string_VkImageUsageFlags(image_usage).c_str(),
489488
string_VkImageUsageFlags(surface_caps.supportedUsageFlags).c_str())) {
490489
return true;
@@ -577,11 +576,10 @@ bool CoreChecks::ValidateCreateSwapchain(const VkSwapchainCreateInfoKHR& create_
577576

578577
const VkImageUsageFlags usage = shared_present_capabilities.sharedPresentSupportedUsageFlags;
579578
if (image_usage != (image_usage & shared_present_capabilities.sharedPresentSupportedUsageFlags)) {
580-
if (LogError("VUID-VkSwapchainCreateInfoKHR-imageUsage-01384", device,
581-
GetSwapchainCreateInfoKHRImageUsageLocation(create_info.pNext, create_info_loc),
582-
"(%s), but the supported flag bits for %s present mode are %s.",
583-
string_VkImageUsageFlags(image_usage).c_str(), string_VkPresentModeKHR(create_info.presentMode),
584-
string_VkImageUsageFlags(usage).c_str())) {
579+
if (LogError(
580+
"VUID-VkSwapchainCreateInfoKHR-imageUsage-01384", device, GetImageUsageLocation(create_info, create_info_loc),
581+
"(%s), but the supported flag bits for %s present mode are %s.", string_VkImageUsageFlags(image_usage).c_str(),
582+
string_VkPresentModeKHR(create_info.presentMode), string_VkImageUsageFlags(usage).c_str())) {
585583
return true;
586584
}
587585
}

layers/core_checks/core_validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,8 @@ class CoreChecks : public vvl::DeviceProxy {
10431043
const Location& loc) const;
10441044
bool ValidateImageAlignmentControlCreateInfo(const VkImageCreateInfo& create_info, const Location& create_info_loc) const;
10451045
bool ValidateImageVideo(const VkImageCreateInfo& create_info, const Location& create_info_loc,
1046-
const VkImageCreateFlags create_flags, const VkImageUsageFlags usage,
1047-
const ErrorObject& error_obj) const;
1046+
const VkImageCreateFlags create_flags, const Location& flags_loc, const VkImageUsageFlags usage,
1047+
const Location& usage_loc, const ErrorObject& error_obj) const;
10481048
bool ValidateImageSwapchain(const VkImageCreateInfo& create_info, const Location& create_info_loc,
10491049
const VkImageCreateFlags create_flags, const VkImageUsageFlags usage) const;
10501050
bool ValidateImageExternalMemory(const VkImageCreateInfo& create_info, const Location& create_info_loc,

layers/state_tracker/image_state.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ bool Image::IsCreateInfoDedicatedAllocationImageAliasingCompatible(const Image&
335335
IsQueueFamilyIndicesEqual(other_image_state.GetQueueFamilyIndexCount(), other_image_state.GetQueueFamilyIndices());
336336
}
337337
is_compatible &= GetTiling() == other_image_state.GetTiling();
338-
339338
is_compatible = is_compatible && GetExtent().width <= other_image_state.GetExtent().width &&
340339
GetExtent().height <= other_image_state.GetExtent().height &&
341340
GetExtent().depth <= other_image_state.GetExtent().depth &&

layers/stateless/sl_image.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool Device::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCre
4040
return skip;
4141
}
4242
const Location create_info_loc = error_obj.location.dot(Field::pCreateInfo);
43-
const Location create_flags_loc = GetImageCreateInfoFlagsLocation(pCreateInfo->pNext, create_info_loc);
44-
const Location usage_loc = GetImageCreateInfoUsageLocation(pCreateInfo->pNext, create_info_loc);
43+
const Location create_flags_loc = GetFlagsLocation(*pCreateInfo, create_info_loc);
44+
const Location usage_loc = GetUsageLocation(*pCreateInfo, create_info_loc);
4545
const VkImageCreateFlags create_flags = GetImageCreateFlags(*pCreateInfo);
4646
const VkImageUsageFlags usage = GetImageUsageFlags(*pCreateInfo);
4747

@@ -90,20 +90,20 @@ bool Device::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCre
9090

9191
if (create_flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
9292
if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
93-
skip |= LogError("VUID-VkImageCreateInfo-flags-00949", device, create_info_loc.dot(Field::flags),
93+
skip |= LogError("VUID-VkImageCreateInfo-flags-00949", device, create_flags_loc,
9494
"includes VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT but imageType (%s) is not VK_IMAGE_TYPE_2D.",
9595
string_VkImageType(pCreateInfo->imageType));
9696
}
9797

9898
if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
99-
skip |= LogError("VUID-VkImageCreateInfo-flags-08865", device, create_info_loc.dot(Field::flags),
99+
skip |= LogError("VUID-VkImageCreateInfo-flags-08865", device, create_flags_loc,
100100
"includes VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT but extent.width (%" PRIu32
101101
") is not equal to extent.height (%" PRIu32 ").",
102102
pCreateInfo->extent.width, pCreateInfo->extent.height);
103103
}
104104

105105
if (pCreateInfo->arrayLayers < 6) {
106-
skip |= LogError("VUID-VkImageCreateInfo-flags-08866", device, create_info_loc.dot(Field::flags),
106+
skip |= LogError("VUID-VkImageCreateInfo-flags-08866", device, create_flags_loc,
107107
"includes VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT but arrayLayers (%" PRIu32 ") is less than 6.",
108108
pCreateInfo->arrayLayers);
109109
}
@@ -151,14 +151,14 @@ bool Device::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCre
151151
}
152152

153153
if ((create_flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
154-
skip |= LogError("VUID-VkImageCreateInfo-flags-00950", device, create_info_loc.dot(Field::flags),
154+
skip |= LogError("VUID-VkImageCreateInfo-flags-00950", device, create_flags_loc,
155155
"includes VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
156156
"imageType is %s.",
157157
string_VkImageType(pCreateInfo->imageType));
158158
}
159159

160160
if ((create_flags & VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
161-
skip |= LogError("VUID-VkImageCreateInfo-flags-07755", device, create_info_loc.dot(Field::flags),
161+
skip |= LogError("VUID-VkImageCreateInfo-flags-07755", device, create_flags_loc,
162162
"includes VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT but "
163163
"imageType is %s.",
164164
string_VkImageType(pCreateInfo->imageType));
@@ -538,6 +538,7 @@ bool Device::ValidateCreateImageStencilUsage(const VkImageCreateInfo& create_inf
538538
if (!stencil_usage_opt.has_value()) {
539539
return skip;
540540
}
541+
Location stencil_usage_loc = create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage);
541542
const VkImageUsageFlags stencil_usage = stencil_usage_opt.value();
542543

543544
if ((stencil_usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
@@ -546,25 +547,22 @@ bool Device::ValidateCreateImageStencilUsage(const VkImageCreateInfo& create_inf
546547
if ((stencil_usage & ~legal_flags) != 0) {
547548
// Todo, update when VkImageStencilUsage2CreateInfoKHR VUID gets a number
548549
const char* vuid = "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539";
549-
skip |= LogError(vuid, device, create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage),
550-
"is %s.", string_VkImageUsageFlags(stencil_usage).c_str());
550+
skip |= LogError(vuid, device, stencil_usage_loc, "is %s.", string_VkImageUsageFlags(stencil_usage).c_str());
551551
}
552552
}
553553

554554
if (vkuFormatIsDepthOrStencil(create_info.format)) {
555555
if ((stencil_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
556556
if (create_info.extent.width > phys_dev_props.limits.maxFramebufferWidth) {
557-
skip |= LogError("VUID-VkImageCreateInfo-Format-02536", device,
558-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage),
557+
skip |= LogError("VUID-VkImageCreateInfo-Format-02536", device, stencil_usage_loc,
559558
"includes VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width (%" PRIu32
560559
") exceeds device "
561560
"maxFramebufferWidth (%" PRIu32 ")",
562561
create_info.extent.width, phys_dev_props.limits.maxFramebufferWidth);
563562
}
564563

565564
if (create_info.extent.height > phys_dev_props.limits.maxFramebufferHeight) {
566-
skip |= LogError("VUID-VkImageCreateInfo-format-02537", device,
567-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage),
565+
skip |= LogError("VUID-VkImageCreateInfo-format-02537", device, stencil_usage_loc,
568566
"includes VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height (%" PRIu32
569567
") exceeds device "
570568
"maxFramebufferHeight (%" PRIu32 ")",
@@ -574,8 +572,7 @@ bool Device::ValidateCreateImageStencilUsage(const VkImageCreateInfo& create_inf
574572

575573
if (!enabled_features.shaderStorageImageMultisample && ((stencil_usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
576574
(create_info.samples != VK_SAMPLE_COUNT_1_BIT)) {
577-
skip |= LogError("VUID-VkImageCreateInfo-format-02538", device,
578-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage),
575+
skip |= LogError("VUID-VkImageCreateInfo-format-02538", device, stencil_usage_loc,
579576
"includes VK_IMAGE_USAGE_STORAGE_BIT and format is %s and samples is %s, but "
580577
"shaderStorageImageMultisample feature was not enabled.",
581578
string_VkFormat(create_info.format), string_VkSampleCountFlagBits(create_info.samples));
@@ -585,28 +582,24 @@ bool Device::ValidateCreateImageStencilUsage(const VkImageCreateInfo& create_inf
585582
((stencil_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
586583
skip |= LogError("VUID-VkImageCreateInfo-format-02795", device, usage_loc, "is (%s), format is %s, and %s is %s",
587584
string_VkImageUsageFlags(usage).c_str(), string_VkFormat(create_info.format),
588-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage).Fields().c_str(),
589-
string_VkImageUsageFlags(stencil_usage).c_str());
585+
stencil_usage_loc.Fields().c_str(), string_VkImageUsageFlags(stencil_usage).c_str());
590586
} else if (((usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
591587
((stencil_usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
592588
skip |= LogError("VUID-VkImageCreateInfo-format-02796", device, usage_loc, "is (%s), format is %s, and %s is %s",
593589
string_VkImageUsageFlags(usage).c_str(), string_VkFormat(create_info.format),
594-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage).Fields().c_str(),
595-
string_VkImageUsageFlags(stencil_usage).c_str());
590+
stencil_usage_loc.Fields().c_str(), string_VkImageUsageFlags(stencil_usage).c_str());
596591
}
597592

598593
if (((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
599594
((stencil_usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
600595
skip |= LogError("VUID-VkImageCreateInfo-format-02797", device, usage_loc, "is (%s), format is %s, and %s is %s",
601596
string_VkImageUsageFlags(usage).c_str(), string_VkFormat(create_info.format),
602-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage).Fields().c_str(),
603-
string_VkImageUsageFlags(stencil_usage).c_str());
597+
stencil_usage_loc.Fields().c_str(), string_VkImageUsageFlags(stencil_usage).c_str());
604598
} else if (((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
605599
((stencil_usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
606600
skip |= LogError("VUID-VkImageCreateInfo-format-02798", device, usage_loc, "is (%s), format is %s, and %s is %s",
607601
string_VkImageUsageFlags(usage).c_str(), string_VkFormat(create_info.format),
608-
create_info_loc.pNext(Struct::VkImageStencilUsageCreateInfo, Field::stencilUsage).Fields().c_str(),
609-
string_VkImageUsageFlags(stencil_usage).c_str());
602+
stencil_usage_loc.Fields().c_str(), string_VkImageUsageFlags(stencil_usage).c_str());
610603
}
611604
}
612605

0 commit comments

Comments
 (0)