Skip to content

Commit dec8e5d

Browse files
authored
[merge] Merge pull request #616 from inexorgame/hanni/cleanup
Hanni/cleanup
2 parents abd3c6d + 51b698a commit dec8e5d

File tree

17 files changed

+118
-42
lines changed

17 files changed

+118
-42
lines changed

benchmarks/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,22 @@ target_link_libraries(
3434
PUBLIC
3535
benchmark::benchmark
3636
)
37+
38+
if(MSVC)
39+
# Group dependencies in Visual Studio
40+
set(THIRD_PARTY_TARGETS
41+
benchmark
42+
benchmark_main
43+
# Note that benchmark requires gtest
44+
gmock
45+
gmock_main
46+
gtest
47+
gtest_main
48+
)
49+
# Move all dependencies into a subfolder
50+
set_target_properties(${THIRD_PARTY_TARGETS}
51+
PROPERTIES
52+
EXCLUDE_FROM_ALL TRUE
53+
FOLDER "Dependencies"
54+
)
55+
endif()

benchmarks/engine_benchmark_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include <benchmark/benchmark.h>
22

3-
#include "inexor/vulkan-renderer/meta.hpp"
3+
#include "inexor/vulkan-renderer/meta/meta.hpp"
44

55
#include <iostream>
66

