Changeset e3bef3a in opengl-game for vulkan-utils.hpp
- Timestamp:
- Nov 12, 2019, 6:55:07 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- cd487fb
- Parents:
- 5a23277
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-utils.hpp
r5a23277 re3bef3a 87 87 uint32_t width, uint32_t height, VkQueue graphicsQueue); 88 88 89 template<class DataType> 90 static void copyDataToBuffer(VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, 91 const vector<DataType>& srcData, VkBuffer dstBuffer, size_t dstVertexOffset, VkQueue graphicsQueue); 92 89 93 static void copyBuffer(VkDevice device, VkCommandPool commandPool, VkBuffer srcBuffer, VkBuffer dstBuffer, 90 94 VkDeviceSize srcOffset, VkDeviceSize dstOffset, VkDeviceSize size, VkQueue graphicsQueue); … … 95 99 }; 96 100 101 template<class DataType> 102 void VulkanUtils::copyDataToBuffer(VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, 103 const vector<DataType>& srcData, VkBuffer dstBuffer, size_t dstVertexOffset, VkQueue graphicsQueue) { 104 VkDeviceSize srcDataSize = srcData.size() * sizeof(DataType); 105 106 VkBuffer stagingBuffer; 107 VkDeviceMemory stagingBufferMemory; 108 createBuffer(device, physicalDevice, srcDataSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, 109 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 110 stagingBuffer, stagingBufferMemory); 111 112 void* data; 113 vkMapMemory(device, stagingBufferMemory, 0, srcDataSize, 0, &data); 114 memcpy(data, srcData.data(), (size_t)srcDataSize); 115 vkUnmapMemory(device, stagingBufferMemory); 116 117 copyBuffer(device, commandPool, stagingBuffer, dstBuffer, 0, dstVertexOffset * sizeof(DataType), srcDataSize, 118 graphicsQueue); 119 120 vkDestroyBuffer(device, stagingBuffer, nullptr); 121 vkFreeMemory(device, stagingBufferMemory, nullptr); 122 } 123 97 124 #endif // _VULKAN_UTILS_H
Note:
See TracChangeset
for help on using the changeset viewer.