1#ifndef LIBSBX_GRAPHICS_DEVICES_LOGICAL_DEVICE_HPP_
2#define LIBSBX_GRAPHICS_DEVICES_LOGICAL_DEVICE_HPP_
4#include <unordered_map>
8#include <vulkan/vulkan.hpp>
10#include <libsbx/utility/noncopyable.hpp>
11#include <libsbx/utility/enum.hpp>
13#include <libsbx/graphics/devices/instance.hpp>
14#include <libsbx/graphics/devices/physical_device.hpp>
16namespace sbx::graphics {
24 enum class type : std::uint32_t {
35 auto operator=(
queue&& other)
noexcept ->
queue& =
default;
37 auto handle()
const noexcept ->
const VkQueue&;
39 operator const VkQueue&()
const noexcept;
41 auto family()
const noexcept -> std::uint32_t;
43 auto wait_idle()
const -> void;
48 : _handle{VK_NULL_HANDLE},
49 _family{0xFFFFFFFF} { }
51 queue(
const VkQueue& handle, std::uint32_t family)
56 std::uint32_t _family{};
68 auto handle()
const noexcept ->
const VkDevice&;
70 operator const VkDevice&()
const noexcept;
74 template<queue::type Type>
76 return _queues.at(utility::to_underlying(Type));
79 auto wait_idle()
const -> void;
83 struct queue_family_indices {
84 std::optional<std::uint32_t> graphics{};
85 std::optional<std::uint32_t> present{};
86 std::optional<std::uint32_t> compute{};
87 std::optional<std::uint32_t> transfer{};
90 template<queue::type Type>
91 auto _get_queue(
const std::uint32_t queue_family_index, std::uint32_t index = 0u) ->
void {
92 auto handle = VkQueue{};
94 vkGetDeviceQueue(_handle, queue_family_index, index, &handle);
96 _queues.at(utility::to_underlying(Type)) =
graphics::queue{handle, queue_family_index};
108 std::array<graphics::queue, 4u> _queues{};
Definition: logical_device.hpp:60
Definition: physical_device.hpp:16
Definition: logical_device.hpp:18
Definition: physical_device.hpp:20
Definition: noncopyable.hpp:6