aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-10-20 14:13:24 -0600
committerTobin Ehlis <tobine@google.com>2016-10-25 21:22:30 -0600
commitd379c77e4254a740aa838a82e7af186525524617 (patch)
tree5c5b32e5d189a0177490183bf8a1b60d44d17ab2
parent177063aac84fac6f4e650c2629a08b48be643f96 (diff)
downloadvulkan-validation-layers-d379c77e4254a740aa838a82e7af186525524617.tar.gz
layers:Refactor DestroyEvent
Update DestroyEvent to use the Pre/Post call pattern and add a validation flag.
-rw-r--r--layers/core_validation.cpp31
-rw-r--r--layers/core_validation.h1
2 files changed, 23 insertions, 9 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 5b49592f7..980add512 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -5436,21 +5436,34 @@ DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallb
}
}
+static bool PreCallValidateDestroyEvent(layer_data *dev_data, VkEvent event, EVENT_NODE **event_state, VK_OBJECT *obj_struct) {
+ if (dev_data->instance_data->disabled.destroy_event)
+ return false;
+ bool skip = false;
+ *event_state = getEventNode(dev_data, event);
+ if (*event_state) {
+ *obj_struct = {reinterpret_cast<uint64_t &>(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT};
+ skip |= ValidateObjectNotInUse(dev_data, *event_state, *obj_struct, VALIDATION_ERROR_00213);
+ }
+ return skip;
+}
+
+static void PostCallRecordDestroyEvent(layer_data *dev_data, VkEvent event, EVENT_NODE *event_state, VK_OBJECT obj_struct) {
+ invalidateCommandBuffers(event_state->cb_bindings, obj_struct);
+ dev_data->eventMap.erase(event);
+}
+
VKAPI_ATTR void VKAPI_CALL DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- bool skip = false;
+ EVENT_NODE *event_state = nullptr;
+ VK_OBJECT obj_struct;
std::unique_lock<std::mutex> lock(global_lock);
- auto event_node = getEventNode(dev_data, event);
- if (event_node) {
- VK_OBJECT obj_struct = {reinterpret_cast<uint64_t &>(event), VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT};
- skip |= ValidateObjectNotInUse(dev_data, event_node, obj_struct, VALIDATION_ERROR_00213);
- // Any bound cmd buffers are now invalid
- invalidateCommandBuffers(event_node->cb_bindings, obj_struct);
- }
+ bool skip = PreCallValidateDestroyEvent(dev_data, event, &event_state, &obj_struct);
if (!skip) {
- dev_data->eventMap.erase(event);
lock.unlock();
dev_data->dispatch_table.DestroyEvent(device, event, pAllocator);
+ lock.lock();
+ PostCallRecordDestroyEvent(dev_data, event, event_state, obj_struct);
}
}
diff --git a/layers/core_validation.h b/layers/core_validation.h
index 216be7f58..325ecea11 100644
--- a/layers/core_validation.h
+++ b/layers/core_validation.h
@@ -78,6 +78,7 @@ struct CHECK_DISABLED {
bool destroy_image; // Skip validation at DestroyImage time
bool destroy_sampler; // Skip validation at DestroySampler time
bool destroy_command_pool; // Skip validation at DestroyCommandPool time
+ bool destroy_event; // Skip validation at DestroyEvent time
bool free_memory; // Skip validation at FreeMemory time
bool object_in_use; // Skip all object in_use checking
bool idle_descriptor_set; // Skip check to verify that descriptor set is no in-use