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));
80 auto wait_idle()
const -> void;
84 struct queue_family_indices {
85 std::optional<std::uint32_t> graphics{};
86 std::optional<std::uint32_t> present{};
87 std::optional<std::uint32_t> compute{};
88 std::optional<std::uint32_t> transfer{};
91 template<queue::type Type>
92 auto _get_queue(
const std::uint32_t queue_family_index, std::uint32_t index = 0u) ->
void {
93 auto handle = VkQueue{};
95 vkGetDeviceQueue(_handle, queue_family_index, index, &handle);
97 _queues.at(utility::to_underlying(Type)) =
graphics::queue{handle, queue_family_index};
109 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