buffer)
{
VkBufferCreateInfo bufferInfo{};
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = size;
bufferInfo.usage = usage;
bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VK_CHECK(vkCreateBuffer(_device, &bufferInfo, nullptr, &buffer));
}
void createBuffer__DeviceMemory(VkPhysicalDevice _physicalDevice, VkDevice _device, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, uint32_t size, VkBuffer& buffer, VkDeviceMemory& deviceMemory)
{
createVkBuffer(_device, size, usage, buffer);
VkMemoryRequirements memRequirements;
vkGetBufferMemoryRequirements(_device, buffer, &memRequirements);
createVkDeviceMemory(_physicalDevice, _device, memRequirements, properties, deviceMemory);
vkBindBufferMemory(_device, buffer, deviceMemory, 0);
}
void createBuffer__DeviceMemory__fill(VkPhysicalDevice _physicalDevice, VkDevice _device, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, uint32_t size, void* srcBuffer, VkBuffer& buffer, VkDeviceMemory& deviceMemory)
{
createBuffer__DeviceMemory(_physicalDevice, _device, usage, properties, size, buffer, deviceMemory);
void* data;
vkMapMemory(_device, deviceMemory, 0, size, 0, &data);
memcpy(data, srcBuffer, size);
vkUnmapMemory(_device, deviceMemory);
}
лучше использовать алокатор
Принципиально хочется навелосипедить
Обсуждают сегодня