Mesa (master): anv/device: Add some asserts to MapMemory

Jason Ekstrand jekstrand at kemper.freedesktop.org
Thu Nov 10 02:18:14 UTC 2016


Module: Mesa
Branch: master
Commit: 73ef9c8f047835d369db3646853cdb25442db8d3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=73ef9c8f047835d369db3646853cdb25442db8d3

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Nov  7 17:23:44 2016 -0800

anv/device: Add some asserts to MapMemory

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>

---

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

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index a9aa646..abc511c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1283,6 +1283,16 @@ VkResult anv_MapMemory(
    if (size == VK_WHOLE_SIZE)
       size = mem->bo.size - offset;
 
+   /* From the Vulkan spec version 1.0.32 docs for MapMemory:
+    *
+    *  * If size is not equal to VK_WHOLE_SIZE, size must be greater than 0
+    *    assert(size != 0);
+    *  * If size is not equal to VK_WHOLE_SIZE, size must be less than or
+    *    equal to the size of the memory minus offset
+    */
+   assert(size > 0);
+   assert(offset + size <= mem->bo.size);
+
    /* FIXME: Is this supposed to be thread safe? Since vkUnmapMemory() only
     * takes a VkDeviceMemory pointer, it seems like only one map of the memory
     * at a time is valid. We could just mmap up front and return an offset




More information about the mesa-commit mailing list