mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
Small fixes merge from v2.
This commit is contained in:
parent
0a41b12c10
commit
2f16fa52d8
@ -288,7 +288,7 @@ static void CreateMesh()
|
|||||||
vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
vbInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
vbInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
VmaMemoryRequirements vbMemReq = {};
|
VmaMemoryRequirements vbMemReq = {};
|
||||||
vbMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
|
vbMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
|
||||||
VkMappedMemoryRange stagingVertexBufferMem;
|
VkMappedMemoryRange stagingVertexBufferMem;
|
||||||
VkBuffer stagingVertexBuffer = VK_NULL_HANDLE;
|
VkBuffer stagingVertexBuffer = VK_NULL_HANDLE;
|
||||||
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &vbInfo, &vbMemReq, &stagingVertexBuffer, &stagingVertexBufferMem, nullptr) );
|
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &vbInfo, &vbMemReq, &stagingVertexBuffer, &stagingVertexBufferMem, nullptr) );
|
||||||
@ -298,6 +298,8 @@ static void CreateMesh()
|
|||||||
memcpy(pVbData, vertices, vertexBufferSize);
|
memcpy(pVbData, vertices, vertexBufferSize);
|
||||||
vmaUnmapMemory(g_hAllocator, &stagingVertexBufferMem);
|
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;
|
vbInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
||||||
vbMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
vbMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||||
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &vbInfo, &vbMemReq, &g_hVertexBuffer, nullptr, nullptr) );
|
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.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
ibInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
ibInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
VmaMemoryRequirements ibMemReq = {};
|
VmaMemoryRequirements ibMemReq = {};
|
||||||
ibMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
|
ibMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
|
||||||
VkMappedMemoryRange stagingIndexBufferMem;
|
VkMappedMemoryRange stagingIndexBufferMem;
|
||||||
VkBuffer stagingIndexBuffer = VK_NULL_HANDLE;
|
VkBuffer stagingIndexBuffer = VK_NULL_HANDLE;
|
||||||
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &ibInfo, &ibMemReq, &stagingIndexBuffer, &stagingIndexBufferMem, nullptr) );
|
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &ibInfo, &ibMemReq, &stagingIndexBuffer, &stagingIndexBufferMem, nullptr) );
|
||||||
@ -319,6 +321,8 @@ static void CreateMesh()
|
|||||||
memcpy(pIbData, indices, indexBufferSize);
|
memcpy(pIbData, indices, indexBufferSize);
|
||||||
vmaUnmapMemory(g_hAllocator, &stagingIndexBufferMem);
|
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;
|
ibInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
||||||
ibMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
ibMemReq.usage = VMA_MEMORY_USAGE_GPU_ONLY;
|
||||||
ERR_GUARD_VULKAN( vmaCreateBuffer(g_hAllocator, &ibInfo, &ibMemReq, &g_hIndexBuffer, nullptr, nullptr) );
|
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.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
stagingImageInfo.flags = 0;
|
stagingImageInfo.flags = 0;
|
||||||
VmaMemoryRequirements stagingImageMemReq = {};
|
VmaMemoryRequirements stagingImageMemReq = {};
|
||||||
stagingImageMemReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
|
stagingImageMemReq.usage = VMA_MEMORY_USAGE_CPU_ONLY;
|
||||||
VkImage stagingImage = VK_NULL_HANDLE;
|
VkImage stagingImage = VK_NULL_HANDLE;
|
||||||
VkMappedMemoryRange stagingImageMem;
|
VkMappedMemoryRange stagingImageMem;
|
||||||
ERR_GUARD_VULKAN( vmaCreateImage(g_hAllocator, &stagingImageInfo, &stagingImageMemReq, &stagingImage, &stagingImageMem, nullptr) );
|
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);
|
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 };
|
VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
|
||||||
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
||||||
imageInfo.extent.width = sizeX;
|
imageInfo.extent.width = sizeX;
|
||||||
|
Loading…
Reference in New Issue
Block a user