Compare commits
4 Commits
6d91291768
...
feb438a3e6
| Author | SHA1 | Date | |
|---|---|---|---|
|
feb438a3e6
|
|||
|
6699128476
|
|||
|
02251260e0
|
|||
|
466be0017f
|
@@ -23,6 +23,11 @@ set(NOVA_SANITIZERS "" CACHE STRING "Sanitizers to enable (address, undefined, l
|
||||
set(NOVA_WERROR OFF CACHE BOOL "Treat compiler warnings as errors")
|
||||
set(NOVA_LIBRARY_INSTALL OFF CACHE BOOL "Enable library installation targets")
|
||||
|
||||
# set(NOVA_BACKEND_DX12 ON CACHE BOOL "Enable DX12 backend")
|
||||
# set(NOVA_BACKEND_METAL ON CACHE BOOL "Enable Metal backend")
|
||||
set(NOVA_BACKEND_VULKAN ON CACHE BOOL "Enable Vulkan backend")
|
||||
# set(NOVA_BACKEND_WEBGPU ON CACHE BOOL "Enable WebGPU backend")
|
||||
|
||||
add_compile_definitions(
|
||||
NOVA_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||
NOVA_VERSION_MINOR=${PROJECT_VERSION_MINOR}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
set(NOVA_ENGINE_SRC
|
||||
core/debug.cpp
|
||||
graphics/context.cpp
|
||||
)
|
||||
|
||||
list(TRANSFORM NOVA_ENGINE_SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||
@@ -17,6 +18,22 @@ target_include_directories(nova
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
if (NOVA_BACKEND_VULKAN)
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
set(NOVA_VULKAN_SRC
|
||||
backends/vulkan/context.cpp
|
||||
backends/vulkan/device.cpp
|
||||
)
|
||||
|
||||
list(TRANSFORM NOVA_VULKAN_SRC PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/)
|
||||
|
||||
target_sources(nova PRIVATE ${NOVA_VULKAN_SRC})
|
||||
target_compile_definitions(nova PRIVATE NOVA_BACKEND_VULKAN)
|
||||
target_include_directories(nova PRIVATE ${Vulkan_INCLUDE_DIRS})
|
||||
target_link_libraries(nova PRIVATE Vulkan::Vulkan)
|
||||
endif()
|
||||
|
||||
set_target_properties(nova PROPERTIES
|
||||
DEFINE_SYMBOL NOVA_EXPORT_SYMBOLS
|
||||
VERSION ${PROJECT_VERSION}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Nova::Types {
|
||||
namespace nova::types {
|
||||
|
||||
using u8 = uint8_t;
|
||||
using u16 = uint16_t;
|
||||
@@ -30,6 +30,6 @@ using imax = intmax_t;
|
||||
using f32 = float;
|
||||
using f64 = double;
|
||||
|
||||
} // namespace Nova::Types
|
||||
} // namespace nova::types
|
||||
|
||||
using namespace Nova::Types;
|
||||
using namespace nova::types;
|
||||
|
||||
38
engine/include/nova/graphics/context.hpp
Normal file
38
engine/include/nova/graphics/context.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nova/core/api.hpp>
|
||||
#include <nova/core/types.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
class IDevice;
|
||||
|
||||
enum class API {
|
||||
UNDEFINED,
|
||||
VULKAN,
|
||||
};
|
||||
|
||||
class NOVA_API IContext {
|
||||
public:
|
||||
static std::unique_ptr<IContext> create(API api);
|
||||
virtual ~IContext() = default;
|
||||
|
||||
virtual API get_api() const = 0;
|
||||
virtual std::string get_api_name() const = 0;
|
||||
|
||||
virtual u32 get_api_version() const = 0;
|
||||
virtual std::string get_api_version_string() const = 0;
|
||||
|
||||
virtual std::unique_ptr<IDevice> create_device() = 0;
|
||||
};
|
||||
|
||||
} // namespace nova::gfx
|
||||
16
engine/include/nova/graphics/device.hpp
Normal file
16
engine/include/nova/graphics/device.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nova/core/api.hpp>
|
||||
#include <nova/core/types.hpp>
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
class NOVA_API IDevice {};
|
||||
|
||||
} // namespace nova::gfx
|
||||
0
engine/src/backends/metal/.gitkeep
Normal file
0
engine/src/backends/metal/.gitkeep
Normal file
45
engine/src/backends/vulkan/context.cpp
Normal file
45
engine/src/backends/vulkan/context.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include <format>
|
||||
|
||||
#include "backends/vulkan/context.hpp"
|
||||
#include "backends/vulkan/device.hpp"
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
API VulkanContext::get_api() const {
|
||||
return API::VULKAN;
|
||||
}
|
||||
|
||||
std::string VulkanContext::get_api_name() const {
|
||||
return "Vulkan";
|
||||
}
|
||||
|
||||
u32 VulkanContext::get_api_version() const {
|
||||
u32 version;
|
||||
vkEnumerateInstanceVersion(&version);
|
||||
return version;
|
||||
}
|
||||
|
||||
std::string VulkanContext::get_api_version_string() const {
|
||||
const u32 version = get_api_version();
|
||||
return std::format(
|
||||
"{}.{}.{}-{}",
|
||||
VK_API_VERSION_MAJOR(version),
|
||||
VK_API_VERSION_MINOR(version),
|
||||
VK_API_VERSION_PATCH(version),
|
||||
VK_API_VERSION_VARIANT(version)
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<IDevice> VulkanContext::create_device() {
|
||||
return std::make_unique<VulkanDevice>();
|
||||
}
|
||||
|
||||
} // namespace nova::gfx
|
||||
24
engine/src/backends/vulkan/context.hpp
Normal file
24
engine/src/backends/vulkan/context.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nova/graphics/context.hpp>
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
class VulkanContext final : public IContext {
|
||||
public:
|
||||
API get_api() const override;
|
||||
std::string get_api_name() const override;
|
||||
|
||||
u32 get_api_version() const override;
|
||||
std::string get_api_version_string() const override;
|
||||
|
||||
std::unique_ptr<IDevice> create_device() override;
|
||||
};
|
||||
|
||||
} // namespace nova::gfx
|
||||
15
engine/src/backends/vulkan/device.cpp
Normal file
15
engine/src/backends/vulkan/device.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "backends/vulkan/device.hpp"
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
18
engine/src/backends/vulkan/device.hpp
Normal file
18
engine/src/backends/vulkan/device.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nova/graphics/device.hpp>
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
class VulkanDevice final : public IDevice {
|
||||
public:
|
||||
// TODO
|
||||
};
|
||||
|
||||
} // namespace nova::gfx
|
||||
0
engine/src/backends/webgpu/.gitkeep
Normal file
0
engine/src/backends/webgpu/.gitkeep
Normal file
26
engine/src/graphics/context.cpp
Normal file
26
engine/src/graphics/context.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <nova/graphics/context.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "backends/vulkan/context.hpp"
|
||||
|
||||
namespace nova::gfx {
|
||||
|
||||
std::unique_ptr<IContext> IContext::create(API p_api) {
|
||||
switch (p_api) {
|
||||
#if defined(NOVA_BACKEND_VULKAN)
|
||||
case API::VULKAN:
|
||||
return std::make_unique<VulkanContext>();
|
||||
#endif
|
||||
default:
|
||||
throw std::runtime_error("Unsupported graphics API");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nova::gfx
|
||||
Reference in New Issue
Block a user