Skip to content

Consider using requested persistently mapped memory instead of using vmaMapMemory/vmaUnmapMemory #32

@fbessou

Description

@fbessou

I might be wrong but what I understand from the VMA docs is that the purpose of the VMA_ALLOCATION_CREATE_MAPPED_BIT is to have the memory persistently mapped on the host. From my understanding we could thus get rid of vmaMapMemory/vmaMapMemory and use the pointer to the mapped area stored in the VmaAllocationInfo instead. We could thus replace :

       chk(vmaMapMemory(allocator, vBufferAllocation, &bufferPtr));
       memcpy(bufferPtr, vertices.data(), vBufSize);
       memcpy(((char*)bufferPtr) + vBufSize, indices.data(), iBufSize);
       vmaUnmapMemory(allocator, vBufferAllocation);

by

  VmaAllocationInfo bufferAllocI;
  chk(vmaCreateBuffer(allocator, &bufferCI, &bufferAllocCI, &vBuffer,
                      &vBufferAllocation, &bufferAllocI));
  memcpy(bufferAllocI.pMappedData, vertices.data(), vBufSize);
  memcpy((reinterpret_cast<uint8_t *>(bufferAllocI.pMappedData)) + vBufSize, indices.data(), iBufSize);

This change worked on by build but maybe I am missing something. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions