Compare commits

..

2 Commits

5 changed files with 41 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ set(NOVA_LIBRARY_INSTALL OFF CACHE BOOL "Enable library installation targets")
set(NOVA_BACKEND_VULKAN ON CACHE BOOL "Enable Vulkan backend") set(NOVA_BACKEND_VULKAN ON CACHE BOOL "Enable Vulkan backend")
# set(NOVA_BACKEND_WEBGPU ON CACHE BOOL "Enable WebGPU backend") # set(NOVA_BACKEND_WEBGPU ON CACHE BOOL "Enable WebGPU backend")
set(NOVA_USE_VOLK ON CACHE BOOL "Use volk for Vulkan function loading")
add_compile_definitions( add_compile_definitions(
NOVA_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} NOVA_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
NOVA_VERSION_MINOR=${PROJECT_VERSION_MINOR} NOVA_VERSION_MINOR=${PROJECT_VERSION_MINOR}

View File

@@ -1,6 +1,8 @@
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com> # Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
include(FetchContent)
set(NOVA_ENGINE_SRC set(NOVA_ENGINE_SRC
core/debug.cpp core/debug.cpp
graphics/context.cpp graphics/context.cpp
@@ -31,7 +33,21 @@ if (NOVA_BACKEND_VULKAN)
target_sources(nova PRIVATE ${NOVA_VULKAN_SRC}) target_sources(nova PRIVATE ${NOVA_VULKAN_SRC})
target_compile_definitions(nova PRIVATE NOVA_BACKEND_VULKAN) target_compile_definitions(nova PRIVATE NOVA_BACKEND_VULKAN)
target_include_directories(nova PRIVATE ${Vulkan_INCLUDE_DIRS}) target_include_directories(nova PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(nova PRIVATE Vulkan::Vulkan)
if (NOVA_USE_VOLK)
FetchContent_Declare(
volk
GIT_REPOSITORY https://github.com/zeux/volk.git
GIT_TAG f30088b3f4160810b53e19258dd2f7395e5f0ba3 # 1.4.328.1
)
FetchContent_MakeAvailable(volk)
target_compile_definitions(nova PRIVATE NOVA_USE_VOLK)
target_include_directories(nova PRIVATE ${volk_INCLUDE_DIRS})
target_link_libraries(nova PRIVATE volk::volk)
else()
target_link_libraries(nova PRIVATE Vulkan::Vulkan)
endif()
endif() endif()
set_target_properties(nova PROPERTIES set_target_properties(nova PROPERTIES

View File

@@ -4,6 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#if defined(NOVA_USE_VOLK)
#include <volk.h>
#endif
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <format> #include <format>
@@ -13,6 +17,14 @@
namespace nova::gfx { namespace nova::gfx {
VulkanContext::VulkanContext() {
#if defined(NOVA_USE_VOLK)
if (volkInitialize() != VK_SUCCESS) {
throw std::runtime_error("Failed to initialize volk");
}
#endif
}
API VulkanContext::get_api() const { API VulkanContext::get_api() const {
return API::VULKAN; return API::VULKAN;
} }

View File

@@ -8,10 +8,14 @@
#include <nova/graphics/context.hpp> #include <nova/graphics/context.hpp>
#include <vulkan/vulkan.h>
namespace nova::gfx { namespace nova::gfx {
class VulkanContext final : public IContext { class VulkanContext final : public IContext {
public: public:
VulkanContext();
API get_api() const override; API get_api() const override;
std::string get_api_name() const override; std::string get_api_name() const override;
@@ -19,6 +23,9 @@ class VulkanContext final : public IContext {
std::string get_api_version_string() const override; std::string get_api_version_string() const override;
std::unique_ptr<IDevice> create_device() override; std::unique_ptr<IDevice> create_device() override;
private:
VkInstance m_instance = VK_NULL_HANDLE;
}; };
} // namespace nova::gfx } // namespace nova::gfx

View File

@@ -8,7 +8,9 @@
#include <stdexcept> #include <stdexcept>
#include "backends/vulkan/context.hpp" #if defined(NOVA_BACKEND_VULKAN)
#include "backends/vulkan/context.hpp"
#endif
namespace nova::gfx { namespace nova::gfx {