Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,22 @@ target_link_libraries(
PUBLIC
benchmark::benchmark
)

if(MSVC)
# Group dependencies in Visual Studio
set(THIRD_PARTY_TARGETS
benchmark
benchmark_main
# Note that benchmark requires gtest
gmock
gmock_main
gtest
gtest_main
)
# Move all dependencies into a subfolder
set_target_properties(${THIRD_PARTY_TARGETS}
PROPERTIES
EXCLUDE_FROM_ALL TRUE
FOLDER "Dependencies"
)
endif()
4 changes: 2 additions & 2 deletions benchmarks/engine_benchmark_main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <benchmark/benchmark.h>

#include "inexor/vulkan-renderer/meta.hpp"
#include "inexor/vulkan-renderer/meta/meta.hpp"

#include <iostream>

int main(int argc, char **argv) {
using namespace inexor::vulkan_renderer;
using namespace inexor::vulkan_renderer::meta;

// Print engine and application metadata.
std::cout << ENGINE_NAME << ", version " << ENGINE_VERSION_STR << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions include/inexor/vulkan-renderer/imgui.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "inexor/vulkan-renderer/render_graph.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/gpu_texture.hpp"
#include "inexor/vulkan-renderer/wrapper/shader.hpp"

Expand Down Expand Up @@ -32,7 +32,7 @@ class ImGUIOverlay {
std::unique_ptr<wrapper::GpuTexture> m_imgui_texture;
std::unique_ptr<wrapper::Shader> m_vertex_shader;
std::unique_ptr<wrapper::Shader> m_fragment_shader;
std::unique_ptr<wrapper::ResourceDescriptor> m_descriptor;
std::unique_ptr<wrapper::descriptors::ResourceDescriptor> m_descriptor;
std::vector<std::uint32_t> m_index_data;
std::vector<ImDrawVert> m_vertex_data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <array>

namespace inexor::vulkan_renderer {
namespace inexor::vulkan_renderer::meta {

/// The following data will be replaced by CMake setup.
constexpr const char *APP_NAME{"${INEXOR_APP_NAME}"};
Expand Down
6 changes: 3 additions & 3 deletions include/inexor/vulkan-renderer/renderer.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "inexor/vulkan-renderer/camera.hpp"
#include "inexor/vulkan-renderer/fps_counter.hpp"
#include "inexor/vulkan-renderer/imgui.hpp"
#include "inexor/vulkan-renderer/octree_gpu_vertex.hpp"
#include "inexor/vulkan-renderer/time_step.hpp"
#include "inexor/vulkan-renderer/tools/camera.hpp"
#include "inexor/vulkan-renderer/wrapper/instance.hpp"
#include "inexor/vulkan-renderer/wrapper/uniform_buffer.hpp"
#include "inexor/vulkan-renderer/wrapper/window/surface.hpp"
Expand Down Expand Up @@ -35,7 +35,7 @@ class VulkanRenderer {

bool m_vsync_enabled{false};

std::unique_ptr<Camera> m_camera;
std::unique_ptr<tools::Camera> m_camera;

std::unique_ptr<Window> m_window;
std::unique_ptr<wrapper::Instance> m_instance;
Expand All @@ -48,7 +48,7 @@ class VulkanRenderer {
std::vector<wrapper::Shader> m_shaders;
std::vector<wrapper::GpuTexture> m_textures;
std::vector<wrapper::UniformBuffer> m_uniform_buffers;
std::vector<wrapper::ResourceDescriptor> m_descriptors;
std::vector<wrapper::descriptors::ResourceDescriptor> m_descriptors;
std::vector<OctreeGpuVertex> m_octree_vertices;
std::vector<std::uint32_t> m_octree_indices;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <array>
#include <vector>

namespace inexor::vulkan_renderer {
namespace inexor::vulkan_renderer::tools {

namespace directions {
/// The default value of the camera's front vector.
Expand Down Expand Up @@ -225,4 +225,4 @@ class Camera {
return m_perspective_matrix;
}
};
} // namespace inexor::vulkan_renderer
} // namespace inexor::vulkan_renderer::tools
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#include <vector>

namespace inexor::vulkan_renderer::wrapper {

// Forward declaration
class Device;
} // namespace inexor::vulkan_renderer::wrapper

namespace inexor::vulkan_renderer::wrapper::descriptors {

/// @brief RAII wrapper class for resource descriptors.
class ResourceDescriptor {
Expand Down Expand Up @@ -49,4 +51,4 @@ class ResourceDescriptor {
}
};

} // namespace inexor::vulkan_renderer::wrapper
} // namespace inexor::vulkan_renderer::wrapper::descriptors
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
#include <vector>

namespace inexor::vulkan_renderer::wrapper {

// Forward declarations
// Forward declaration
class Device;
} // namespace inexor::vulkan_renderer::wrapper

namespace inexor::vulkan_renderer::wrapper::descriptors {

class ResourceDescriptor;

class DescriptorBuilder {
Expand Down Expand Up @@ -96,4 +99,4 @@ DescriptorBuilder &DescriptorBuilder::add_uniform_buffer(const VkBuffer uniform_
return *this;
}

} // namespace inexor::vulkan_renderer::wrapper
} // namespace inexor::vulkan_renderer::wrapper::descriptors
40 changes: 35 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(INEXOR_SOURCE_FILES
vulkan-renderer/application.cpp
vulkan-renderer/camera.cpp
vulkan-renderer/exception.cpp
vulkan-renderer/fps_counter.cpp
vulkan-renderer/imgui.cpp
Expand All @@ -15,15 +14,14 @@ set(INEXOR_SOURCE_FILES
vulkan-renderer/io/byte_stream.cpp
vulkan-renderer/io/nxoc_parser.cpp

vulkan-renderer/tools/camera.cpp
vulkan-renderer/tools/cla_parser.cpp
vulkan-renderer/tools/device_info.cpp
vulkan-renderer/tools/enumerate.cpp
vulkan-renderer/tools/file.cpp
vulkan-renderer/tools/representation.cpp

vulkan-renderer/wrapper/cpu_texture.cpp
vulkan-renderer/wrapper/descriptor.cpp
vulkan-renderer/wrapper/descriptor_builder.cpp
vulkan-renderer/wrapper/device.cpp
vulkan-renderer/wrapper/framebuffer.cpp
vulkan-renderer/wrapper/gpu_memory_buffer.cpp
Expand All @@ -38,6 +36,9 @@ set(INEXOR_SOURCE_FILES
vulkan-renderer/wrapper/commands/command_buffer.cpp
vulkan-renderer/wrapper/commands/command_pool.cpp

vulkan-renderer/wrapper/descriptors/descriptor.cpp
vulkan-renderer/wrapper/descriptors/descriptor_builder.cpp

vulkan-renderer/wrapper/window/window.cpp
vulkan-renderer/wrapper/window/surface.cpp

Expand Down Expand Up @@ -100,8 +101,8 @@ endif()

# Replace variables in header file with CMake values
configure_file(
${PROJECT_SOURCE_DIR}/include/inexor/vulkan-renderer/meta.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/inexor/vulkan-renderer/meta.hpp
${PROJECT_SOURCE_DIR}/include/inexor/vulkan-renderer/meta/meta.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/inexor/vulkan-renderer/meta/meta.hpp
)

target_include_directories(
Expand Down Expand Up @@ -144,3 +145,32 @@ target_link_libraries(inexor-vulkan-renderer
volk::volk
Vulkan::Headers
VulkanMemoryAllocator)

if(MSVC)
# Group dependencies in Visual Studio
set(THIRD_PARTY_TARGETS
glfw
fmt
glm
imgui
spdlog
volk
VulkanMemoryAllocator
tinygltf
toml11
# Also those extra ones
loader_example
uninstall
update_mappings
Continuous
Experimental
Nightly
NightlyMemoryCheck
)
# Move all dependencies into a subfolder
set_target_properties(${THIRD_PARTY_TARGETS}
PROPERTIES
EXCLUDE_FROM_ALL TRUE
FOLDER "Dependencies"
)
endif()
17 changes: 11 additions & 6 deletions src/vulkan-renderer/application.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "inexor/vulkan-renderer/application.hpp"

#include "inexor/vulkan-renderer/camera.hpp"
#include "inexor/vulkan-renderer/exception.hpp"
#include "inexor/vulkan-renderer/meta.hpp"
#include "inexor/vulkan-renderer/meta/meta.hpp"
#include "inexor/vulkan-renderer/octree_gpu_vertex.hpp"
#include "inexor/vulkan-renderer/standard_ubo.hpp"
#include "inexor/vulkan-renderer/tools/camera.hpp"
#include "inexor/vulkan-renderer/tools/cla_parser.hpp"
#include "inexor/vulkan-renderer/tools/enumerate.hpp"
#include "inexor/vulkan-renderer/world/collision.hpp"
#include "inexor/vulkan-renderer/wrapper/cpu_texture.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptor_builder.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor_builder.hpp"
#include "inexor/vulkan-renderer/wrapper/instance.hpp"

#include <GLFW/glfw3.h>
Expand Down Expand Up @@ -286,7 +286,7 @@ void Application::initialize_spdlog() {
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();

// A copy of the console output will automatically be saved to a logfile
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(std::string(APP_NAME) + ".log", true);
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(std::string(meta::APP_NAME) + ".log", true);
auto logger = std::make_shared<spdlog::async_logger>("main", spdlog::sinks_init_list{console_sink, file_sink},
spdlog::thread_pool(), spdlog::async_overflow_policy::block);

Expand All @@ -303,6 +303,8 @@ void Application::initialize_spdlog() {
Application::Application(int argc, char **argv) {
initialize_spdlog();

using namespace vulkan_renderer::meta;

spdlog::trace("Application version: {}.{}.{}", APP_VERSION[0], APP_VERSION[1], APP_VERSION[2]);
spdlog::trace("Engine version: {}.{}.{}", ENGINE_VERSION[0], ENGINE_VERSION[1], ENGINE_VERSION[2]);

Expand Down Expand Up @@ -451,7 +453,7 @@ Application::Application(int argc, char **argv) {

// Create an instance of the resource descriptor builder.
// This allows us to make resource descriptors with the help of a builder pattern.
wrapper::DescriptorBuilder descriptor_builder(*m_device);
wrapper::descriptors::DescriptorBuilder descriptor_builder(*m_device);

// Make use of the builder to create a resource descriptor for the uniform buffer.
m_descriptors.emplace_back(
Expand Down Expand Up @@ -492,7 +494,8 @@ void Application::update_imgui_overlay() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
ImGui::SetNextWindowPos(ImVec2(10, 10));
ImGui::SetNextWindowSize(ImVec2(330, 0));
ImGui::Begin("Inexor Vulkan-renderer", nullptr,
using namespace vulkan_renderer::meta;
ImGui::Begin(APP_NAME, nullptr,
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
ImGui::Text("%s", m_device->gpu_name().c_str());
ImGui::Text("Engine version %d.%d.%d (Git sha %s)", ENGINE_VERSION[0], ENGINE_VERSION[1], ENGINE_VERSION[2],
Expand Down Expand Up @@ -526,6 +529,8 @@ void Application::process_input() {

auto deadzone_lambda = [](const float state) { return (glm::abs(state) < 0.2f) ? 0.0f : state; };

using namespace tools;

if (m_camera->type() == CameraType::LOOK_AT &&
m_input->kbm_data().is_mouse_button_pressed(GLFW_MOUSE_BUTTON_LEFT)) {
m_camera->rotate(static_cast<float>(cursor_pos_delta[0]), -static_cast<float>(cursor_pos_delta[1]));
Expand Down
6 changes: 3 additions & 3 deletions src/vulkan-renderer/imgui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "inexor/vulkan-renderer/imgui.hpp"

#include "inexor/vulkan-renderer/wrapper/cpu_texture.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptor_builder.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor_builder.hpp"
#include "inexor/vulkan-renderer/wrapper/make_info.hpp"

#include <cassert>
Expand Down Expand Up @@ -78,10 +78,10 @@ ImGUIOverlay::ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapcha

// Create an instance of the resource descriptor builder.
// This allows us to make resource descriptors with the help of a builder pattern.
wrapper::DescriptorBuilder descriptor_builder(m_device);
wrapper::descriptors::DescriptorBuilder descriptor_builder(m_device);

// Make use of the builder to create a resource descriptor for the combined image sampler.
m_descriptor = std::make_unique<wrapper::ResourceDescriptor>(
m_descriptor = std::make_unique<wrapper::descriptors::ResourceDescriptor>(
descriptor_builder.add_combined_image_sampler(m_imgui_texture->sampler(), m_imgui_texture->image_view(), 0)
.build("ImGUI"));

Expand Down
3 changes: 2 additions & 1 deletion src/vulkan-renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ void VulkanRenderer::recreate_swapchain() {
m_render_graph = std::make_unique<RenderGraph>(*m_device, *m_swapchain);
setup_render_graph();

m_camera = std::make_unique<Camera>(glm::vec3(6.0f, 10.0f, 2.0f), 180.0f, 0.0f,
m_camera =
std::make_unique<tools::Camera>(glm::vec3(6.0f, 10.0f, 2.0f), 180.0f, 0.0f,
static_cast<float>(m_window->width()), static_cast<float>(m_window->height()));

m_camera->set_movement_speed(5.0f);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "inexor/vulkan-renderer/camera.hpp"
#include "inexor/vulkan-renderer/tools/camera.hpp"

namespace inexor::vulkan_renderer {
namespace inexor::vulkan_renderer::tools {

Camera::Camera(const glm::vec3 &position, const float yaw, const float pitch, const float window_width,
const float window_height)
Expand Down Expand Up @@ -144,4 +144,4 @@ void Camera::update(const float delta_time) {
}
}

} // namespace inexor::vulkan_renderer
} // namespace inexor::vulkan_renderer::tools
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "inexor/vulkan-renderer/wrapper/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor.hpp"

#include "inexor/vulkan-renderer/exception.hpp"
#include "inexor/vulkan-renderer/wrapper/device.hpp"
Expand All @@ -7,7 +7,7 @@
#include <cassert>
#include <utility>

namespace inexor::vulkan_renderer::wrapper {
namespace inexor::vulkan_renderer::wrapper::descriptors {

ResourceDescriptor::ResourceDescriptor(ResourceDescriptor &&other) noexcept : m_device(other.m_device) {
m_name = std::move(other.m_name);
Expand Down Expand Up @@ -91,4 +91,4 @@ ResourceDescriptor::~ResourceDescriptor() {
vkDestroyDescriptorPool(m_device.device(), m_descriptor_pool, nullptr);
}

} // namespace inexor::vulkan_renderer::wrapper
} // namespace inexor::vulkan_renderer::wrapper::descriptors
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "inexor/vulkan-renderer/wrapper/descriptor_builder.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor_builder.hpp"

#include "inexor/vulkan-renderer/wrapper/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor.hpp"
#include "inexor/vulkan-renderer/wrapper/device.hpp"

#include <utility>

namespace inexor::vulkan_renderer::wrapper {
namespace inexor::vulkan_renderer::wrapper::descriptors {

DescriptorBuilder::DescriptorBuilder(const Device &device) : m_device(device) {
assert(m_device.device());
Expand Down Expand Up @@ -58,4 +58,4 @@ DescriptorBuilder &DescriptorBuilder::add_combined_image_sampler(const VkSampler
return *this;
}

} // namespace inexor::vulkan_renderer::wrapper
} // namespace inexor::vulkan_renderer::wrapper::descriptors
Loading
Loading