layers: Distinguish never-bound from un-bound memory cases
Fixes #964
Added special MEMORY_UNBOUND handle (0xF..FE) that indicates that memory
bound to an object has been freed. When attempting to bind memory or
checking for bound memory, distinguish the never-bound case from the
memory un-bound case.
For sparse binding case allow for memory to be re-bound.
Update tests to account for new error messages.
There's a sliver of exposure here if an actual memory handle is MEMORY_UNBOUND.
We could remove that exposure by never having unique_objects return MEMORY_UNBOUND
as a handle. I believe the exposure is small enough that we don't need to do that,
but am open to other opinions.
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index c972a6a..a54fec7 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -7006,7 +7006,7 @@
// Introduce error, do not call vkBindImageMemory(m_device->device(), image, image_mem, 0);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " used with no memory bound. Memory should be bound by calling vkBindImageMemory().");
m_commandBuffer->BeginCommandBuffer();
VkClearColorValue ccv;
@@ -7065,7 +7065,7 @@
// Introduce failure by not calling vkBindBufferMemory(m_device->device(), buffer, mem, 0);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " used with no memory bound. Memory should be bound by calling vkBindBufferMemory().");
VkBufferImageCopy region = {};
region.bufferRowLength = 128;
region.bufferImageHeight = 128;
@@ -7803,7 +7803,7 @@
// Break memory binding and attempt update
vkFreeMemory(m_device->device(), image_memory, nullptr);
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " previously bound memory was freed. Memory must not be freed prior to this operation.");
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
"vkUpdateDescriptorsSets() failed write update validation for Descriptor Set 0x");
vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL);
@@ -7993,12 +7993,11 @@
}
TEST_F(VkLayerTest, CreateBufferViewNoMemoryBoundToBuffer) {
- TEST_DESCRIPTION("Attempt to create a buffer view with a buffer that has"
- " no memory bound to it.");
+ TEST_DESCRIPTION("Attempt to create a buffer view with a buffer that has no memory bound to it.");
VkResult err;
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " used with no memory bound. Memory should be bound by calling vkBindBufferMemory().");
ASSERT_NO_FATAL_FAILURE(InitState());
@@ -8204,7 +8203,7 @@
"that doesn't have memory bound");
VkResult err;
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " used with no memory bound. Memory should be bound by calling vkBindBufferMemory().");
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
"vkUpdateDescriptorsSets() failed write update validation for Descriptor Set 0x");
@@ -16004,7 +16003,7 @@
TEST_F(VkLayerTest, CreateImageViewNoMemoryBoundToImage) {
VkResult err;
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- " used with no memory bound. Memory should be bound by calling vkBindImageMemory() and ");
+ " used with no memory bound. Memory should be bound by calling vkBindImageMemory().");
ASSERT_NO_FATAL_FAILURE(InitState());