aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-11-17 13:51:54 -0700
committerTobin Ehlis <tobine@google.com>2016-11-17 15:34:38 -0700
commitac339e84be5416fc0211a49d68734389ef41c078 (patch)
treea38abe7502797dcff18ec672a3e2a4dffa2af028 /layers/core_validation.cpp
parent4e96aa8a5cd65bc1c6f29d471f6a1b132cbbed6f (diff)
downloadusermoji-ac339e84be5416fc0211a49d68734389ef41c078.tar.xz
layers:Check reqs before call to BindImageMemory
There's an implicit spec requirement that GetImageMemoryRequirements() should be called prior to calling BindImageMemory() b/c various return values from GetImageMemoryRequirements() are expected to be complied with. This change adds a warning if GetImageMemoryRequirements() has not been called prior to BindImageMemory(). In this case it will make the call itself in order to populate internal state tracking.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 9f1028f0..64748fc8 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -11370,17 +11370,27 @@ VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory(VkDevice device, VkImage image, V
// Track objects tied to memory
uint64_t image_handle = reinterpret_cast<uint64_t &>(image);
skip_call = SetMemBinding(dev_data, mem, image_handle, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "vkBindImageMemory");
- VkMemoryRequirements memRequirements;
- lock.unlock();
- dev_data->dispatch_table.GetImageMemoryRequirements(device, image, &memRequirements);
- lock.lock();
+ 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
+ // vkGetImageMemoryRequirements()
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
+ image_handle, __LINE__, DRAWSTATE_INVALID_IMAGE, "DS",
+ "vkBindBufferMemory(): Binding memory to image 0x%" PRIxLEAST64
+ " but vkGetImageMemoryRequirements() has not been called on that image.",
+ image_handle);
+ // Make the call for them so we can verify the state
+ lock.unlock();
+ dev_data->dispatch_table.GetImageMemoryRequirements(device, image, &image_state->requirements);
+ lock.lock();
+ }
// Track and validate bound memory range information
auto mem_info = getMemObjInfo(dev_data, mem);
if (mem_info) {
- skip_call |= InsertImageMemoryRange(dev_data, image, mem_info, memoryOffset, memRequirements,
+ skip_call |= InsertImageMemoryRange(dev_data, image, mem_info, memoryOffset, image_state->requirements,
image_state->createInfo.tiling == VK_IMAGE_TILING_LINEAR);
- skip_call |= ValidateMemoryTypes(dev_data, mem_info, memRequirements.memoryTypeBits, "vkBindImageMemory");
+ skip_call |= ValidateMemoryTypes(dev_data, mem_info, image_state->requirements.memoryTypeBits, "vkBindImageMemory");
}
print_mem_list(dev_data);
@@ -11390,7 +11400,7 @@ VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory(VkDevice device, VkImage image, V
lock.lock();
image_state->binding.mem = mem;
image_state->binding.offset = memoryOffset;
- image_state->binding.size = memRequirements.size;
+ image_state->binding.size = image_state->requirements.size;
lock.unlock();
}
} else {