124 lines
3.4 KiB
C++
124 lines
3.4 KiB
C++
|
|
#pragma once
|
||
|
|
#include "char_types.hpp"
|
||
|
|
#include <string>
|
||
|
|
#include <cinttypes>
|
||
|
|
|
||
|
|
namespace Basalt::Shared::Kernel {
|
||
|
|
|
||
|
|
#pragma region Guid & Predefined Guid
|
||
|
|
|
||
|
|
struct Guid {
|
||
|
|
std::uint32_t d1, d2;
|
||
|
|
|
||
|
|
constexpr Guid(std::uint32_t gd1 = 0, std::uint32_t gd2 = 0) : d1(gd1), d2(gd2) {}
|
||
|
|
Guid(const Guid& rhs) : d1(rhs.d1), d2(rhs.d2) {}
|
||
|
|
Guid(Guid&& rhs) noexcept : d1(rhs.d1), d2(rhs.d2) {}
|
||
|
|
Guid& operator=(const Guid& rhs) {
|
||
|
|
this->d1 = rhs.d1;
|
||
|
|
this->d2 = rhs.d2;
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
Guid& operator=(Guid&& rhs) noexcept {
|
||
|
|
this->d1 = rhs.d1;
|
||
|
|
this->d2 = rhs.d2;
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
auto operator<=>(const Guid& rhs) const {
|
||
|
|
if (auto cmp = this->d1 <=> rhs.d1; cmp != 0) return cmp;
|
||
|
|
return this->d2 <=> rhs.d2;
|
||
|
|
}
|
||
|
|
bool operator==(const Guid& rhs) const { return ((this->d1 == rhs.d1) && (this->d2 == rhs.d2)); }
|
||
|
|
};
|
||
|
|
|
||
|
|
constexpr Guid DIRECTX8_ENGINE{0x0, 0x1};
|
||
|
|
constexpr Guid DIRECTX9_ENGINE{0x0, 0x2};
|
||
|
|
constexpr Guid DIRECTX11_ENGINE{0x0, 0x3};
|
||
|
|
constexpr Guid DIRECTX12_ENGINE{0x0, 0x4};
|
||
|
|
constexpr Guid OPENGL_ENGINE{0x0, 0x5};
|
||
|
|
constexpr Guid VULKAN_ENGINE{0x0, 0x6};
|
||
|
|
|
||
|
|
constexpr Guid CUDA_DELIVER{0x1, 0x1};
|
||
|
|
constexpr Guid ROCM_DELIVER{0x1, 0x2};
|
||
|
|
constexpr Guid PIPE_DELIVER{0x1, 0x3};
|
||
|
|
constexpr Guid TCP_DELIVER{0x1, 0x4};
|
||
|
|
constexpr Guid MMAP_DELIVER{0x1, 0x5};
|
||
|
|
|
||
|
|
constexpr Guid TINYOBJLOADER_OBJECT_LOADER{0x2, 0x1};
|
||
|
|
constexpr Guid CGLTF_OBJECT_LOADER{0x2, 0x2};
|
||
|
|
constexpr Guid ASSIMP_OBJECT_LOADER{0x2, 0x3};
|
||
|
|
|
||
|
|
constexpr Guid HOMEBREW_ANIME_LOADER{0x3, 0x1};
|
||
|
|
|
||
|
|
#pragma endregion
|
||
|
|
|
||
|
|
#pragma region Engine
|
||
|
|
|
||
|
|
struct EngineConfig {
|
||
|
|
bool headless; ///< Whether enable headless mode (No Window created).
|
||
|
|
std::basic_string<BSCHAR> title; ///< Window title.
|
||
|
|
std::uint32_t width; ///< Window width.
|
||
|
|
std::uint32_t height; ///< Window height.
|
||
|
|
Guid deliver; ///< The GUID of deliver.
|
||
|
|
};
|
||
|
|
|
||
|
|
enum class EngineStatus {
|
||
|
|
Ready, ///< Engine was allocated but not initialized.
|
||
|
|
Running, ///< Engine has been initialized and running.
|
||
|
|
Stop, ///< Engine is shutdown.
|
||
|
|
};
|
||
|
|
|
||
|
|
class IEngine {
|
||
|
|
public:
|
||
|
|
IEngine();
|
||
|
|
virtual ~IEngine();
|
||
|
|
|
||
|
|
public:
|
||
|
|
virtual Guid GetGuid() const;
|
||
|
|
virtual void Startup(EngineConfig&& config);
|
||
|
|
/**
|
||
|
|
* @brief
|
||
|
|
* @return True for active exit.
|
||
|
|
*/
|
||
|
|
virtual bool Tick();
|
||
|
|
virtual void Shutdown();
|
||
|
|
|
||
|
|
protected:
|
||
|
|
EngineConfig config;
|
||
|
|
EngineStatus status;
|
||
|
|
};
|
||
|
|
|
||
|
|
#pragma endregion
|
||
|
|
|
||
|
|
#pragma region Deliver
|
||
|
|
|
||
|
|
struct DeliverConfig {
|
||
|
|
Guid engine; ///< The GUID of render engine.
|
||
|
|
};
|
||
|
|
|
||
|
|
enum class DeliverStatus {
|
||
|
|
Ready, ///< Engine was allocated but not initialized.
|
||
|
|
Running, ///< Engine has been initialized and running.
|
||
|
|
Stop, ///< Engine is shutdown.
|
||
|
|
};
|
||
|
|
|
||
|
|
class IDeliver {
|
||
|
|
public:
|
||
|
|
IDeliver();
|
||
|
|
virtual ~IDeliver();
|
||
|
|
|
||
|
|
public:
|
||
|
|
virtual Guid GetGuid() const;
|
||
|
|
virtual void Startup(DeliverConfig&& config);
|
||
|
|
virtual void Transmit();
|
||
|
|
virtual void Shutdown();
|
||
|
|
|
||
|
|
protected:
|
||
|
|
DeliverConfig config;
|
||
|
|
DeliverStatus status;
|
||
|
|
};
|
||
|
|
|
||
|
|
#pragma endregion
|
||
|
|
|
||
|
|
} // namespace Basalt::Shared::Kernel
|