anv: bound checks buffer memory binding in debug builds

Validation layers should warn you about this
(VUID-VkBindBufferMemoryInfo-size-01037) but this would be useful for
zink debugging.

Requested by Zmike.

v2: Also check memoryOffset (Jason)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11542>
This commit is contained in:
Lionel Landwerlin
2021-06-22 21:36:41 +03:00
committed by Marge Bot
parent 4dc4284342
commit 9b7cba7724
+2
View File
@@ -4333,6 +4333,8 @@ anv_bind_buffer_memory(const VkBindBufferMemoryInfo *pBindInfo)
assert(pBindInfo->sType == VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO);
if (mem) {
assert(pBindInfo->memoryOffset < mem->bo->size);
assert(mem->bo->size - pBindInfo->memoryOffset >= buffer->size);
buffer->address = (struct anv_address) {
.bo = mem->bo,
.offset = pBindInfo->memoryOffset,