diff options
| author | 2020-03-31 20:29:19 -0300 | |
|---|---|---|
| committer | 2020-03-31 21:32:07 -0300 | |
| commit | 397f53dea1212ac888eeee0a644d036ce1fc3782 (patch) | |
| tree | b910737757ab96d36268b8fd446ee2ff6c48b27e /src | |
| parent | renderer_vulkan/wrapper: Add buffer and image handles (diff) | |
| download | yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.gz yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.tar.xz yuzu-397f53dea1212ac888eeee0a644d036ce1fc3782.zip | |
renderer_vulkan/wrapper: Add pool handles
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/wrapper.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/wrapper.h | 15 |
2 files changed, 47 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 { | |||
| 428 | Check(dld->vkBindImageMemory(owner, handle, memory, offset)); | 428 | Check(dld->vkBindImageMemory(owner, handle, memory, offset)); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | DescriptorSets DescriptorPool::Allocate(const VkDescriptorSetAllocateInfo& ai) const { | ||
| 432 | const std::size_t num = ai.descriptorSetCount; | ||
| 433 | std::unique_ptr sets = std::make_unique<VkDescriptorSet[]>(num); | ||
| 434 | switch (const VkResult result = dld->vkAllocateDescriptorSets(owner, &ai, sets.get())) { | ||
| 435 | case VK_SUCCESS: | ||
| 436 | return DescriptorSets(std::move(sets), num, owner, handle, *dld); | ||
| 437 | case VK_ERROR_OUT_OF_POOL_MEMORY: | ||
| 438 | return {}; | ||
| 439 | default: | ||
| 440 | throw Exception(result); | ||
| 441 | } | ||
| 442 | } | ||
| 443 | |||
| 444 | CommandBuffers CommandPool::Allocate(std::size_t num_buffers, VkCommandBufferLevel level) const { | ||
| 445 | VkCommandBufferAllocateInfo ai; | ||
| 446 | ai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||
| 447 | ai.pNext = nullptr; | ||
| 448 | ai.commandPool = handle; | ||
| 449 | ai.level = level; | ||
| 450 | ai.commandBufferCount = static_cast<u32>(num_buffers); | ||
| 451 | |||
| 452 | std::unique_ptr buffers = std::make_unique<VkCommandBuffer[]>(num_buffers); | ||
| 453 | switch (const VkResult result = dld->vkAllocateCommandBuffers(owner, &ai, buffers.get())) { | ||
| 454 | case VK_SUCCESS: | ||
| 455 | return CommandBuffers(std::move(buffers), num_buffers, owner, handle, *dld); | ||
| 456 | case VK_ERROR_OUT_OF_POOL_MEMORY: | ||
| 457 | return {}; | ||
| 458 | default: | ||
| 459 | throw Exception(result); | ||
| 460 | } | ||
| 461 | } | ||
| 462 | |||
| 431 | } // namespace Vulkan::vk | 463 | } // namespace Vulkan::vk |
diff --git a/src/video_core/renderer_vulkan/wrapper.h b/src/video_core/renderer_vulkan/wrapper.h index c6d7cbb3f..d1a355144 100644 --- a/src/video_core/renderer_vulkan/wrapper.h +++ b/src/video_core/renderer_vulkan/wrapper.h | |||
| @@ -600,4 +600,19 @@ public: | |||
| 600 | void BindMemory(VkDeviceMemory memory, VkDeviceSize offset) const; | 600 | void BindMemory(VkDeviceMemory memory, VkDeviceSize offset) const; |
| 601 | }; | 601 | }; |
| 602 | 602 | ||
| 603 | class DescriptorPool : public Handle<VkDescriptorPool, VkDevice, DeviceDispatch> { | ||
| 604 | using Handle<VkDescriptorPool, VkDevice, DeviceDispatch>::Handle; | ||
| 605 | |||
| 606 | public: | ||
| 607 | DescriptorSets Allocate(const VkDescriptorSetAllocateInfo& ai) const; | ||
| 608 | }; | ||
| 609 | |||
| 610 | class CommandPool : public Handle<VkCommandPool, VkDevice, DeviceDispatch> { | ||
| 611 | using Handle<VkCommandPool, VkDevice, DeviceDispatch>::Handle; | ||
| 612 | |||
| 613 | public: | ||
| 614 | CommandBuffers Allocate(std::size_t num_buffers, | ||
| 615 | VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY) const; | ||
| 616 | }; | ||
| 617 | |||
| 603 | } // namespace Vulkan::vk | 618 | } // namespace Vulkan::vk |