Bug 13632 Header 84 Add offset and size to VkMapMemory
authorTony Barbour <tony@LunarG.com>
Fri, 17 Apr 2015 01:09:28 +0000 (19:09 -0600)
committerTony Barbour <tony@LunarG.com>
Fri, 17 Apr 2015 01:35:00 +0000 (19:35 -0600)
demos/cube.c
demos/tri.c
icd/nulldrv/nulldrv.c
include/vulkan.h
layers/mem_tracker.cpp
layers/param_checker.cpp
vulkan.py

index 71181e5..8927a0a 100644 (file)
@@ -481,7 +481,7 @@ void demo_update_data_buffer(struct demo *demo)
     mat4x4_mul(MVP, VP, demo->model_matrix);
 
     assert(demo->uniform_data.num_mem == 1);
-    err = vkMapMemory(demo->uniform_data.mem[0], 0, (void **) &pData);
+    err = vkMapMemory(demo->uniform_data.mem[0], 0, 0, 0, (void **) &pData);
     assert(!err);
 
     memcpy(pData, (const void*) &MVP[0][0], matrixSize);
@@ -886,7 +886,7 @@ static void demo_prepare_texture_image(struct demo *demo,
         /* Linear texture must be within a single memory object */
         assert(num_allocations == 1);
 
-        err = vkMapMemory(tex_obj->mem[0], 0, &data);
+        err = vkMapMemory(tex_obj->mem[0], 0, 0, 0, &data);
         assert(!err);
 
         if (!loadTexture(filename, data, &layout, &tex_width, &tex_height)) {
@@ -1087,7 +1087,7 @@ void demo_prepare_cube_data_buffer(struct demo *demo)
         err = vkAllocMemory(demo->device, &alloc_info, &(demo->uniform_data.mem[i]));
         assert(!err);
 
-        err = vkMapMemory(demo->uniform_data.mem[i], 0, (void **) &pData);
+        err = vkMapMemory(demo->uniform_data.mem[i], 0, 0, 0, (void **) &pData);
         assert(!err);
 
         memcpy(pData, &data, (size_t)alloc_info.allocationSize);
index b799468..847e273 100644 (file)
@@ -545,7 +545,7 @@ static void demo_prepare_texture_image(struct demo *demo,
         /* Linear texture must be within a single memory object */
         assert(num_allocations == 1);
 
-        err = vkMapMemory(tex_obj->mem[0], 0, &data);
+        err = vkMapMemory(tex_obj->mem[0], 0, 0, 0, &data);
         assert(!err);
 
         for (y = 0; y < tex_height; y++) {
@@ -739,7 +739,7 @@ static void demo_prepare_vertices(struct demo *demo)
         err = vkAllocMemory(demo->device, &mem_alloc, &demo->vertices.mem[i]);
         assert(!err);
 
-        err = vkMapMemory(demo->vertices.mem[i], 0, &data);
+        err = vkMapMemory(demo->vertices.mem[i], 0, 0, 0, &data);
         assert(!err);
 
         memcpy(data, vb, sizeof(vb));
index 8171604..e704908 100644 (file)
@@ -1477,7 +1477,9 @@ ICD_EXPORT VkResult VKAPI vkSetMemoryPriority(
 
 ICD_EXPORT VkResult VKAPI vkMapMemory(
     VkDeviceMemory                              mem_,
-    VkFlags                                   flags,
+    VkDeviceSize                                offset,
+    VkDeviceSize                                size,
+    VkFlags                                     flags,
     void**                                      ppData)
 {
     NULLDRV_LOG_FUNC;
index d7748ce..ab347c4 100644 (file)
@@ -145,7 +145,7 @@ typedef enum VkImageLayout_
     VK_IMAGE_LAYOUT_CLEAR_OPTIMAL                           = 0x00000006,   // Optimal layout when image is used only for clear operations
     VK_IMAGE_LAYOUT_TRANSFER_SOURCE_OPTIMAL                 = 0x00000007,   // Optimal layout when image is used only as source of transfer operations
     VK_IMAGE_LAYOUT_TRANSFER_DESTINATION_OPTIMAL            = 0x00000008,   // Optimal layout when image is used only as destination of transfer operations
+
     VK_ENUM_RANGE(IMAGE_LAYOUT, UNDEFINED, TRANSFER_DESTINATION_OPTIMAL)
 } VkImageLayout;
 
@@ -595,7 +595,6 @@ typedef enum VkVertexInputStepRate_
     VK_ENUM_RANGE(VERTEX_INPUT_STEP_RATE, VERTEX, DRAW)
 } VkVertexInputStepRate;
 
-// ------------------------------------------------------------------------------------------------
 // Vulkan format definitions
 typedef enum VkFormat_
 {
@@ -1334,7 +1333,7 @@ typedef struct VkMemoryRequirements_
 {
     VkDeviceSize                                size;                       // Specified in bytes
     VkDeviceSize                                alignment;                  // Specified in bytes
-    VkDeviceSize                                granularity;                // Granularity on which vkBindObjectMemoryRange can bind sub-ranges of memory specified in bytes (usually the page size)
+    VkDeviceSize                                granularity;                // Granularity on which vkQueueBindObjectMemoryRange can bind sub-ranges of memory specified in bytes (usually the page size)
     VkMemoryPropertyFlags                       memPropsAllowed;            // Allowed memory property flags
     VkMemoryPropertyFlags                       memPropsRequired;           // Required memory property flags
 } VkMemoryRequirements;
@@ -1700,7 +1699,6 @@ typedef struct VkComputePipelineCreateInfo_
     uint32_t                                    localSizeX;
     uint32_t                                    localSizeY;
     uint32_t                                    localSizeZ;
-
 } VkComputePipelineCreateInfo;
 
 typedef struct VkVertexInputBindingDescription_
@@ -2084,8 +2082,9 @@ typedef VkResult (VKAPI *PFN_vkDeviceWaitIdle)(VkDevice device);
 typedef VkResult (VKAPI *PFN_vkAllocMemory)(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem);
 typedef VkResult (VKAPI *PFN_vkFreeMemory)(VkDeviceMemory mem);
 typedef VkResult (VKAPI *PFN_vkSetMemoryPriority)(VkDeviceMemory mem, VkMemoryPriority priority);
-typedef VkResult (VKAPI *PFN_vkMapMemory)(VkDeviceMemory mem, VkFlags flags, void** ppData);
+typedef VkResult (VKAPI *PFN_vkMapMemory)(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData);
 typedef VkResult (VKAPI *PFN_vkUnmapMemory)(VkDeviceMemory mem);
+typedef VkResult (VKAPI *PFN_vkFlushMappedMemory)(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size);
 typedef VkResult (VKAPI *PFN_vkPinSystemMemory)(VkDevice device, const void* pSysMem, size_t memSize, VkDeviceMemory* pMem);
 typedef VkResult (VKAPI *PFN_vkGetMultiDeviceCompatibility)(VkPhysicalDevice physicalDevice0, VkPhysicalDevice physicalDevice1, VkPhysicalDeviceCompatibilityInfo* pInfo);
 typedef VkResult (VKAPI *PFN_vkOpenSharedMemory)(VkDevice device, const VkMemoryOpenInfo* pOpenInfo, VkDeviceMemory* pMem);
@@ -2095,7 +2094,7 @@ typedef VkResult (VKAPI *PFN_vkOpenPeerImage)(VkDevice device, const VkPeerImage
 typedef VkResult (VKAPI *PFN_vkDestroyObject)(VkObject object);
 typedef VkResult (VKAPI *PFN_vkGetObjectInfo)(VkBaseObject object, VkObjectInfoType infoType, size_t* pDataSize, void* pData);
 typedef VkResult (VKAPI *PFN_vkQueueBindObjectMemory)(VkQueue queue, VkObject object, uint32_t allocationIdx, VkDeviceMemory mem, VkDeviceSize offset);
-typedef VkResult (VKAPI *PFN_vkQueueBindObjectMemoryRange)(VkQueue queue, VkObject object, uint32_t allocationIdx, VkDeviceSize rangeOffset,VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset);
+typedef VkResult (VKAPI *PFN_vkQueueBindObjectMemoryRange)(VkQueue queue, VkObject object, uint32_t allocationIdx, VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceMemory mem, VkDeviceSize memOffset);
 typedef VkResult (VKAPI *PFN_vkQueueBindImageMemoryRange)(VkQueue queue, VkImage image, uint32_t allocationIdx, const VkImageMemoryBindInfo* pBindInfo, VkDeviceMemory mem, VkDeviceSize memOffset);
 typedef VkResult (VKAPI *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence);
 typedef VkResult (VKAPI *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, VkFence* pFences);
@@ -2173,7 +2172,7 @@ typedef void     (VKAPI *PFN_vkCmdBeginQuery)(VkCmdBuffer cmdBuffer, VkQueryPool
 typedef void     (VKAPI *PFN_vkCmdEndQuery)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot);
 typedef void     (VKAPI *PFN_vkCmdResetQueryPool)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount);
 typedef void     (VKAPI *PFN_vkCmdWriteTimestamp)(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset);
-typedef void     (VKAPI *PFN_vkCmdCopyQueryPoolResults)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkFlags flags);
+typedef void     (VKAPI *PFN_vkCmdCopyQueryPoolResults)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags);
 typedef void     (VKAPI *PFN_vkCmdInitAtomicCounters)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData);
 typedef void     (VKAPI *PFN_vkCmdLoadAtomicCounters)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkDeviceSize srcOffset);
 typedef void     (VKAPI *PFN_vkCmdSaveAtomicCounters)(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkDeviceSize destOffset);
