summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-11-07 17:23:44 -0800
committerJason Ekstrand <[email protected]>2016-11-09 18:17:41 -0800
commit73ef9c8f047835d369db3646853cdb25442db8d3 (patch)
tree444470c09157d60848e2cf7c2e314be52cd6b387 /src/intel
parent843775bab78a6b4d5cb4f02bd95d9d0e95c1c5e3 (diff)
anv/device: Add some asserts to MapMemory
Signed-off-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_device.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index a9aa64656ce..abc511c4d24 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