diff options
| author | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-04-29 17:16:21 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-05-01 17:26:57 -0600 |
| commit | 2bda8330c5bf332db9b0560ea358af6564116de7 (patch) | |
| tree | 20659cd12b05374572131ca42ac90ba93a9eee24 | |
| parent | 605dbeb0730baa0527c0866d425ef96302c7993c (diff) | |
| download | usermoji-2bda8330c5bf332db9b0560ea358af6564116de7.tar.xz | |
bug-13690: Clarification on vkFlushMappedMemory
Bug 13690 - Clarification on the behavior of vkFlushMappedMemory
svn ID: 30914 & 30888
| -rw-r--r-- | demos/cube.c | 2 | ||||
| -rw-r--r-- | demos/tri.c | 2 | ||||
| -rw-r--r-- | icd/nulldrv/nulldrv.c | 16 | ||||
| -rw-r--r-- | include/vkLayer.h | 3 | ||||
| -rw-r--r-- | include/vulkan.h | 37 | ||||
| -rw-r--r-- | layers/param_checker.cpp | 17 | ||||
| -rwxr-xr-x | vk-layer-generate.py | 2 | ||||
| -rwxr-xr-x | vulkan.py | 12 |
8 files changed, 66 insertions, 25 deletions
diff --git a/demos/cube.c b/demos/cube.c index 8dc7ac32..faa9fa17 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -430,7 +430,7 @@ static void demo_set_image_layout( if (new_image_layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) { /* Make sure any Copy or CPU writes to image are flushed */ - image_memory_barrier.outputMask = VK_MEMORY_OUTPUT_CPU_WRITE_BIT | VK_MEMORY_OUTPUT_TRANSFER_BIT; + image_memory_barrier.outputMask = VK_MEMORY_OUTPUT_HOST_WRITE_BIT | VK_MEMORY_OUTPUT_TRANSFER_BIT; } VkImageMemoryBarrier *pmemory_barrier = &image_memory_barrier; diff --git a/demos/tri.c b/demos/tri.c index 0d640620..3990e696 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -247,7 +247,7 @@ static void demo_set_image_layout( if (new_image_layout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) { /* Make sure any Copy or CPU writes to image are flushed */ - image_memory_barrier.outputMask = VK_MEMORY_OUTPUT_TRANSFER_BIT | VK_MEMORY_OUTPUT_CPU_WRITE_BIT; + image_memory_barrier.outputMask = VK_MEMORY_OUTPUT_TRANSFER_BIT | VK_MEMORY_OUTPUT_HOST_WRITE_BIT; } VkImageMemoryBarrier *pmemory_barrier = &image_memory_barrier; diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c index 2788c783..69c26c22 100644 --- a/icd/nulldrv/nulldrv.c +++ b/icd/nulldrv/nulldrv.c @@ -1731,11 +1731,19 @@ ICD_EXPORT VkResult VKAPI vkUnmapMemory( return VK_SUCCESS; } -ICD_EXPORT VkResult VKAPI vkFlushMappedMemory( +ICD_EXPORT VkResult VKAPI vkFlushMappedMemoryRanges( VkDevice device, - VkDeviceMemory mem_, - VkDeviceSize offset, - VkDeviceSize size) + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges) +{ + NULLDRV_LOG_FUNC; + return VK_SUCCESS; +} + +ICD_EXPORT VkResult VKAPI vkInvalidateMappedMemoryRanges( + VkDevice device, + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges) { NULLDRV_LOG_FUNC; return VK_SUCCESS; diff --git a/include/vkLayer.h b/include/vkLayer.h index ec6e8acc..0b629b80 100644 --- a/include/vkLayer.h +++ b/include/vkLayer.h @@ -46,7 +46,8 @@ typedef struct VkLayerDispatchTable_ PFN_vkSetMemoryPriority SetMemoryPriority; PFN_vkMapMemory MapMemory; PFN_vkUnmapMemory UnmapMemory; - PFN_vkFlushMappedMemory FlushMappedMemory; + PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges; + PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges; PFN_vkPinSystemMemory PinSystemMemory; PFN_vkGetMultiDeviceCompatibility GetMultiDeviceCompatibility; PFN_vkOpenSharedMemory OpenSharedMemory; diff --git a/include/vulkan.h b/include/vulkan.h index 650d348b..f4ac9357 100644 --- a/include/vulkan.h +++ b/include/vulkan.h @@ -33,7 +33,7 @@ #include "vk_platform.h" // Vulkan API version supported by this file -#define VK_API_VERSION VK_MAKE_VERSION(0, 91, 0) +#define VK_API_VERSION VK_MAKE_VERSION(0, 92, 0) #ifdef __cplusplus extern "C" @@ -856,8 +856,9 @@ typedef enum VkStructureType_ VK_STRUCTURE_TYPE_UPDATE_AS_COPY = 50, VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 51, VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 52, + VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 53, - VK_ENUM_RANGE(STRUCTURE_TYPE, APPLICATION_INFO, PIPELINE_LAYOUT_CREATE_INFO) + VK_ENUM_RANGE(STRUCTURE_TYPE, APPLICATION_INFO, MAPPED_MEMORY_RANGE) } VkStructureType; // Object type enumerant @@ -980,7 +981,8 @@ typedef enum VkMemoryPropertyFlagBits_ { VK_MEMORY_PROPERTY_DEVICE_ONLY = 0, // If otherwise stated, then allocate memory on device VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = VK_BIT(0), // Memory should be mappable by host - VK_MEMORY_PROPERTY_HOST_DEVICE_COHERENT_BIT = VK_BIT(1), // Memory should be coherent between host and device accesses + VK_MEMORY_PROPERTY_HOST_NON_COHERENT_BIT = VK_BIT(1), // Memory may not have i/o coherency so vkFlushMappedMemoryRanges and + // vkInvalidateMappedMemoryRanges must be used flush/invalidate host cache VK_MEMORY_PROPERTY_HOST_UNCACHED_BIT = VK_BIT(2), // Memory should not be cached by the host VK_MEMORY_PROPERTY_HOST_WRITE_COMBINED_BIT = VK_BIT(3), // Memory should support host write combining VK_MEMORY_PROPERTY_PREFER_HOST_LOCAL = VK_BIT(4), // If set, prefer host access @@ -991,7 +993,7 @@ typedef enum VkMemoryPropertyFlagBits_ typedef VkFlags VkMemoryOutputFlags; typedef enum VkMemoryOutputFlagBits_ { - VK_MEMORY_OUTPUT_CPU_WRITE_BIT = VK_BIT(0), // Controls output coherency of CPU writes + VK_MEMORY_OUTPUT_HOST_WRITE_BIT = VK_BIT(0), // Controls output coherency of host writes VK_MEMORY_OUTPUT_SHADER_WRITE_BIT = VK_BIT(1), // Controls output coherency of generic shader writes VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT = VK_BIT(2), // Controls output coherency of color attachment writes VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT = VK_BIT(3), // Controls output coherency of depth/stencil attachment writes @@ -1002,7 +1004,7 @@ typedef enum VkMemoryOutputFlagBits_ typedef VkFlags VkMemoryInputFlags; typedef enum VkMemoryInputFlagBits_ { - VK_MEMORY_INPUT_CPU_READ_BIT = VK_BIT(0), // Controls input coherency of CPU reads + VK_MEMORY_INPUT_HOST_READ_BIT = VK_BIT(0), // Controls input coherency of host reads VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT = VK_BIT(1), // Controls input coherency of indirect command reads VK_MEMORY_INPUT_INDEX_FETCH_BIT = VK_BIT(2), // Controls input coherency of index fetches VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT = VK_BIT(3), // Controls input coherency of vertex attribute fetches @@ -1405,9 +1407,17 @@ typedef struct VkMemoryRequirements_ 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; +typedef struct VkMappedMemoryRange_ +{ + VkStructureType sType; // Must be VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE + const void* pNext; // Pointer to next structure + VkDeviceMemory mem; // Mapped memory object + VkDeviceSize offset; // Offset within the mapped memory the range starts from + VkDeviceSize size; // Size of the range within the mapped memory +} VkMappedMemoryRange; + typedef struct VkFormatProperties_ { VkFormatFeatureFlags linearTilingFeatures; // Format features in case of linear tiling @@ -2145,7 +2155,8 @@ typedef VkResult (VKAPI *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory mem); typedef VkResult (VKAPI *PFN_vkSetMemoryPriority)(VkDevice device, VkDeviceMemory mem, VkMemoryPriority priority); typedef VkResult (VKAPI *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData); typedef VkResult (VKAPI *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory mem); -typedef VkResult (VKAPI *PFN_vkFlushMappedMemory)(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size); +typedef VkResult (VKAPI *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); +typedef VkResult (VKAPI *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memRangeCount, const VkMappedMemoryRange* pMemRanges); 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); @@ -2360,11 +2371,15 @@ VkResult VKAPI vkUnmapMemory( VkDevice device, VkDeviceMemory mem); -VkResult VKAPI vkFlushMappedMemory( +VkResult VKAPI vkFlushMappedMemoryRanges( VkDevice device, - VkDeviceMemory mem, - VkDeviceSize offset, - VkDeviceSize size); + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges); + +VkResult VKAPI vkInvalidateMappedMemoryRanges( + VkDevice device, + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges); VkResult VKAPI vkPinSystemMemory( VkDevice device, diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp index f7807142..01328bf1 100644 --- a/layers/param_checker.cpp +++ b/layers/param_checker.cpp @@ -413,10 +413,23 @@ VK_LAYER_EXPORT VkResult VKAPI vkUnmapMemory(VkDevice device, VkDeviceMemory mem return result; } -VK_LAYER_EXPORT VkResult VKAPI vkFlushMappedMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size) +VK_LAYER_EXPORT VkResult VKAPI vkFlushMappedMemoryRanges( + VkDevice device, + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges) { - VkResult result = nextTable.FlushMappedMemory(device, mem, offset, size); + VkResult result = nextTable.FlushMappedMemoryRanges(device, memRangeCount, pMemRanges); + return result; +} + +VK_LAYER_EXPORT VkResult VKAPI vkInvalidateMappedMemoryRanges( + VkDevice device, + uint32_t memRangeCount, + const VkMappedMemoryRange* pMemRanges) +{ + + VkResult result = nextTable.InvalidateMappedMemoryRanges(device, memRangeCount, pMemRanges); return result; } diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 680d3c4c..326a47e5 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -1170,7 +1170,7 @@ class ObjectTrackerSubcommand(Subcommand): using_line += ' // validate_memory_mapping_status(pMemRefs, memRefCount);\n' using_line += ' // validate_mem_ref_count(memRefCount);\n' using_line += ' loader_platform_thread_unlock_mutex(&objLock);\n' - elif 'MemoryRange' in proto.name: + elif 'QueueBindObjectMemoryRange' in proto.name or 'QueueBindImageMemoryRange' in proto.name: using_line = ' loader_platform_thread_lock_mutex(&objLock);\n' using_line += ' if (validateQueueFlags(queue) == VK_FALSE) {\n' using_line += ' char str[1024];\n' @@ -321,11 +321,15 @@ core = Extension( [Param("VkDevice", "device"), Param("VkDeviceMemory", "mem")]), - Proto("VkResult", "FlushMappedMemory", + Proto("VkResult", "FlushMappedMemoryRanges", [Param("VkDevice", "device"), - Param("VkDeviceMemory", "mem"), - Param("VkDeviceSize", "offset"), - Param("VkDeviceSize", "size")]), + Param("uint32_t", "memRangeCount"), + Param("const VkMappedMemoryRange*", "pMemRanges")]), + + Proto("VkResult", "InvalidateMappedMemoryRanges", + [Param("VkDevice", "device"), + Param("uint32_t", "memRangeCount"), + Param("const VkMappedMemoryRange*", "pMemRanges")]), Proto("VkResult", "PinSystemMemory", [Param("VkDevice", "device"), |
