aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-10-20 06:35:39 -0600
committerTobin Ehlis <tobine@google.com>2016-10-25 21:15:48 -0600
commit806095ea973371ad4c82bd0c2c58d53cc5557f0b (patch)
treee39adeba94b79498bb2f19f2490ad81bae18e1d0
parent3f1d2ba6852cf6b1bb4e1f06d690293565108e2c (diff)
downloadvulkan-validation-layers-806095ea973371ad4c82bd0c2c58d53cc5557f0b.tar.gz
layers:Refactor DestroySampler
Update DestroySampler to use the Pre/Post pattern and add a validation flag for these checks.
-rw-r--r--layers/core_validation.cpp34
-rw-r--r--layers/core_validation.h1
2 files changed, 26 insertions, 9 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 4e3c5f31f..eb95719b9 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -6061,22 +6061,38 @@ DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const Vk
dev_data->dispatch_table.DestroyPipelineLayout(device, pipelineLayout, pAllocator);
}
+static bool PreCallValidateDestroySampler(layer_data *dev_data, VkSampler sampler, SAMPLER_NODE **sampler_state,
+ VK_OBJECT *obj_struct) {
+ if (dev_data->instance_data->disabled.destroy_sampler)
+ return false;
+ bool skip = false;
+ *sampler_state = getSamplerNode(dev_data, sampler);
+ if (*sampler_state) {
+ *obj_struct = {reinterpret_cast<uint64_t &>(sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT};
+ skip |= ValidateObjectNotInUse(dev_data, *sampler_state, *obj_struct, VALIDATION_ERROR_00837);
+ }
+ return skip;
+}
+
+static void PostCallRecordDestroySampler(layer_data *dev_data, VkSampler sampler, SAMPLER_NODE *sampler_state,
+ VK_OBJECT obj_struct) {
+ // Any bound cmd buffers are now invalid
+ invalidateCommandBuffers(sampler_state->cb_bindings, obj_struct);
+ dev_data->samplerMap.erase(sampler);
+}
+
VKAPI_ATTR void VKAPI_CALL
DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
- bool skip = false;
+ SAMPLER_NODE *sampler_state = nullptr;
+ VK_OBJECT obj_struct;
std::unique_lock<std::mutex> lock(global_lock);
- auto sampler_node = getSamplerNode(dev_data, sampler);
- if (sampler_node) {
- VK_OBJECT obj_struct = {reinterpret_cast<uint64_t &>(sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT};
- skip |= ValidateObjectNotInUse(dev_data, sampler_node, obj_struct, VALIDATION_ERROR_00837);
- // Any bound cmd buffers are now invalid
- invalidateCommandBuffers(sampler_node->cb_bindings, obj_struct);
- }
+ bool skip = PreCallValidateDestroySampler(dev_data, sampler, &sampler_state, &obj_struct);
if (!skip) {
- dev_data->samplerMap.erase(sampler);
lock.unlock();
dev_data->dispatch_table.DestroySampler(device, sampler, pAllocator);
+ lock.lock();
+ PostCallRecordDestroySampler(dev_data, sampler, sampler_state, obj_struct);
}
}
diff --git a/layers/core_validation.h b/layers/core_validation.h
index 44121ec75..993b5ed7f 100644
--- a/layers/core_validation.h
+++ b/layers/core_validation.h
@@ -76,6 +76,7 @@ struct CHECK_DISABLED {
bool destroy_framebuffer; // Skip validation at DestroyFramebuffer time
bool destroy_renderpass; // Skip validation at DestroyRenderpass time
bool destroy_image; // Skip validation at DestroyImage time
+ bool destroy_sampler; // Skip validation at DestroySampler 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
bool push_constant_range; // Skip push constant range checks