Small fixes merge from v2.
@@ -288,7 +288,7 @@ static void CreateMesh()
vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
vbInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VmaMemoryRequirements vbMemReq = {};
- vbMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
+ vbMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
VkMappedMemoryRange stagingVertexBufferMem;
VkBuffer stagingVertexBuffer = VK_NULL_HANDLE;
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &vbInfo, &vbMemReq, &stagingVertexBuffer, &stagingVertexBufferMem, nullptr) );
@@ -298,6 +298,8 @@ static void CreateMesh()
memcpy(pVbData, vertices, vertexBufferSize);
vmaUnmapMemory(g_hAllocator, &stagingVertexBufferMem);
+ // No need to flush stagingVertexBuffer memory because CPU_ONLY memory is always HOST_COHERENT.
+
vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
vbMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &vbInfo, &vbMemReq, &g_hVertexBuffer, nullptr, nullptr) );
@@ -309,7 +311,7 @@ static void CreateMesh()
ibInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
ibInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VmaMemoryRequirements ibMemReq = {};
- ibMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
+ ibMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
VkMappedMemoryRange stagingIndexBufferMem;
VkBuffer stagingIndexBuffer = VK_NULL_HANDLE;
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &ibInfo, &ibMemReq, &stagingIndexBuffer, &stagingIndexBufferMem, nullptr) );
@@ -319,6 +321,8 @@ static void CreateMesh()
memcpy(pIbData, indices, indexBufferSize);
vmaUnmapMemory(g_hAllocator, &stagingIndexBufferMem);
+ // No need to flush stagingIndexBuffer memory because CPU_ONLY memory is always HOST_COHERENT.
+
ibInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
ibMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &ibInfo, &ibMemReq, &g_hIndexBuffer, nullptr, nullptr) );
@@ -469,7 +473,7 @@ static void CreateTexture(uint32_t sizeX, uint32_t sizeY)
stagingImageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
stagingImageInfo.flags = 0;
VmaMemoryRequirements stagingImageMemReq = {};
- stagingImageMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
+ stagingImageMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
VkImage stagingImage = VK_NULL_HANDLE;
VkMappedMemoryRange stagingImageMem;
ERR_GUARD_VULKAN( vmaCreateImage(g_hAllocator, &stagingImageInfo, &stagingImageMemReq, &stagingImage, &stagingImageMem, nullptr) );
@@ -504,6 +508,8 @@ static void CreateTexture(uint32_t sizeX, uint32_t sizeY)
vmaUnmapMemory(g_hAllocator, &stagingImageMem);
+ // No need to flush stagingImage memory because CPU_ONLY memory is always HOST_COHERENT.
+
VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
imageInfo.imageType = VK_IMAGE_TYPE_2D;
imageInfo.extent.width = sizeX;
