Mesa (main): anv: bound checks buffer memory binding in debug builds

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 23 08:41:36 UTC 2021


Module: Mesa
Branch: main
Commit: 9b7cba7724f5cc407a889a1feeccf7c9fb105f50
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b7cba7724f5cc407a889a1feeccf7c9fb105f50

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Tue Jun 22 21:36:41 2021 +0300

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 at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11542>

---

 src/intel/vulkan/anv_device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 8943097c08f..5597b065467 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -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,



More information about the mesa-commit mailing list