project-aster/aster_core/device.h

58 lines
1.4 KiB
C++

// =============================================
// 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 <iterator>
#include <set>
#include <span>
#include <string_view>
#include <utility>
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<QueueAllocation> &&_enabled_queues);
~Device();
template <typename T>
requires vk::isVulkanHandleType<T>::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);
};