77
int main(int argc, char **argv) {
8-
using namespace inexor::vulkan_renderer;
8+
using namespace inexor::vulkan_renderer::meta;
99

1010
// Print engine and application metadata.
1111
std::cout << ENGINE_NAME << ", version " << ENGINE_VERSION_STR << std::endl;

include/inexor/vulkan-renderer/imgui.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include "inexor/vulkan-renderer/render_graph.hpp"
4-
#include "inexor/vulkan-renderer/wrapper/descriptor.hpp"
4+
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor.hpp"
55
#include "inexor/vulkan-renderer/wrapper/gpu_texture.hpp"
66
#include "inexor/vulkan-renderer/wrapper/shader.hpp"
77

@@ -32,7 +32,7 @@ class ImGUIOverlay {
3232
std::unique_ptr<wrapper::GpuTexture> m_imgui_texture;
3333
std::unique_ptr<wrapper::Shader> m_vertex_shader;
3434
std::unique_ptr<wrapper::Shader> m_fragment_shader;
35-
std::unique_ptr<wrapper::ResourceDescriptor> m_descriptor;
35+
std::unique_ptr<wrapper::descriptors::ResourceDescriptor> m_descriptor;
3636
std::vector<std::uint32_t> m_index_data;
3737
std::vector<ImDrawVert> m_vertex_data;
3838

include/inexor/vulkan-renderer/meta.hpp.in renamed to include/inexor/vulkan-renderer/meta/meta.hpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <array>
44

5-
namespace inexor::vulkan_renderer {
5+
namespace inexor::vulkan_renderer::meta {
66

77
/// The following data will be replaced by CMake setup.
88
constexpr const char *APP_NAME{"${INEXOR_APP_NAME}"};

include/inexor/vulkan-renderer/renderer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22

3-
#include "inexor/vulkan-renderer/camera.hpp"
43
#include "inexor/vulkan-renderer/fps_counter.hpp"
54
#include "inexor/vulkan-renderer/imgui.hpp"
65
#include "inexor/vulkan-renderer/octree_gpu_vertex.hpp"
76
#include "inexor/vulkan-renderer/time_step.hpp"
7+
#include "inexor/vulkan-renderer/tools/camera.hpp"
88
#include "inexor/vulkan-renderer/wrapper/instance.hpp"
99
#include "inexor/vulkan-renderer/wrapper/uniform_buffer.hpp"
1010
#include "inexor/vulkan-renderer/wrapper/window/surface.hpp"
@@ -35,7 +35,7 @@ class VulkanRenderer {
3535

3636
bool m_vsync_enabled{false};
3737

38-
std::unique_ptr<Camera> m_camera;
38+
std::unique_ptr<tools::Camera> m_camera;
3939

4040
std::unique_ptr<Window> m_window;
4141
std::unique_ptr<wrapper::Instance> m_instance;
@@ -48,7 +48,7 @@ class VulkanRenderer {
4848
std::vector<wrapper::Shader> m_shaders;
4949
std::vector<wrapper::GpuTexture> m_textures;
5050
std::vector<wrapper::UniformBuffer> m_uniform_buffers;
51-
std::vector<wrapper::ResourceDescriptor> m_descriptors;
51+
std::vector<wrapper::descriptors::ResourceDescriptor> m_descriptors;
5252
std::vector<OctreeGpuVertex> m_octree_vertices;
5353
std::vector<std::uint32_t> m_octree_indices;
5454

include/inexor/vulkan-renderer/camera.hpp renamed to include/inexor/vulkan-renderer/tools/camera.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <array>
88
#include <vector>
99

10-
namespace inexor::vulkan_renderer {
10+
namespace inexor::vulkan_renderer::tools {
1111

1212
namespace directions {
1313
/// The default value of the camera's front vector.
@@ -225,4 +225,4 @@ class Camera {
225225
return m_perspective_matrix;
226226
}
227227
};
228-
} // namespace inexor::vulkan_renderer
228+
} // namespace inexor::vulkan_renderer::tools

include/inexor/vulkan-renderer/wrapper/descriptor.hpp renamed to include/inexor/vulkan-renderer/wrapper/descriptors/descriptor.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#include <vector>
77

88
namespace inexor::vulkan_renderer::wrapper {
9-
109
// Forward declaration
1110
class Device;
11+
} // namespace inexor::vulkan_renderer::wrapper
12+
13+
namespace inexor::vulkan_renderer::wrapper::descriptors {
1214

1315
/// @brief RAII wrapper class for resource descriptors.
1416
class ResourceDescriptor {
@@ -49,4 +51,4 @@ class ResourceDescriptor {
4951
}
5052
};
5153

52-
} // namespace inexor::vulkan_renderer::wrapper
54+
} // namespace inexor::vulkan_renderer::wrapper::descriptors

include/inexor/vulkan-renderer/wrapper/descriptor_builder.hpp renamed to include/inexor/vulkan-renderer/wrapper/descriptors/descriptor_builder.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
#include <vector>
1111

1212
namespace inexor::vulkan_renderer::wrapper {
13-
14-
// Forward declarations
13+
// Forward declaration
1514
class Device;
15+
} // namespace inexor::vulkan_renderer::wrapper
16+
17+
namespace inexor::vulkan_renderer::wrapper::descriptors {
18+
1619
class ResourceDescriptor;
1720

1821
class DescriptorBuilder {
@@ -96,4 +99,4 @@ DescriptorBuilder &DescriptorBuilder::add_uniform_buffer(const VkBuffer uniform_
9699
return *this;
97100
}
98101

99-
} // namespace inexor::vulkan_renderer::wrapper
102+
} // namespace inexor::vulkan_renderer::wrapper::descriptors

src/CMakeLists.txt

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
set(INEXOR_SOURCE_FILES
22
vulkan-renderer/application.cpp
3-
vulkan-renderer/camera.cpp
43
vulkan-renderer/exception.cpp
54
vulkan-renderer/fps_counter.cpp
65
vulkan-renderer/imgui.cpp
@@ -15,15 +14,14 @@ set(INEXOR_SOURCE_FILES
1514
vulkan-renderer/io/byte_stream.cpp
1615
vulkan-renderer/io/nxoc_parser.cpp
1716

17+
vulkan-renderer/tools/camera.cpp
1818
vulkan-renderer/tools/cla_parser.cpp
1919
vulkan-renderer/tools/device_info.cpp
2020
vulkan-renderer/tools/enumerate.cpp
2121
vulkan-renderer/tools/file.cpp
2222
vulkan-renderer/tools/representation.cpp
2323

2424
vulkan-renderer/wrapper/cpu_texture.cpp
25-
vulkan-renderer/wrapper/descriptor.cpp
26-
vulkan-renderer/wrapper/descriptor_builder.cpp
2725
vulkan-renderer/wrapper/device.cpp
2826
vulkan-renderer/wrapper/framebuffer.cpp
2927
vulkan-renderer/wrapper/gpu_memory_buffer.cpp
@@ -38,6 +36,9 @@ set(INEXOR_SOURCE_FILES
3836
vulkan-renderer/wrapper/commands/command_buffer.cpp
3937
vulkan-renderer/wrapper/commands/command_pool.cpp
4038

39+
vulkan-renderer/wrapper/descriptors/descriptor.cpp
40+
vulkan-renderer/wrapper/descriptors/descriptor_builder.cpp
41+
4142
vulkan-renderer/wrapper/window/window.cpp
4243
vulkan-renderer/wrapper/window/surface.cpp
4344

@@ -100,8 +101,8 @@ endif()
100101

101102
# Replace variables in header file with CMake values
102103
configure_file(
103-
${PROJECT_SOURCE_DIR}/include/inexor/vulkan-renderer/meta.hpp.in
104-
${CMAKE_CURRENT_BINARY_DIR}/include/inexor/vulkan-renderer/meta.hpp
104+
${PROJECT_SOURCE_DIR}/include/inexor/vulkan-renderer/meta/meta.hpp.in
105+
${CMAKE_CURRENT_BINARY_DIR}/include/inexor/vulkan-renderer/meta/meta.hpp
105106
)
106107

107108
target_include_directories(
@@ -144,3 +145,32 @@ target_link_libraries(inexor-vulkan-renderer
144145
volk::volk
145146
Vulkan::Headers
146147
VulkanMemoryAllocator)
148+
149+
if(MSVC)
150+
# Group dependencies in Visual Studio
151+
set(THIRD_PARTY_TARGETS
152+
glfw
153+
fmt
154+
glm
155+
imgui
156+
spdlog
157+
volk
158+
VulkanMemoryAllocator
159+
tinygltf
160+
toml11
161+
# Also those extra ones
162+
loader_example
163+
uninstall
164+
update_mappings
165+
Continuous
166+
Experimental
167+
Nightly
168+
NightlyMemoryCheck
169+
)
170+
# Move all dependencies into a subfolder
171+
set_target_properties(${THIRD_PARTY_TARGETS}
172+
PROPERTIES
173+
EXCLUDE_FROM_ALL TRUE
174+
FOLDER "Dependencies"
175+
)
176+
endif()

src/vulkan-renderer/application.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "inexor/vulkan-renderer/application.hpp"
22

3-
#include "inexor/vulkan-renderer/camera.hpp"
43
#include "inexor/vulkan-renderer/exception.hpp"
5-
#include "inexor/vulkan-renderer/meta.hpp"
4+
#include "inexor/vulkan-renderer/meta/meta.hpp"
65
#include "inexor/vulkan-renderer/octree_gpu_vertex.hpp"
76
#include "inexor/vulkan-renderer/standard_ubo.hpp"
7+
#include "inexor/vulkan-renderer/tools/camera.hpp"
88
#include "inexor/vulkan-renderer/tools/cla_parser.hpp"
99
#include "inexor/vulkan-renderer/tools/enumerate.hpp"
1010
#include "inexor/vulkan-renderer/world/collision.hpp"
1111
#include "inexor/vulkan-renderer/wrapper/cpu_texture.hpp"
12-
#include "inexor/vulkan-renderer/wrapper/descriptor_builder.hpp"
12+
#include "inexor/vulkan-renderer/wrapper/descriptors/descriptor_builder.hpp"
1313
#include "inexor/vulkan-renderer/wrapper/instance.hpp"
1414

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

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

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

306+
using namespace vulkan_renderer::meta;
307+
306308
spdlog::trace("Application version: {}.{}.{}", APP_VERSION[0], APP_VERSION[1], APP_VERSION[2]);
307309
spdlog::trace("Engine version: {}.{}.{}", ENGINE_VERSION[0], ENGINE_VERSION[1], ENGINE_VERSION[2]);
308310

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

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

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

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

532+
using namespace tools;
533+
529534
if (m_camera->type() == CameraType::LOOK_AT &&
530535
m_input->kbm_data().is_mouse_button_pressed(GLFW_MOUSE_BUTTON_LEFT)) {
531536
m_camera->rotate(static_cast<float>(cursor_pos_delta[0]), -static_cast<float>(cursor_pos_delta[1]));

0 commit comments

Comments
 (0)