layers: Switch CV over to layer object types
Convert internal uses of VkDebugReportObjectTypeEXT for the core-
validation layer to use the internal layer-povided object-type.
Also modified tests for changed error text.
Change-Id: If080f4bf452ead0c6fecc648309bfd95b27fc0ce
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index e177397..61054b7 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -775,7 +775,7 @@
bool PreCallValidateDestroyImage(layer_data *device_data, VkImage image, IMAGE_STATE **image_state, VK_OBJECT *obj_struct) {
const CHECK_DISABLED *disabled = core_validation::GetDisables(device_data);
*image_state = core_validation::GetImageState(device_data, image);
- *obj_struct = {reinterpret_cast<uint64_t &>(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(image), kVulkanObjectTypeImage };
if (disabled->destroy_image) return false;
bool skip = false;
if (*image_state) {
@@ -793,7 +793,7 @@
core_validation::RemoveImageMemoryRange(obj_struct.handle, mem_info);
}
}
- core_validation::ClearMemoryObjectBindings(device_data, obj_struct.handle, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT);
+ core_validation::ClearMemoryObjectBindings(device_data, obj_struct.handle, kVulkanObjectTypeImage);
// Remove image from imageMap
core_validation::GetImageMap(device_data)->erase(image);
std::unordered_map<VkImage, std::vector<ImageSubresourcePair>> *imageSubresourceMap =
@@ -2248,12 +2248,12 @@
// Helper function to validate correct usage bits set for buffers or images. Verify that (actual & desired) flags != 0 or, if strict
// is true, verify that (actual & desired) flags == desired
static bool validate_usage_flags(layer_data *device_data, VkFlags actual, VkFlags desired, VkBool32 strict, uint64_t obj_handle,
- VkDebugReportObjectTypeEXT obj_type, int32_t const msgCode, char const *ty_str,
- char const *func_name, char const *usage_str) {
+ VulkanObjectType obj_type, int32_t const msgCode, char const *func_name, char const *usage_str) {
const debug_report_data *report_data = core_validation::GetReportData(device_data);
bool correct_usage = false;
bool skip = false;
+ const char *type_str = object_string[obj_type];
if (strict) {
correct_usage = ((actual & desired) == desired);
} else {
@@ -2262,16 +2262,17 @@
if (!correct_usage) {
if (msgCode == -1) {
// TODO: Fix callers with msgCode == -1 to use correct validation checks.
- skip = log_msg(
- report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, obj_type, obj_handle, __LINE__, MEMTRACK_INVALID_USAGE_FLAG, "MEM",
- "Invalid usage flag for %s 0x%" PRIxLEAST64 " used by %s. In this case, %s should have %s set during creation.",
- ty_str, obj_handle, func_name, ty_str, usage_str);
+ skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, GetDebugReportEnum[obj_type], obj_handle, __LINE__,
+ MEMTRACK_INVALID_USAGE_FLAG, "MEM",
+ "Invalid usage flag for %s 0x%" PRIxLEAST64
+ " used by %s. In this case, %s should have %s set during creation.",
+ type_str, obj_handle, func_name, type_str, usage_str);
} else {
const char *valid_usage = (msgCode == -1) ? "" : validation_error_map[msgCode];
- skip = log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, obj_type, obj_handle, __LINE__, msgCode, "MEM",
- "Invalid usage flag for %s 0x%" PRIxLEAST64
- " used by %s. In this case, %s should have %s set during creation. %s",
- ty_str, obj_handle, func_name, ty_str, usage_str, valid_usage);
+ skip = log_msg(
+ report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, GetDebugReportEnum[obj_type], obj_handle, __LINE__, msgCode, "MEM",
+ "Invalid usage flag for %s 0x%" PRIxLEAST64 " used by %s. In this case, %s should have %s set during creation. %s",
+ type_str, obj_handle, func_name, type_str, usage_str, valid_usage);
}
}
return skip;
@@ -2282,8 +2283,8 @@
bool ValidateImageUsageFlags(layer_data *device_data, IMAGE_STATE const *image_state, VkFlags desired, VkBool32 strict,
int32_t const msgCode, char const *func_name, char const *usage_string) {
return validate_usage_flags(device_data, image_state->createInfo.usage, desired, strict,
- reinterpret_cast<const uint64_t &>(image_state->image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
- msgCode, "image", func_name, usage_string);
+ reinterpret_cast<const uint64_t &>(image_state->image), kVulkanObjectTypeImage, msgCode, func_name,
+ usage_string);
}
// Helper function to validate usage flags for buffers. For given buffer_state send actual vs. desired usage off to helper above
@@ -2291,8 +2292,8 @@
bool ValidateBufferUsageFlags(layer_data *device_data, BUFFER_STATE const *buffer_state, VkFlags desired, VkBool32 strict,
int32_t const msgCode, char const *func_name, char const *usage_string) {
return validate_usage_flags(device_data, buffer_state->createInfo.usage, desired, strict,
- reinterpret_cast<const uint64_t &>(buffer_state->buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
- msgCode, "buffer", func_name, usage_string);
+ reinterpret_cast<const uint64_t &>(buffer_state->buffer), kVulkanObjectTypeBuffer, msgCode,
+ func_name, usage_string);
}
bool PreCallValidateCreateBuffer(layer_data *device_data, const VkBufferCreateInfo *pCreateInfo) {
@@ -2573,7 +2574,7 @@
bool PreCallValidateDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state,
VK_OBJECT *obj_struct) {
*image_view_state = GetImageViewState(device_data, image_view);
- *obj_struct = {reinterpret_cast<uint64_t &>(image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(image_view), kVulkanObjectTypeImageView};
if (GetDisables(device_data)->destroy_image_view) return false;
bool skip = false;
if (*image_view_state) {
@@ -2591,7 +2592,7 @@
bool PreCallValidateDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE **buffer_state, VK_OBJECT *obj_struct) {
*buffer_state = GetBufferState(device_data, buffer);
- *obj_struct = {reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(buffer), kVulkanObjectTypeBuffer };
if (GetDisables(device_data)->destroy_buffer) return false;
bool skip = false;
if (*buffer_state) {
@@ -2608,14 +2609,14 @@
core_validation::RemoveBufferMemoryRange(reinterpret_cast<uint64_t &>(buffer), mem_info);
}
}
- ClearMemoryObjectBindings(device_data, reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT);
+ ClearMemoryObjectBindings(device_data, reinterpret_cast<uint64_t &>(buffer), kVulkanObjectTypeBuffer);
GetBufferMap(device_data)->erase(buffer_state->buffer);
}
bool PreCallValidateDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state,
VK_OBJECT *obj_struct) {
*buffer_view_state = GetBufferViewState(device_data, buffer_view);
- *obj_struct = {reinterpret_cast<uint64_t &>(buffer_view), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(buffer_view), kVulkanObjectTypeBufferView };
if (GetDisables(device_data)->destroy_buffer_view) return false;
bool skip = false;
if (*buffer_view_state) {
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 15656ee..6218d14 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -407,11 +407,11 @@
}
// Return ptr to memory binding for given handle of specified type
-static BINDABLE *GetObjectMemBinding(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type) {
+static BINDABLE *GetObjectMemBinding(layer_data *dev_data, uint64_t handle, VulkanObjectType type) {
switch (type) {
- case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT:
+ case kVulkanObjectTypeImage:
return GetImageState(dev_data, VkImage(handle));
- case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT:
+ case kVulkanObjectTypeBuffer:
return GetBufferState(dev_data, VkBuffer(handle));
default:
break;
@@ -480,8 +480,8 @@
}
// For given bound_object_handle, bound to given mem allocation, verify that the range for the bound object is valid
-static bool ValidateMemoryIsValid(layer_data *dev_data, VkDeviceMemory mem, uint64_t bound_object_handle,
- VkDebugReportObjectTypeEXT type, const char *functionName) {
+static bool ValidateMemoryIsValid(layer_data *dev_data, VkDeviceMemory mem, uint64_t bound_object_handle, VulkanObjectType type,
+ const char *functionName) {
DEVICE_MEM_INFO *mem_info = GetMemObjInfo(dev_data, mem);
if (mem_info) {
if (!mem_info->bound_ranges[bound_object_handle].valid) {
@@ -489,7 +489,7 @@
reinterpret_cast<uint64_t &>(mem), __LINE__, MEMTRACK_INVALID_MEM_REGION, "MEM",
"%s: Cannot read invalid region of memory allocation 0x%" PRIx64 " for bound %s object 0x%" PRIx64
", please fill the memory before using.",
- functionName, reinterpret_cast<uint64_t &>(mem), object_type_to_string(type), bound_object_handle);
+ functionName, reinterpret_cast<uint64_t &>(mem), object_string[type], bound_object_handle);
}
}
return false;
@@ -507,14 +507,14 @@
}
} else {
return ValidateMemoryIsValid(dev_data, image_state->binding.mem, reinterpret_cast<uint64_t &>(image_state->image),
- VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, functionName);
+ kVulkanObjectTypeImage, functionName);
}
return false;
}
// For given buffer_state, verify that the range it's bound to is valid
bool ValidateBufferMemoryIsValid(layer_data *dev_data, BUFFER_STATE *buffer_state, const char *functionName) {
return ValidateMemoryIsValid(dev_data, buffer_state->binding.mem, reinterpret_cast<uint64_t &>(buffer_state->buffer),
- VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, functionName);
+ kVulkanObjectTypeBuffer, functionName);
}
// For the given memory allocation, set the range bound by the given handle object to the valid param value
static void SetMemoryValid(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, bool valid) {
@@ -564,7 +564,7 @@
void AddCommandBufferBindingSampler(GLOBAL_CB_NODE *cb_node, SAMPLER_STATE *sampler_state) {
sampler_state->cb_bindings.insert(cb_node);
cb_node->object_bindings.insert(
- {reinterpret_cast<uint64_t &>(sampler_state->sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT});
+ {reinterpret_cast<uint64_t &>(sampler_state->sampler), kVulkanObjectTypeSampler });
}
// Create binding link between given image node and command buffer node
@@ -581,7 +581,7 @@
}
}
// Now update cb binding for image
- cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(image_state->image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT});
+ cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(image_state->image), kVulkanObjectTypeImage });
image_state->cb_bindings.insert(cb_node);
}
}
@@ -591,7 +591,7 @@
// First add bindings for imageView
view_state->cb_bindings.insert(cb_node);
cb_node->object_bindings.insert(
- {reinterpret_cast<uint64_t &>(view_state->image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT});
+ {reinterpret_cast<uint64_t &>(view_state->image_view), kVulkanObjectTypeImageView });
auto image_state = GetImageState(dev_data, view_state->create_info.image);
// Add bindings for image within imageView
if (image_state) {
@@ -611,7 +611,7 @@
}
}
// Now update cb binding for buffer
- cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(buffer_state->buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT});
+ cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(buffer_state->buffer), kVulkanObjectTypeBuffer });
buffer_state->cb_bindings.insert(cb_node);
}
@@ -620,7 +620,7 @@
// First add bindings for bufferView
view_state->cb_bindings.insert(cb_node);
cb_node->object_bindings.insert(
- {reinterpret_cast<uint64_t &>(view_state->buffer_view), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT});
+ {reinterpret_cast<uint64_t &>(view_state->buffer_view), kVulkanObjectTypeBufferView });
auto buffer_state = GetBufferState(dev_data, view_state->create_info.buffer);
// Add bindings for buffer within bufferView
if (buffer_state) {
@@ -649,7 +649,7 @@
}
// Clear a single object binding from given memory object, or report error if binding is missing
-static bool ClearMemoryObjectBinding(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type, VkDeviceMemory mem) {
+static bool ClearMemoryObjectBinding(layer_data *dev_data, uint64_t handle, VulkanObjectType type, VkDeviceMemory mem) {
DEVICE_MEM_INFO *mem_info = GetMemObjInfo(dev_data, mem);
// This obj is bound to a memory object. Remove the reference to this object in that memory object's list
if (mem_info) {
@@ -661,7 +661,7 @@
// ClearMemoryObjectBindings clears the binding of objects to memory
// For the given object it pulls the memory bindings and makes sure that the bindings
// no longer refer to the object being cleared. This occurs when objects are destroyed.
-bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type) {
+bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VulkanObjectType type) {
bool skip = false;
BINDABLE *mem_binding = GetObjectMemBinding(dev_data, handle, type);
if (mem_binding) {
@@ -720,8 +720,7 @@
// SetMemBinding is used to establish immutable, non-sparse binding between a single image/buffer object and memory object.
// Corresponding valid usage checks are in ValidateSetMemBinding().
-static void SetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, VkDebugReportObjectTypeEXT type,
- const char *apiName) {
+static void SetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, VulkanObjectType type, const char *apiName) {
if (mem != VK_NULL_HANDLE) {
BINDABLE *mem_binding = GetObjectMemBinding(dev_data, handle, type);
assert(mem_binding);
@@ -730,7 +729,7 @@
mem_info->obj_bindings.insert({handle, type});
// For image objects, make sure default memory state is correctly set
// TODO : What's the best/correct way to handle this?
- if (VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT == type) {
+ if (kVulkanObjectTypeImage == type) {
auto const image_state = GetImageState(dev_data, VkImage(handle));
if (image_state) {
VkImageCreateInfo ici = image_state->createInfo;
@@ -751,7 +750,7 @@
// Otherwise, add reference from objectInfo to memoryInfo
// Add reference off of objInfo
// TODO: We may need to refactor or pass in multiple valid usage statements to handle multiple valid usage conditions.
-static bool ValidateSetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, VkDebugReportObjectTypeEXT type,
+static bool ValidateSetMemBinding(layer_data *dev_data, VkDeviceMemory mem, uint64_t handle, VulkanObjectType type,
const char *apiName) {
bool skip_call = false;
// It's an error to bind an object to NULL memory
@@ -811,7 +810,7 @@
// Add reference from objectInfo to memoryInfo
// Add reference off of object's binding info
// Return VK_TRUE if addition is successful, VK_FALSE otherwise
-static bool SetSparseMemBinding(layer_data *dev_data, MEM_BINDING binding, uint64_t handle, VkDebugReportObjectTypeEXT type,
+static bool SetSparseMemBinding(layer_data *dev_data, MEM_BINDING binding, uint64_t handle, VulkanObjectType type,
const char *apiName) {
bool skip_call = VK_FALSE;
// Handle NULL case separately, just clear previous binding & decrement reference
@@ -3497,9 +3496,9 @@
static bool ReportInvalidCommandBuffer(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, const char *call_source) {
bool skip = false;
for (auto obj : cb_state->broken_bindings) {
- const char *type_str = object_type_to_string(obj.type);
+ const char *type_str = object_string[obj.type];
// Descriptor sets are a special case that can be either destroyed or updated to invalidate a CB
- const char *cause_str = (obj.type == VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT) ? "destroyed or updated" : "destroyed";
+ const char *cause_str = (obj.type == kVulkanObjectTypeDescriptorSet) ? "destroyed or updated" : "destroyed";
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
reinterpret_cast<uint64_t &>(cb_state->commandBuffer), __LINE__, DRAWSTATE_INVALID_COMMAND_BUFFER, "DS",
"You are adding %s to command buffer 0x%p that is invalid because bound %s 0x%" PRIxLEAST64 " was %s.",
@@ -4347,12 +4346,11 @@
}
if (!found) {
- auto type_string = (object->type == VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT ? "image" : "buffer");
- skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, object->type, object->handle, __LINE__,
- DRAWSTATE_INVALID_QUEUE_FAMILY, "DS",
+ skip = log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, GetDebugReportEnum[object->type], object->handle,
+ __LINE__, DRAWSTATE_INVALID_QUEUE_FAMILY, "DS",
"vkQueueSubmit: Command buffer 0x%" PRIxLEAST64 " contains %s 0x%" PRIxLEAST64
" which was not created allowing concurrent access to this queue family %d.",
- reinterpret_cast<uint64_t>(cb_node->commandBuffer), type_string, object->handle,
+ reinterpret_cast<uint64_t>(cb_node->commandBuffer), object_string[object->type], object->handle,
queue_state->queueFamilyIndex);
}
}
@@ -4379,13 +4377,13 @@
// Ensure that any bound images or buffers created with SHARING_MODE_CONCURRENT have access to the current queue family
for (auto object : pCB->object_bindings) {
- if (object.type == VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT) {
+ if (object.type == kVulkanObjectTypeImage) {
auto image_state = GetImageState(dev_data, reinterpret_cast<VkImage &>(object.handle));
if (image_state && image_state->createInfo.sharingMode == VK_SHARING_MODE_CONCURRENT) {
skip_call |= ValidImageBufferQueue(dev_data, pCB, &object, queue, image_state->createInfo.queueFamilyIndexCount,
image_state->createInfo.pQueueFamilyIndices);
}
- } else if (object.type == VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT) {
+ } else if (object.type == kVulkanObjectTypeBuffer) {
auto buffer_state = GetBufferState(dev_data, reinterpret_cast<VkBuffer &>(object.handle));
if (buffer_state && buffer_state->createInfo.sharingMode == VK_SHARING_MODE_CONCURRENT) {
skip_call |=
@@ -4663,16 +4661,17 @@
if (dev_data->instance_data->disabled.object_in_use) return false;
bool skip = false;
if (obj_node->in_use.load()) {
- skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, obj_struct.type, obj_struct.handle, __LINE__,
- error_code, "DS", "Cannot delete %s 0x%" PRIx64 " that is currently in use by a command buffer. %s",
- object_type_to_string(obj_struct.type), obj_struct.handle, validation_error_map[error_code]);
+ skip |=
+ log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, GetDebugReportEnum[obj_struct.type], obj_struct.handle,
+ __LINE__, error_code, "DS", "Cannot delete %s 0x%" PRIx64 " that is currently in use by a command buffer. %s",
+ object_string[obj_struct.type], obj_struct.handle, validation_error_map[error_code]);
}
return skip;
}
static bool PreCallValidateFreeMemory(layer_data *dev_data, VkDeviceMemory mem, DEVICE_MEM_INFO **mem_info, VK_OBJECT *obj_struct) {
*mem_info = GetMemObjInfo(dev_data, mem);
- *obj_struct = {reinterpret_cast<uint64_t &>(mem), VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(mem), kVulkanObjectTypeDeviceMemory};
if (dev_data->instance_data->disabled.free_memory) return false;
bool skip = false;
if (*mem_info) {
@@ -4684,17 +4683,17 @@
static void PostCallRecordFreeMemory(layer_data *dev_data, VkDeviceMemory mem, DEVICE_MEM_INFO *mem_info, VK_OBJECT obj_struct) {
// Clear mem binding for any bound objects
for (auto obj : mem_info->obj_bindings) {
- log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, obj.type, obj.handle, __LINE__, MEMTRACK_FREED_MEM_REF,
- "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64, obj.handle,
- (uint64_t)mem_info->mem);
+ log_msg(dev_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, GetDebugReportEnum[obj.type], obj.handle, __LINE__,
+ MEMTRACK_FREED_MEM_REF, "MEM", "VK Object 0x%" PRIxLEAST64 " still has a reference to mem obj 0x%" PRIxLEAST64,
+ obj.handle, (uint64_t)mem_info->mem);
switch (obj.type) {
- case VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT: {
+ case kVulkanObjectTypeImage: {
auto image_state = GetImageState(dev_data, reinterpret_cast<VkImage &>(obj.handle));
assert(image_state); // Any destroyed images should already be removed from bindings
image_state->binding.mem = MEMORY_UNBOUND;
break;
}
- case VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT: {
+ case kVulkanObjectTypeBuffer: {
auto buffer_state = GetBufferState(dev_data, reinterpret_cast<VkBuffer &>(obj.handle));
assert(buffer_state); // Any destroyed buffers should already be removed from bindings
buffer_state->binding.mem = MEMORY_UNBOUND;
@@ -5014,7 +5013,7 @@
static bool PreCallValidateDestroyFence(layer_data *dev_data, VkFence fence, FENCE_NODE **fence_node, VK_OBJECT *obj_struct) {
*fence_node = GetFenceNode(dev_data, fence);
- *obj_struct = {reinterpret_cast<uint64_t &>(fence), VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(fence), kVulkanObjectTypeFence};
if (dev_data->instance_data->disabled.destroy_fence) return false;
bool skip = false;
if (*fence_node) {
@@ -5048,7 +5047,7 @@
static bool PreCallValidateDestroySemaphore(layer_data *dev_data, VkSemaphore semaphore, SEMAPHORE_NODE **sema_node,
VK_OBJECT *obj_struct) {
*sema_node = GetSemaphoreNode(dev_data, semaphore);
- *obj_struct = {reinterpret_cast<uint64_t &>(semaphore), VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(semaphore), kVulkanObjectTypeSemaphore};
if (dev_data->instance_data->disabled.destroy_semaphore) return false;
bool skip = false;
if (*sema_node) {
@@ -5075,7 +5074,7 @@
static bool PreCallValidateDestroyEvent(layer_data *dev_data, VkEvent event, EVENT_STATE **event_state, VK_OBJECT *obj_struct) {
*event_state = GetEventNode(dev_data, event);
- *obj_struct = {reinterpret_cast<uint64_t &>(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent};
if (dev_data->instance_data->disabled.destroy_event) return false;
bool skip = false;
if (*event_state) {
@@ -5108,7 +5107,7 @@
static bool PreCallValidateDestroyQueryPool(layer_data *dev_data, VkQueryPool query_pool, QUERY_POOL_NODE **qp_state,
VK_OBJECT *obj_struct) {
*qp_state = GetQueryPoolNode(dev_data, query_pool);
- *obj_struct = {reinterpret_cast<uint64_t &>(query_pool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(query_pool), kVulkanObjectTypeQueryPool};
if (dev_data->instance_data->disabled.destroy_query_pool) return false;
bool skip = false;
if (*qp_state) {
@@ -5504,7 +5503,7 @@
std::unique_lock<std::mutex> lock(global_lock);
// Track objects tied to memory
uint64_t buffer_handle = reinterpret_cast<uint64_t &>(buffer);
- skip = ValidateSetMemBinding(dev_data, mem, buffer_handle, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "vkBindBufferMemory()");
+ skip = ValidateSetMemBinding(dev_data, mem, buffer_handle, kVulkanObjectTypeBuffer, "vkBindBufferMemory()");
if (!buffer_state->memory_requirements_checked) {
// There's not an explicit requirement in the spec to call vkGetBufferMemoryRequirements() prior to calling
// BindBufferMemory, but it's implied in that memory being bound must conform with VkMemoryRequirements from
@@ -5601,7 +5600,7 @@
// Track objects tied to memory
uint64_t buffer_handle = reinterpret_cast<uint64_t &>(buffer);
- SetMemBinding(dev_data, mem, buffer_handle, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "vkBindBufferMemory()");
+ SetMemBinding(dev_data, mem, buffer_handle, kVulkanObjectTypeBuffer, "vkBindBufferMemory()");
buffer_state->binding.mem = mem;
buffer_state->binding.offset = memoryOffset;
@@ -5675,7 +5674,7 @@
static bool PreCallValidateDestroyPipeline(layer_data *dev_data, VkPipeline pipeline, PIPELINE_STATE **pipeline_state,
VK_OBJECT *obj_struct) {
*pipeline_state = getPipelineState(dev_data, pipeline);
- *obj_struct = {reinterpret_cast<uint64_t &>(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(pipeline), kVulkanObjectTypePipeline};
if (dev_data->instance_data->disabled.destroy_pipeline) return false;
bool skip = false;
if (*pipeline_state) {
@@ -5720,7 +5719,7 @@
static bool PreCallValidateDestroySampler(layer_data *dev_data, VkSampler sampler, SAMPLER_STATE **sampler_state,
VK_OBJECT *obj_struct) {
*sampler_state = GetSamplerState(dev_data, sampler);
- *obj_struct = {reinterpret_cast<uint64_t &>(sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(sampler), kVulkanObjectTypeSampler};
if (dev_data->instance_data->disabled.destroy_sampler) return false;
bool skip = false;
if (*sampler_state) {
@@ -5767,7 +5766,7 @@
static bool PreCallValidateDestroyDescriptorPool(layer_data *dev_data, VkDescriptorPool pool,
DESCRIPTOR_POOL_STATE **desc_pool_state, VK_OBJECT *obj_struct) {
*desc_pool_state = GetDescriptorPoolState(dev_data, pool);
- *obj_struct = {reinterpret_cast<uint64_t &>(pool), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(pool), kVulkanObjectTypeDescriptorPool};
if (dev_data->instance_data->disabled.destroy_descriptor_pool) return false;
bool skip = false;
if (*desc_pool_state) {
@@ -6040,7 +6039,7 @@
static bool PreCallValidateDestroyFramebuffer(layer_data *dev_data, VkFramebuffer framebuffer,
FRAMEBUFFER_STATE **framebuffer_state, VK_OBJECT *obj_struct) {
*framebuffer_state = GetFramebufferState(dev_data, framebuffer);
- *obj_struct = {reinterpret_cast<uint64_t &>(framebuffer), VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(framebuffer), kVulkanObjectTypeFramebuffer};
if (dev_data->instance_data->disabled.destroy_framebuffer) return false;
bool skip = false;
if (*framebuffer_state) {
@@ -6074,7 +6073,7 @@
static bool PreCallValidateDestroyRenderPass(layer_data *dev_data, VkRenderPass render_pass, RENDER_PASS_STATE **rp_state,
VK_OBJECT *obj_struct) {
*rp_state = GetRenderPassState(dev_data, render_pass);
- *obj_struct = {reinterpret_cast<uint64_t &>(render_pass), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT};
+ *obj_struct = {reinterpret_cast<uint64_t &>(render_pass), kVulkanObjectTypeRenderPass};
if (dev_data->instance_data->disabled.destroy_renderpass) return false;
bool skip = false;
if (*rp_state) {
@@ -6854,7 +6853,7 @@
// Add bindings between the given cmd buffer & framebuffer and the framebuffer's children
static void AddFramebufferBinding(layer_data *dev_data, GLOBAL_CB_NODE *cb_state, FRAMEBUFFER_STATE *fb_state) {
addCommandBufferBinding(&fb_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(fb_state->framebuffer), VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT},
+ {reinterpret_cast<uint64_t &>(fb_state->framebuffer), kVulkanObjectTypeFramebuffer},
cb_state);
for (auto attachment : fb_state->attachments) {
auto view_state = attachment.view_state;
@@ -6865,7 +6864,7 @@
if (rp_state) {
addCommandBufferBinding(
&rp_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(rp_state->renderPass), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT}, cb_state);
+ {reinterpret_cast<uint64_t &>(rp_state->renderPass), kVulkanObjectTypeRenderPass}, cb_state);
}
}
}
@@ -7096,14 +7095,14 @@
validation_error_map[VALIDATION_ERROR_00600]);
}
addCommandBufferBinding(&pipe_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}, cb_state);
+ {reinterpret_cast<uint64_t &>(pipeline), kVulkanObjectTypePipeline}, cb_state);
if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) {
// Add binding for child renderpass
auto rp_state = GetRenderPassState(dev_data, pipe_state->graphicsPipelineCI.renderPass);
if (rp_state) {
addCommandBufferBinding(
&rp_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(rp_state->renderPass), VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT}, cb_state);
+ {reinterpret_cast<uint64_t &>(rp_state->renderPass), kVulkanObjectTypeRenderPass}, cb_state);
}
}
}
@@ -8052,7 +8051,7 @@
auto event_state = GetEventNode(dev_data, event);
if (event_state) {
addCommandBufferBinding(&event_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT}, pCB);
+ {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent}, pCB);
event_state->cb_bindings.insert(pCB);
}
pCB->events.push_back(event);
@@ -8083,7 +8082,7 @@
auto event_state = GetEventNode(dev_data, event);
if (event_state) {
addCommandBufferBinding(&event_state->cb_bindings,
- {reinterpret_cast<uint64_t &>(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT}, pCB);
+ {reinterpret_cast<uint64_t &>(event), kVulkanObjectTypeEvent}, pCB);
event_state->cb_bindings.insert(pCB);
}
pCB->events.push_back(event);
@@ -8416,7 +8415,7 @@
auto event_state = GetEventNode(dev_data, pEvents[i]);
if (event_state) {
addCommandBufferBinding(&event_state->cb_bindings,
- {reinterpret_cast<const uint64_t &>(pEvents[i]), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT},
+ {reinterpret_cast<const uint64_t &>(pEvents[i]), kVulkanObjectTypeEvent},
cb_state);
event_state->cb_bindings.insert(cb_state);
}
@@ -8530,7 +8529,7 @@
skip_call |= ValidateCmd(dev_data, pCB, CMD_BEGINQUERY, "vkCmdBeginQuery()");
UpdateCmdBufferLastCmd(pCB, CMD_BEGINQUERY);
addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings,
- {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, pCB);
+ {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, pCB);
}
lock.unlock();
if (!skip_call) dev_data->dispatch_table.CmdBeginQuery(commandBuffer, queryPool, slot, flags);
@@ -8558,7 +8557,7 @@
skip |= ValidateCmd(dev_data, cb_state, CMD_ENDQUERY, "VkCmdEndQuery()");
UpdateCmdBufferLastCmd(cb_state, CMD_ENDQUERY);
addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings,
- {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, cb_state);
+ {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_state);
}
lock.unlock();
if (!skip) dev_data->dispatch_table.CmdEndQuery(commandBuffer, queryPool, slot);
@@ -8584,7 +8583,7 @@
UpdateCmdBufferLastCmd(cb_state, CMD_RESETQUERYPOOL);
skip |= insideRenderPass(dev_data, cb_state, "vkCmdResetQueryPool()", VALIDATION_ERROR_01025);
addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings,
- {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, cb_state);
+ {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_state);
}
lock.unlock();
if (!skip) dev_data->dispatch_table.CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount);
@@ -8654,7 +8653,7 @@
UpdateCmdBufferLastCmd(cb_node, CMD_COPYQUERYPOOLRESULTS);
skip |= insideRenderPass(dev_data, cb_node, "vkCmdCopyQueryPoolResults()", VALIDATION_ERROR_01074);
addCommandBufferBinding(&GetQueryPoolNode(dev_data, queryPool)->cb_bindings,
- {reinterpret_cast<uint64_t &>(queryPool), VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT}, cb_node);
+ {reinterpret_cast<uint64_t &>(queryPool), kVulkanObjectTypeQueryPool}, cb_node);
} else {
assert(0);
}
@@ -10199,7 +10198,7 @@
std::unique_lock<std::mutex> lock(global_lock);
// Track objects tied to memory
uint64_t image_handle = reinterpret_cast<uint64_t &>(image);
- skip = ValidateSetMemBinding(dev_data, mem, image_handle, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "vkBindImageMemory()");
+ skip = ValidateSetMemBinding(dev_data, mem, image_handle, kVulkanObjectTypeImage, "vkBindImageMemory()");
if (!image_state->memory_requirements_checked) {
// There's not an explicit requirement in the spec to call vkGetImageMemoryRequirements() prior to calling
// BindImageMemory but it's implied in that memory being bound must conform with VkMemoryRequirements from
@@ -10263,7 +10262,7 @@
// Track objects tied to memory
uint64_t image_handle = reinterpret_cast<uint64_t &>(image);
- SetMemBinding(dev_data, mem, image_handle, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "vkBindImageMemory()");
+ SetMemBinding(dev_data, mem, image_handle, kVulkanObjectTypeImage, "vkBindImageMemory()");
image_state->binding.mem = mem;
image_state->binding.offset = memoryOffset;
@@ -10338,8 +10337,7 @@
for (uint32_t k = 0; k < bindInfo.pBufferBinds[j].bindCount; k++) {
auto sparse_binding = bindInfo.pBufferBinds[j].pBinds[k];
if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, sparse_binding.size},
- (uint64_t)bindInfo.pBufferBinds[j].buffer, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
- "vkQueueBindSparse"))
+ (uint64_t)bindInfo.pBufferBinds[j].buffer, kVulkanObjectTypeBuffer, "vkQueueBindSparse"))
skip_call = true;
}
}
@@ -10347,8 +10345,7 @@
for (uint32_t k = 0; k < bindInfo.pImageOpaqueBinds[j].bindCount; k++) {
auto sparse_binding = bindInfo.pImageOpaqueBinds[j].pBinds[k];
if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, sparse_binding.size},
- (uint64_t)bindInfo.pImageOpaqueBinds[j].image, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
- "vkQueueBindSparse"))
+ (uint64_t)bindInfo.pImageOpaqueBinds[j].image, kVulkanObjectTypeImage, "vkQueueBindSparse"))
skip_call = true;
}
}
@@ -10358,8 +10355,7 @@
// TODO: This size is broken for non-opaque bindings, need to update to comprehend full sparse binding data
VkDeviceSize size = sparse_binding.extent.depth * sparse_binding.extent.height * sparse_binding.extent.width * 4;
if (SetSparseMemBinding(dev_data, {sparse_binding.memory, sparse_binding.memoryOffset, size},
- (uint64_t)bindInfo.pImageBinds[j].image, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
- "vkQueueBindSparse"))
+ (uint64_t)bindInfo.pImageBinds[j].image, kVulkanObjectTypeImage, "vkQueueBindSparse"))
skip_call = true;
}
}
@@ -10724,7 +10720,7 @@
dev_data->imageSubresourceMap.erase(image_sub);
}
skip_call =
- ClearMemoryObjectBindings(dev_data, (uint64_t)swapchain_image, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT);
+ ClearMemoryObjectBindings(dev_data, (uint64_t)swapchain_image, kVulkanObjectTypeSwapchainKHR);
dev_data->imageMap.erase(swapchain_image);
}
}
diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h
index a6a6fec..ee070fe 100644
--- a/layers/core_validation_types.h
+++ b/layers/core_validation_types.h
@@ -50,6 +50,7 @@
#include "vulkan/vulkan.h"
#include "vk_validation_error_messages.h"
#include "vk_layer_logging.h"
+#include "vk_object_types.h"
#include <atomic>
#include <functional>
#include <map>
@@ -92,7 +93,7 @@
// Generic wrapper for vulkan objects
struct VK_OBJECT {
uint64_t handle;
- VkDebugReportObjectTypeEXT type;
+ VulkanObjectType type;
};
inline bool operator==(VK_OBJECT a, VK_OBJECT b) NOEXCEPT { return a.handle == b.handle && a.type == b.type; }
@@ -813,7 +814,7 @@
void invalidateCommandBuffers(const layer_data *dev_data, std::unordered_set<GLOBAL_CB_NODE *> const &cb_nodes, VK_OBJECT obj);
void RemoveImageMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info);
void RemoveBufferMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info);
-bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type);
+bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VulkanObjectType type);
bool ValidateCmdQueueFlags(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, const char *caller_name, VkQueueFlags flags,
UNIQUE_VALIDATION_ERROR_CODE error_code);
bool ValidateCmd(layer_data *my_data, GLOBAL_CB_NODE *pCB, const CMD_TYPE cmd, const char *caller_name);
diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp
index de34945..7e1108a 100644
--- a/layers/descriptor_sets.cpp
+++ b/layers/descriptor_sets.cpp
@@ -594,7 +594,7 @@
// Set is being deleted or updates so invalidate all bound cmd buffers
void cvdescriptorset::DescriptorSet::InvalidateBoundCmdBuffers() {
core_validation::invalidateCommandBuffers(device_data_, cb_bindings,
- {reinterpret_cast<uint64_t &>(set_), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT});
+ {reinterpret_cast<uint64_t &>(set_), kVulkanObjectTypeDescriptorSet });
}
// Perform write update in given update struct
void cvdescriptorset::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorSet *update) {
@@ -730,10 +730,10 @@
// bind cb to this descriptor set
cb_bindings.insert(cb_node);
// Add bindings for descriptor set, the set's pool, and individual objects in the set
- cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(set_), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT});
+ cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(set_), kVulkanObjectTypeDescriptorSet });
pool_state_->cb_bindings.insert(cb_node);
cb_node->object_bindings.insert(
- {reinterpret_cast<uint64_t &>(pool_state_->pool), VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT});
+ {reinterpret_cast<uint64_t &>(pool_state_->pool), kVulkanObjectTypeDescriptorPool });
// For the active slots, use set# to look up descriptorSet from boundDescriptorSets, and bind all of that descriptor set's
// resources
for (auto binding_req_pair : binding_req_map) {
diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h
index 0e8cdb5..de47dc9 100644
--- a/layers/descriptor_sets.h
+++ b/layers/descriptor_sets.h
@@ -50,6 +50,7 @@
#include "vk_layer_utils.h"
#include "vk_safe_struct.h"
#include "vulkan/vk_layer.h"
+#include "vk_object_types.h"
#include <map>
#include <memory>
#include <unordered_map>