@@ -2259,12 +2258,12 @@ VkResult VKAPI vkQueueSubmit(
 VkResult VKAPI vkQueueAddMemReferences(
     VkQueue                                     queue,
     uint32_t                                    count,
-    const VkDeviceMemory*                          pMems);
+    const VkDeviceMemory*                       pMems);
 
 VkResult VKAPI vkQueueRemoveMemReferences(
     VkQueue                                     queue,
     uint32_t                                    count,
-    const VkDeviceMemory*                          pMems);
+    const VkDeviceMemory*                       pMems);
 
 VkResult VKAPI vkQueueWaitIdle(
     VkQueue                                     queue);
@@ -2288,6 +2287,8 @@ VkResult VKAPI vkSetMemoryPriority(
 
 VkResult VKAPI vkMapMemory(
     VkDeviceMemory                              mem,
+    VkDeviceSize                                offset,
+    VkDeviceSize                                size,
     VkMemoryMapFlags                            flags,
     void**                                      ppData);
 
@@ -2339,7 +2340,7 @@ VkResult VKAPI vkGetObjectInfo(
     size_t*                                     pDataSize,
     void*                                       pData);
 
-// Memory namagement API functions
+// Memory management API functions
 
 VkResult VKAPI vkQueueBindObjectMemory(
     VkQueue                                     queue,
@@ -2643,7 +2644,7 @@ void VKAPI vkCmdBindDescriptorSets(
     uint32_t                                    layoutChainSlot,
     uint32_t                                    count,
     const VkDescriptorSet*                      pDescriptorSets,
-    const uint32_t    *                         pUserData);
+    const uint32_t*                             pUserData);
 
 void VKAPI vkCmdBindIndexBuffer(
     VkCmdBuffer                                 cmdBuffer,
@@ -2843,7 +2844,7 @@ void VKAPI vkCmdCopyQueryPoolResults(
     VkBuffer                                    destBuffer,
     VkDeviceSize                                destOffset,
     VkDeviceSize                                destStride,
-    VkFlags                                     flags); // VkQueryResultFlags
+    VkQueryResultFlags                          flags);
 
 void VKAPI vkCmdInitAtomicCounters(
     VkCmdBuffer                                 cmdBuffer,
index 5884eda..ddba58c 100644 (file)
@@ -1098,7 +1098,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDeviceMemory mem, VkMemoryP
     return result;
 }
 
-VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDeviceMemory mem, VkFlags flags, void** ppData)
+VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData)
 {
     // TODO : Track when memory is mapped
     loader_platform_thread_lock_mutex(&globalLock);
@@ -1109,7 +1109,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDeviceMemory mem, VkFlags flags, vo
         layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, mem, 0, MEMTRACK_INVALID_STATE, "MEM", str);
     }
     loader_platform_thread_unlock_mutex(&globalLock);
-    VkResult result = nextTable.MapMemory(mem, flags, ppData);
+    VkResult result = nextTable.MapMemory(mem, offset, size, flags, ppData);
     return result;
 }
 
index da93382..cfa0f30 100644 (file)
@@ -390,10 +390,10 @@ VK_LAYER_EXPORT VkResult VKAPI vkSetMemoryPriority(VkDeviceMemory mem, VkMemoryP
     return result;
 }
 
-VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDeviceMemory mem, VkFlags flags, void** ppData)
+VK_LAYER_EXPORT VkResult VKAPI vkMapMemory(VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, void** ppData)
 {
 
-    VkResult result = nextTable.MapMemory(mem, flags, ppData);
+    VkResult result = nextTable.MapMemory(mem, offset, size, flags, ppData);
     return result;
 }
 
index 6f14c28..5112e36 100755 (executable)
--- a/vulkan.py
+++ b/vulkan.py
@@ -311,6 +311,8 @@ core = Extension(
 
         Proto("VkResult", "MapMemory",
             [Param("VkDeviceMemory", "mem"),
+             Param("VkDeviceSize", "offset"),
+             Param("VkDeviceSize", "size"),
              Param("VkFlags", "flags"),
              Param("void**", "ppData")]),