Rename Context to Instance.
This commit is contained in:
parent
668189acb5
commit
a790c26f1c
|
|
@ -7,7 +7,7 @@ INTERFACE
|
||||||
"global.h"
|
"global.h"
|
||||||
"constants.h"
|
"constants.h"
|
||||||
"config.h"
|
"config.h"
|
||||||
"context.h"
|
"instance.h"
|
||||||
"physical_device.h"
|
"physical_device.h"
|
||||||
"device.h"
|
"device.h"
|
||||||
"swapchain.h"
|
"swapchain.h"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <EASTL/vector.h>
|
#include <EASTL/vector.h>
|
||||||
|
|
||||||
struct QueueAllocation;
|
struct QueueAllocation;
|
||||||
struct Context;
|
struct Instance;
|
||||||
struct PhysicalDevice;
|
struct PhysicalDevice;
|
||||||
|
|
||||||
struct Features
|
struct Features
|
||||||
|
|
@ -40,9 +40,9 @@ struct Device final
|
||||||
void WaitIdle() const;
|
void WaitIdle() const;
|
||||||
|
|
||||||
// Ctor/Dtor
|
// Ctor/Dtor
|
||||||
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
||||||
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
||||||
NameString &&name);
|
NameString &&name);
|
||||||
~Device();
|
~Device();
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,25 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Context
|
* @class Instance
|
||||||
*
|
*
|
||||||
* @brief Vulkan context to handle device initialization logic.
|
* @brief Vulkan context to handle device initialization logic.
|
||||||
*
|
*
|
||||||
* Handles the required hardware interactions.
|
* Handles the required hardware interactions.
|
||||||
*/
|
*/
|
||||||
struct Context final
|
struct Instance final
|
||||||
{
|
{
|
||||||
// Members
|
// Members
|
||||||
vk::Instance m_Instance = nullptr;
|
vk::Instance m_Instance = nullptr;
|
||||||
vk::DebugUtilsMessengerEXT m_DebugMessenger = nullptr;
|
vk::DebugUtilsMessengerEXT m_DebugMessenger = nullptr;
|
||||||
|
|
||||||
// Ctor/Dtor
|
// Ctor/Dtor
|
||||||
Context(cstr appName, Version version, bool enableValidation = ENABLE_LAYER_MESSAGES_DEFAULT_VALUE);
|
Instance(cstr appName, Version version, bool enableValidation = ENABLE_LAYER_MESSAGES_DEFAULT_VALUE);
|
||||||
~Context();
|
~Instance();
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
Context(Context &&other) noexcept;
|
Instance(Instance &&other) noexcept;
|
||||||
Context &operator=(Context &&other) noexcept;
|
Instance &operator=(Instance &&other) noexcept;
|
||||||
|
|
||||||
#if !defined(ASTER_NDEBUG)
|
#if !defined(ASTER_NDEBUG)
|
||||||
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = true;
|
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = true;
|
||||||
|
|
@ -34,5 +34,5 @@ struct Context final
|
||||||
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = false;
|
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Context);
|
DISALLOW_COPY_AND_ASSIGN(Instance);
|
||||||
};
|
};
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
struct Context;
|
struct Instance;
|
||||||
|
|
||||||
enum class QueueSupportFlagBits
|
enum class QueueSupportFlagBits
|
||||||
{
|
{
|
||||||
|
|
@ -54,5 +54,5 @@ struct PhysicalDevice final
|
||||||
class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
|
class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PhysicalDevices(const Surface *surface, const Context *context);
|
PhysicalDevices(const Surface *surface, const Instance *context);
|
||||||
};
|
};
|
||||||
|
|
@ -7,17 +7,17 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
struct Context;
|
struct Instance;
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
||||||
struct Surface
|
struct Surface
|
||||||
{
|
{
|
||||||
Context *m_Context;
|
Instance *m_Context;
|
||||||
vk::SurfaceKHR m_Surface;
|
vk::SurfaceKHR m_Surface;
|
||||||
NameString m_Name;
|
NameString m_Name;
|
||||||
|
|
||||||
// Ctor Dtor
|
// Ctor Dtor
|
||||||
Surface(Context *context, const Window *window, cstr name);
|
Surface(Instance *context, const Window *window, cstr name);
|
||||||
~Surface();
|
~Surface();
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.13)
|
||||||
target_sources(aster_core
|
target_sources(aster_core
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"global.cpp"
|
"global.cpp"
|
||||||
"context.cpp"
|
"instance.cpp"
|
||||||
"physical_device.cpp"
|
"physical_device.cpp"
|
||||||
"device.cpp"
|
"device.cpp"
|
||||||
"swapchain.cpp"
|
"swapchain.cpp"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/instance.h"
|
||||||
#include "core/physical_device.h"
|
#include "core/physical_device.h"
|
||||||
#include "core/queue_allocation.h"
|
#include "core/queue_allocation.h"
|
||||||
|
|
||||||
|
|
@ -17,13 +17,13 @@ constexpr eastl::array DEVICE_EXTENSIONS = {
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
Device::Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device::Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name)
|
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name)
|
||||||
: Device(context, physicalDevice, enabledFeatures, queueAllocations, {}, std::move(name))
|
: Device(context, physicalDevice, enabledFeatures, queueAllocations, {}, std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device::Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
||||||
NameString &&name)
|
NameString &&name)
|
||||||
: m_Name(std::move(name))
|
: m_Name(std::move(name))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Copyright (c) 2020-2025 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/instance.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
@ -35,7 +35,7 @@ DebugCallback(const VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::Context(const cstr appName, const Version version, bool enableValidation)
|
Instance::Instance(const cstr appName, const Version version, bool enableValidation)
|
||||||
{
|
{
|
||||||
INFO_IF(enableValidation, "Validation Layers enabled");
|
INFO_IF(enableValidation, "Validation Layers enabled");
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ Context::Context(const cstr appName, const Version version, bool enableValidatio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context()
|
Instance::~Instance()
|
||||||
{
|
{
|
||||||
if (m_DebugMessenger)
|
if (m_DebugMessenger)
|
||||||
{
|
{
|
||||||
|
|
@ -108,14 +108,14 @@ Context::~Context()
|
||||||
DEBUG("Instance destroyed");
|
DEBUG("Instance destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::Context(Context &&other) noexcept
|
Instance::Instance(Instance &&other) noexcept
|
||||||
: m_Instance(Take(other.m_Instance))
|
: m_Instance(Take(other.m_Instance))
|
||||||
, m_DebugMessenger(Take(other.m_DebugMessenger))
|
, m_DebugMessenger(Take(other.m_DebugMessenger))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Context &
|
Instance &
|
||||||
Context::operator=(Context &&other) noexcept
|
Instance::operator=(Instance &&other) noexcept
|
||||||
{
|
{
|
||||||
if (this == &other)
|
if (this == &other)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/physical_device.h"
|
#include "core/physical_device.h"
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/instance.h"
|
||||||
#include "core/surface.h"
|
#include "core/surface.h"
|
||||||
|
|
||||||
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
||||||
|
|
@ -154,7 +154,7 @@ EnumeratePhysicalDevices(const vk::Instance instance)
|
||||||
return physicalDevices;
|
return physicalDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalDevices::PhysicalDevices(const Surface *surface, const Context *context)
|
PhysicalDevices::PhysicalDevices(const Surface *surface, const Instance *context)
|
||||||
{
|
{
|
||||||
auto physicalDevices = EnumeratePhysicalDevices(context->m_Instance);
|
auto physicalDevices = EnumeratePhysicalDevices(context->m_Instance);
|
||||||
for (auto physicalDevice : physicalDevices)
|
for (auto physicalDevice : physicalDevices)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
#include "core/surface.h"
|
#include "core/surface.h"
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/instance.h"
|
||||||
#include "core/window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
Surface::Surface(Context *context, const Window *window, cstr name)
|
Surface::Surface(Instance *context, const Window *window, cstr name)
|
||||||
: m_Context(context)
|
: m_Context(context)
|
||||||
, m_Name(name)
|
, m_Name(name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/instance.h"
|
||||||
#include "util/logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
std::atomic_uint64_t Window::m_WindowCount = 0;
|
std::atomic_uint64_t Window::m_WindowCount = 0;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
#include "aster/core/context.h"
|
#include "aster/core/instance.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/window.h"
|
#include "aster/core/window.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
@ -26,7 +26,7 @@ VulkanAssert(VkResult result)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init(const Context *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
||||||
const u32 imageCount, const u32 queueFamily, const vk::Queue queue)
|
const u32 imageCount, const u32 queueFamily, const vk::Queue queue)
|
||||||
{
|
{
|
||||||
g_AttachmentFormat = attachmentFormat;
|
g_AttachmentFormat = attachmentFormat;
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
struct Device;
|
struct Device;
|
||||||
struct Context;
|
struct Instance;
|
||||||
struct Window;
|
struct Window;
|
||||||
struct Swapchain;
|
struct Swapchain;
|
||||||
|
|
||||||
// ReSharper disable once CppInconsistentNaming
|
// ReSharper disable once CppInconsistentNaming
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
void Init(const Context *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
void Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
||||||
u32 imageCount, u32 queueFamily, vk::Queue queue);
|
u32 imageCount, u32 queueFamily, vk::Queue queue);
|
||||||
void Destroy(const Device *device);
|
void Destroy(const Device *device);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/context.h"
|
#include "aster/core/instance.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
#include "aster/core/pipeline.h"
|
#include "aster/core/pipeline.h"
|
||||||
|
|
@ -76,7 +76,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"Triangle (Aster)", {640, 480}};
|
Window window = {"Triangle (Aster)", {640, 480}};
|
||||||
Context context = {"Triangle", VERSION};
|
Instance context = {"Triangle", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/context.h"
|
#include "aster/core/instance.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/image.h"
|
#include "aster/core/image.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
|
|
@ -99,7 +99,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"Box (Aster)", {640, 480}};
|
Window window = {"Box (Aster)", {640, 480}};
|
||||||
Context context = {"Box", VERSION};
|
Instance context = {"Box", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/context.h"
|
#include "aster/core/instance.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/image.h"
|
#include "aster/core/image.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
|
|
@ -136,7 +136,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
||||||
Context context = {"ModelRender", VERSION};
|
Instance context = {"ModelRender", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary Surface"};
|
Surface surface = {&context, &window, "Primary Surface"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue