aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-10-20 14:42:57 -0600
committerTobin Ehlis <tobine@google.com>2016-10-25 21:20:16 -0600
commit450677bb3c91e3b80b6ac5f953dd965bb9ca4511 (patch)
tree526423e26aca4f1bcda499304d867dd4d6c2ea1a
parentf6b163ba3de27441b74b200a10285385e3f124c4 (diff)
downloadvulkan-validation-layers-450677bb3c91e3b80b6ac5f953dd965bb9ca4511.tar.gz
layers:Early exit in object_tracker FreeMemory
If memory object is invalid, object_tracker should not call down the chain. Also, update validation test to expect that object_tracker will flag the invalid handle instead of core_validation.
-rw-r--r--layers/object_tracker.cpp14
-rw-r--r--tests/layer_validation_tests.cpp3
2 files changed, 9 insertions, 8 deletions
diff --git a/layers/object_tracker.cpp b/layers/object_tracker.cpp
index a7c950931..ec1bcae9b 100644
--- a/layers/object_tracker.cpp
+++ b/layers/object_tracker.cpp
@@ -3282,15 +3282,17 @@ VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyI
}
VKAPI_ATTR void VKAPI_CALL FreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator) {
+ bool skip = false;
std::unique_lock<std::mutex> lock(global_lock);
- ValidateObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false, VALIDATION_ERROR_00621);
- ValidateObject(device, memory, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, true, VALIDATION_ERROR_00622);
+ skip |= ValidateObject(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false, VALIDATION_ERROR_00621);
+ skip |= ValidateObject(device, memory, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, true, VALIDATION_ERROR_00622);
lock.unlock();
+ if (!skip) {
+ get_dispatch_table(ot_device_table_map, device)->FreeMemory(device, memory, pAllocator);
- get_dispatch_table(ot_device_table_map, device)->FreeMemory(device, memory, pAllocator);
-
- lock.lock();
- DestroyObject(device, memory, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, pAllocator);
+ lock.lock();
+ DestroyObject(device, memory, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, pAllocator);
+ }
}
VKAPI_ATTR VkResult VKAPI_CALL MapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size,
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 1ee895730..649b05254 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -9857,8 +9857,7 @@ TEST_F(VkLayerTest, VertexBufferInvalid) {
"is 0x";
const char *bind_null_buffer_message = "In vkBindBufferMemory, attempting"
" to Bind Obj(0x";
- const char *free_invalid_buffer_message = "Request to delete memory "
- "object 0x";
+ const char *free_invalid_buffer_message = "Invalid Device Memory Object 0x";
ASSERT_NO_FATAL_FAILURE(InitState());
ASSERT_NO_FATAL_FAILURE(InitViewport());