// ============================================= // Aster: device.h // Copyright (c) 2020-2024 Anish Bhobe // ============================================= #pragma once #include "context.h" #include "global.h" #include "physical_device.h" #include "window.h" #include #include #include #include #include struct QueueAllocation { u32 family; u32 count; }; class Device { public: Device(const Device &_other) = delete; Device(Device &&_other) noexcept; Device &operator=(const Device &_other) = delete; Device &operator=(Device &&_other) noexcept; Device(const std::string_view &_name, Context *_context, const PhysicalDevice &_physical_device_info, const vk::PhysicalDeviceFeatures &_enabled_features, std::set &&_enabled_queues); ~Device(); template requires vk::isVulkanHandleType::value void set_object_name(const T &_obj, const std::string_view &_name) const { try { device.setDebugUtilsObjectNameEXT({ .objectType = _obj.objectType, .objectHandle = get_vk_handle(_obj), .pObjectName = _name.data(), }); } catch (const std::exception &err) { WARN("Debug Utils name setting failed with "s + err.what()); } } // fields PhysicalDevice physical_device; vk::raii::Device device{ nullptr }; VmaAllocator allocator; std::string name; private: void set_name(const std::string_view &_name); };