Skip to content

Commit

Permalink
layers: Fix swapchain image debug marker logic
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed May 13, 2024
1 parent c7d8d71 commit e12f3bb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions layers/object_tracker/object_tracker_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ bool ObjectLifetimes::PreCallValidateDebugMarkerSetObjectTagEXT(VkDevice device,
error_obj.location.dot(Field::pTagInfo).dot(Field::object), "is VK_NULL_HANDLE.");
} else if (!object_map[object_type].contains(pTagInfo->object)) {
// Need to check for swapchain images as they are not in object_map
if (object_type != kVulkanObjectTypeImage && !swapchain_image_map.contains(pTagInfo->object)) {
if (object_type != kVulkanObjectTypeImage || !swapchain_image_map.contains(pTagInfo->object)) {
skip |= LogError("VUID-VkDebugMarkerObjectTagInfoEXT-object-01495", device,
error_obj.location.dot(Field::pTagInfo).dot(Field::objectType),
"(%s) doesn't match the object (0x%" PRIx64 ").",
Expand All @@ -1116,7 +1116,7 @@ bool ObjectLifetimes::PreCallValidateDebugMarkerSetObjectNameEXT(VkDevice device
error_obj.location.dot(Field::pNameInfo).dot(Field::object), "is VK_NULL_HANDLE.");
} else if (!object_map[object_type].contains(pNameInfo->object)) {
// Need to check for swapchain images as they are not in object_map
if (object_type != kVulkanObjectTypeImage && !swapchain_image_map.contains(pNameInfo->object)) {
if (object_type != kVulkanObjectTypeImage || !swapchain_image_map.contains(pNameInfo->object)) {
skip |= LogError("VUID-VkDebugMarkerObjectNameInfoEXT-object-01492", device,
error_obj.location.dot(Field::pNameInfo).dot(Field::objectType),
"(%s) doesn't match the object (0x%" PRIx64 ").",
Expand Down
62 changes: 62 additions & 0 deletions tests/unit/debug_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,65 @@ TEST_F(NegativeDebugExtensions, DebugLabelSecondaryCommandBuffer) {
m_errorMonitor->VerifyFound();
cb.end();
}

TEST_F(NegativeDebugExtensions, SwapchainImagesDebugMarker) {
TEST_DESCRIPTION("https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/7977");
SetTargetApiVersion(VK_API_VERSION_1_1);
AddRequiredExtensions(VK_EXT_DEBUG_MARKER_EXTENSION_NAME);
AddSurfaceExtension();
RETURN_IF_SKIP(Init());
RETURN_IF_SKIP(InitSurface());

SurfaceInformation info = GetSwapchainInfo(m_surface);
InitSwapchainInfo();

VkSwapchainCreateInfoKHR swapchain_create_info = vku::InitStructHelper();
swapchain_create_info.surface = m_surface;
swapchain_create_info.minImageCount = info.surface_capabilities.minImageCount;
swapchain_create_info.imageFormat = info.surface_formats[0].format;
swapchain_create_info.imageColorSpace = info.surface_formats[0].colorSpace;
swapchain_create_info.imageExtent = {info.surface_capabilities.minImageExtent.width,
info.surface_capabilities.minImageExtent.height};
swapchain_create_info.imageArrayLayers = 1;
swapchain_create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapchain_create_info.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
swapchain_create_info.compositeAlpha = info.surface_composite_alpha;
swapchain_create_info.presentMode = info.surface_non_shared_present_mode;
swapchain_create_info.clipped = VK_FALSE;
swapchain_create_info.oldSwapchain = VK_NULL_HANDLE;

VkSwapchainKHR swapchain;
vk::CreateSwapchainKHR(device(), &swapchain_create_info, nullptr, &swapchain);

uint32_t imageCount;
vk::GetSwapchainImagesKHR(device(), swapchain, &imageCount, nullptr);
std::vector<VkImage> images(imageCount);
vk::GetSwapchainImagesKHR(device(), swapchain, &imageCount, images.data());

{
VkDebugMarkerObjectNameInfoEXT name_info = vku::InitStructHelper();
name_info.object = (uint64_t)images[0];
name_info.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT;
std::string image_name = "swapchain [0]";
name_info.pObjectName = image_name.c_str();
m_errorMonitor->SetDesiredError("VUID-VkDebugMarkerObjectNameInfoEXT-object-01492");
vk::DebugMarkerSetObjectNameEXT(device(), &name_info);
m_errorMonitor->VerifyFound();
}

{
int tags[2] = {1, 2};
VkDebugMarkerObjectTagInfoEXT name_info = vku::InitStructHelper();
name_info.object = (uint64_t)images[0];
name_info.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT;
name_info.tagName = 1;
name_info.tagSize = 2;
name_info.pTag = tags;
m_errorMonitor->SetDesiredError("VUID-VkDebugMarkerObjectTagInfoEXT-object-01495");
vk::DebugMarkerSetObjectTagEXT(device(), &name_info);
m_errorMonitor->VerifyFound();
}

vk::DestroySwapchainKHR(device(), swapchain, nullptr);
}

0 comments on commit e12f3bb

Please sign in to comment.