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