X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;ds=sidebyside;f=src%2Fvulkan%2Fallocator.cc;h=ba1b47be1909122a194565ed497a94a8e395d421;hb=c3d7c1b7f8a7f4bcfc7661b6baf166ce0648083a;hp=714b7cc9ec4fb2ecf29b7c336d9f59cd61441190;hpb=22347bb45e427ea763295d77da0de0d2ef9c2395;p=demo diff --git a/src/vulkan/allocator.cc b/src/vulkan/allocator.cc index 714b7cc..ba1b47b 100644 --- a/src/vulkan/allocator.cc +++ b/src/vulkan/allocator.cc @@ -30,3 +30,18 @@ void vku_free(VkDeviceMemory gpu_memory) { vkFreeMemory(vk_device, gpu_memory, 0); } + +bool vku_write_memory(VkDeviceMemory gpu_mem, int size, void *data) +{ + uint8_t *pdata; + VkResult res = vkMapMemory(vk_device, gpu_mem, 0, size, 0, (void**)&pdata); + if(res != VK_SUCCESS) { + fprintf(stderr, "Failed to map memory to write data.\n"); + return false; + } + + memcpy(pdata, data, size); + vkUnmapMemory(vk_device, gpu_mem); + + return true; +}