From 0b0be96ac2cf958866c0a26daf11b7ff86c6936b Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Tue, 11 Apr 2017 15:43:49 -0600 Subject: [PATCH] layers: Switch to codegen'd obj_type string helper Updated LVTs for error string changes as well. Change-Id: I5e0da92a9859e8ada7374af42a21a3f8f7629fdd --- layers/object_tracker.cpp | 27 ++++++++++++--------------- layers/object_tracker.h | 32 -------------------------------- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/layers/object_tracker.cpp b/layers/object_tracker.cpp index b82114d..9c9f74a 100644 --- a/layers/object_tracker.cpp +++ b/layers/object_tracker.cpp @@ -159,8 +159,7 @@ static bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, V } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, object_handle, __LINE__, VALIDATION_ERROR_00097, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", - object_name[VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT], object_handle, - validation_error_map[VALIDATION_ERROR_00097]); + object_string[kVulkanObjectTypeCommandBuffer], object_handle, validation_error_map[VALIDATION_ERROR_00097]); } return skip; } @@ -202,8 +201,7 @@ static bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_p } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, object_handle, __LINE__, VALIDATION_ERROR_00920, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", - object_name[VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT], object_handle, - validation_error_map[VALIDATION_ERROR_00920]); + object_string[kVulkanObjectTypeDescriptorSet], object_handle, validation_error_map[VALIDATION_ERROR_00920]); } return skip; } @@ -266,7 +264,7 @@ static void CreateObject(T1 dispatchable_object, T2 object, VulkanObjectType obj VkDebugReportObjectTypeEXT debug_object_type = GetDebugReportEnum(object_type); log_msg(instance_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, - object_name[debug_object_type], object_handle); + object_string[object_type], object_handle); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = object_type; @@ -301,8 +299,8 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType ob log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", - object_name[debug_object_type], reinterpret_cast(object), device_data->num_total_objects, - device_data->num_objects[pNode->object_type], object_name[debug_object_type]); + object_string[object_type], reinterpret_cast(object), device_data->num_total_objects, + device_data->num_objects[pNode->object_type], object_string[object_type]); auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false; if (allocated_with_custom && !custom_allocator && expected_custom_allocator_code != VALIDATION_ERROR_UNDEFINED) { @@ -311,13 +309,13 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType ob log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, expected_custom_allocator_code, LayerName, "Custom allocator not specified while destroying %s obj 0x%" PRIxLEAST64 " but specified at creation. %s", - object_name[debug_object_type], object_handle, validation_error_map[expected_custom_allocator_code]); + object_string[object_type], object_handle, validation_error_map[expected_custom_allocator_code]); } else if (!allocated_with_custom && custom_allocator && expected_default_allocator_code != VALIDATION_ERROR_UNDEFINED) { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, expected_default_allocator_code, LayerName, "Custom allocator specified while destroying %s obj 0x%" PRIxLEAST64 " but not specified at creation. %s", - object_name[debug_object_type], object_handle, validation_error_map[expected_default_allocator_code]); + object_string[object_type], object_handle, validation_error_map[expected_default_allocator_code]); } delete pNode; @@ -326,7 +324,7 @@ static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType ob log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, object_handle, __LINE__, OBJTRACK_UNKNOWN_OBJECT, LayerName, "Unable to remove %s obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", - object_name[debug_object_type], object_handle); + object_string[object_type], object_handle); } } } @@ -370,7 +368,7 @@ static bool ValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType o // Report an error if object was not found anywhere return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, invalid_handle_code, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", - object_name[debug_object_type], object_handle, validation_error_map[invalid_handle_code]); + object_string[object_type], object_handle, validation_error_map[invalid_handle_code]); } } return false; @@ -379,13 +377,12 @@ static bool ValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType o static void DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, enum UNIQUE_VALIDATION_ERROR_CODE error_code) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); - VkDebugReportObjectTypeEXT debug_object_type = GetDebugReportEnum(object_type); for (auto item = device_data->object_map[object_type].begin(); item != device_data->object_map[object_type].end();) { OBJTRACK_NODE *object_info = item->second; - log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_info->handle, __LINE__, - error_code, LayerName, + log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, GetDebugReportEnum(object_type), object_info->handle, + __LINE__, error_code, LayerName, "OBJ ERROR : For device 0x%" PRIxLEAST64 ", %s object 0x%" PRIxLEAST64 " has not been destroyed. %s", - reinterpret_cast(device), object_name[debug_object_type], object_info->handle, + reinterpret_cast(device), object_string[object_type], object_info->handle, validation_error_map[error_code]); item = device_data->object_map[object_type].erase(item); } diff --git a/layers/object_tracker.h b/layers/object_tracker.h index 3c53630..58ad571 100644 --- a/layers/object_tracker.h +++ b/layers/object_tracker.h @@ -160,38 +160,6 @@ static instance_table_map ot_instance_table_map; static std::mutex global_lock; static uint64_t object_track_index = 0; -// Array of object name strings for OBJECT_TYPE enum conversion -static const char *object_name[VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT] = { - "Unknown", // VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN - "Instance", // VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT - "Physical Device", // VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT - "Device", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT - "Queue", // VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT - "Semaphore", // VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT - "Command Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT - "Fence", // VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT - "Device Memory", // VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT - "Buffer", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT - "Image", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT - "Event", // VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT - "Query Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT - "Buffer View", // VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT - "Image View", // VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT - "Shader Module", // VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT - "Pipeline Cache", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT - "Pipeline Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT - "Render Pass", // VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT - "Pipeline", // VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT - "Descriptor Set Layout", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT - "Sampler", // VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT - "Descriptor Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT - "Descriptor Set", // VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT - "Framebuffer", // VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT - "Command Pool", // VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT - "SurfaceKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT - "SwapchainKHR", // VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT - "Debug Report"}; // VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT - #include "vk_dispatch_table_helper.h" } // namespace object_tracker -- 2.7.4