2#ifndef LIBSBX_GRAPHICS_DEVICES_LOGICAL_DEVICE_HPP_
3#define LIBSBX_GRAPHICS_DEVICES_LOGICAL_DEVICE_HPP_
5#include <unordered_map>
9#include <vulkan/vulkan.hpp>
11#include <libsbx/utility/noncopyable.hpp>
12#include <libsbx/utility/enum.hpp>
14#include <libsbx/graphics/devices/instance.hpp>
15#include <libsbx/graphics/devices/physical_device.hpp>
17namespace sbx::graphics {
25 enum class type : std::uint32_t {
36 auto operator=(
queue&& other)
noexcept ->
queue& =
default;
38 auto handle()
const noexcept ->
const VkQueue&;
40 operator const VkQueue&()
const noexcept;
42 auto family()
const noexcept -> std::uint32_t;
44 auto wait_idle()
const -> void;
49 : _handle{VK_NULL_HANDLE},
50 _family{0xFFFFFFFF} { }
52 queue(
const VkQueue& handle, std::uint32_t family)
57 std::uint32_t _family{};
69 auto handle()
const noexcept ->
const VkDevice&;
71 operator const VkDevice&()
const noexcept;
75 template<queue::type Type>
77 return _queues.at(utility::to_underlying(Type));
81 return _queues.at(utility::to_underlying(type));
84 auto wait_idle()
const -> void;
88 struct queue_family_indices {
89 std::optional<std::uint32_t> graphics{};
90 std::optional<std::uint32_t> present{};
91 std::optional<std::uint32_t> compute{};
92 std::optional<std::uint32_t> transfer{};
95 template<queue::type Type>
96 auto _get_queue(
const std::uint32_t queue_family_index, std::uint32_t index = 0u) ->
void {
97 auto handle = VkQueue{};
99 vkGetDeviceQueue(_handle, queue_family_index, index, &handle);
101 _queues.at(utility::to_underlying(Type)) =
graphics::queue{handle, queue_family_index};
113 std::array<graphics::queue, 4u> _queues{};
Definition: logical_device.hpp:61
Definition: physical_device.hpp:17
Definition: logical_device.hpp:19
Definition: physical_device.hpp:21
Definition: noncopyable.hpp:7