diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-04-01 01:29:19 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-04-01 02:32:07 +0200 |
commit | 397f53dea1212ac888eeee0a644d036ce1fc3782 (patch) | |
tree | b910737757ab96d36268b8fd446ee2ff6c48b27e /src/video_core/renderer_vulkan/wrapper.cpp | |
parent | renderer_vulkan/wrapper: Add buffer and image handles (diff) | |
download | yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.gz yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.bz2 yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.lz yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.xz yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.zst yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan/wrapper.cpp')
-rw-r--r-- | src/video_core/renderer_vulkan/wrapper.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/wrapper.cpp b/src/video_core/renderer_vulkan/wrapper.cpp index 84a4c354f..d6fea3711 100644 --- a/src/video_core/renderer_vulkan/wrapper.cpp +++ b/src/video_core/renderer_vulkan/wrapper.cpp @@ -428,4 +428,36 @@ void Image::BindMemory(VkDeviceMemory memory, VkDeviceSize offset) const { Check(dld->vkBindImageMemory(owner, handle, memory, offset)); } +DescriptorSets DescriptorPool::Allocate(const VkDescriptorSetAllocateInfo& ai) const { + const std::size_t num = ai.descriptorSetCount; + std::unique_ptr sets = std::make_unique<VkDescriptorSet[]>(num); + switch (const VkResult result = dld->vkAllocateDescriptorSets(owner, &ai, sets.get())) { + case VK_SUCCESS: + return DescriptorSets(std::move(sets), num, owner, handle, *dld); + case VK_ERROR_OUT_OF_POOL_MEMORY: + return {}; + default: + throw Exception(result); + } +} + +CommandBuffers CommandPool::Allocate(std::size_t num_buffers, VkCommandBufferLevel level) const { + VkCommandBufferAllocateInfo ai; + ai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; + ai.pNext = nullptr; + ai.commandPool = handle; + ai.level = level; + ai.commandBufferCount = static_cast<u32>(num_buffers); + + std::unique_ptr buffers = std::make_unique<VkCommandBuffer[]>(num_buffers); + switch (const VkResult result = dld->vkAllocateCommandBuffers(owner, &ai, buffers.get())) { + case VK_SUCCESS: + return CommandBuffers(std::move(buffers), num_buffers, owner, handle, *dld); + case VK_ERROR_OUT_OF_POOL_MEMORY: + return {}; + default: + throw Exception(result); + } +} + } // namespace Vulkan::vk |