Refactored Device and Cleaned up includes.
This commit is contained in:
parent
f603bd5752
commit
c16456c610
|
|
@ -31,6 +31,8 @@ set(SOURCE_FILES
|
|||
add_library(aster_core STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
set_property(TARGET aster_core PROPERTY CXX_STANDARD 20)
|
||||
|
||||
target_precompile_headers(aster_core PUBLIC global.h)
|
||||
|
||||
target_include_directories(aster_core PUBLIC ${CMAKE_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(aster_core PUBLIC glm::glm-header-only)
|
||||
|
|
|
|||
|
|
@ -5,14 +5,19 @@
|
|||
|
||||
#include "device.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "physical_device.h"
|
||||
|
||||
#include <EASTL/array.h>
|
||||
#include <EASTL/fixed_vector.h>
|
||||
|
||||
constexpr eastl::array DEVICE_EXTENSIONS = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
|
||||
|
||||
Device::Device(const Context *context, PhysicalDevice *physicalDevice,
|
||||
const vk::PhysicalDeviceFeatures *enabledFeatures,
|
||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString name)
|
||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name)
|
||||
: m_Name(std::move(name))
|
||||
, m_PhysicalDevice(physicalDevice->m_PhysicalDevice)
|
||||
{
|
||||
// Shouldn't have more than 4 deviceQueueFamilies in use anyway. Else we can heap
|
||||
eastl::fixed_vector<vk::DeviceQueueCreateInfo, 4> deviceQueueCreateInfos;
|
||||
|
|
@ -43,7 +48,7 @@ Device::Device(const Context *context, PhysicalDevice *physicalDevice,
|
|||
.pEnabledFeatures = enabledFeatures,
|
||||
};
|
||||
|
||||
vk::Result result = physicalDevice->m_PhysicalDevice.createDevice(&deviceCreateInfo, nullptr, &m_Device);
|
||||
vk::Result result = m_PhysicalDevice.createDevice(&deviceCreateInfo, nullptr, &m_Device);
|
||||
ERROR_IF(failed(result), "Could not initialize Vulkan Device. Cause: {}", result)
|
||||
THEN_ABORT(result)
|
||||
ELSE_DEBUG("{} ({}) Initialized.", m_Name, physicalDevice->m_DeviceProperties.deviceName.data());
|
||||
|
|
@ -54,8 +59,7 @@ Device::Device(const Context *context, PhysicalDevice *physicalDevice,
|
|||
};
|
||||
|
||||
const VmaAllocatorCreateInfo allocatorCreateInfo = {
|
||||
.flags = 0,
|
||||
.physicalDevice = physicalDevice->m_PhysicalDevice,
|
||||
.physicalDevice = m_PhysicalDevice,
|
||||
.device = m_Device,
|
||||
.pVulkanFunctions = &vmaVulkanFunctions,
|
||||
.instance = context->m_Instance,
|
||||
|
|
@ -81,4 +85,5 @@ Device::~Device()
|
|||
}
|
||||
m_Device.destroy(nullptr);
|
||||
DEBUG("Device '{}' Destroyed", m_Name);
|
||||
m_PhysicalDevice = nullptr;
|
||||
}
|
||||
|
|
@ -6,7 +6,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#include "physical_device.h"
|
||||
|
||||
#include <EASTL/vector.h>
|
||||
|
||||
struct Context;
|
||||
struct PhysicalDevice;
|
||||
|
||||
struct QueueAllocation
|
||||
{
|
||||
|
|
@ -16,14 +20,12 @@ struct QueueAllocation
|
|||
|
||||
struct Device final
|
||||
{
|
||||
using NameString = eastl::fixed_string<char, 32, false>;
|
||||
|
||||
NameString m_Name;
|
||||
vk::PhysicalDevice m_PhysicalDevice = nullptr;
|
||||
vk::Device m_Device = nullptr;
|
||||
VmaAllocator m_Allocator = nullptr;
|
||||
|
||||
Device(const Context *context, PhysicalDevice *physicalDevice, const vk::PhysicalDeviceFeatures *enabledFeatures,
|
||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString name);
|
||||
|
||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
||||
~Device();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ toCstr(const T &val)
|
|||
return buffer.c_str();
|
||||
}
|
||||
|
||||
using NameString = eastl::fixed_string<char, 32, false>;
|
||||
|
||||
// TODO: Check why inline namespaces aren't working in MSVC 19.27.29110
|
||||
using namespace std::literals::string_literals;
|
||||
using namespace std::literals::string_view_literals;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
#include "physical_device.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "window.h"
|
||||
|
||||
[[nodiscard]] eastl::vector<vk::SurfaceFormatKHR>
|
||||
getSurfaceFormats(const vk::SurfaceKHR surface, const vk::PhysicalDevice physicalDevice)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#include "window.h"
|
||||
#include <EASTL/fixed_vector.h>
|
||||
|
||||
struct Window;
|
||||
struct Context;
|
||||
|
||||
enum class QueueSupportFlagBits
|
||||
{
|
||||
eGraphics = 0b0001,
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "context.h"
|
||||
#include "global.h"
|
||||
#include <EASTL/fixed_string.h>
|
||||
|
||||
struct Context;
|
||||
|
||||
struct Window final
|
||||
{
|
||||
// fields
|
||||
|
|
|
|||
Loading…
Reference in New Issue