Hello guys,
i dont understand why the vulkan function “VkMapMemory” gives me a pointer to a pointer instead of just the pointer.
Can somebody explain it please?
Thanks
Hello guys,
i dont understand why the vulkan function “VkMapMemory” gives me a pointer to a pointer instead of just the pointer.
Can somebody explain it please?
Thanks
you pass it a pointer to a pointer. Then it can write the location of the mapped memory into the pointer variable:
void* mapped;
vkMapMemory(dev, mem, 0, VK_WHOLE_SIZE, 0, &mapped);
// now mapped is the pointer to the mapped memory
It is C question and little to do with Vulkan.
It does give a pointer (address). Because it is returned through parameter list you have to add another level of abstraction. C copies primitive types. If you gave it just pointer, it would copy and then modify its local copy and you would get nothing (your variable wouldn’t change). So you have to pass the pointer by reference (as pointer to pointer).