Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor rendergraph #533

Draft
wants to merge 179 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
f9d0dc7
[*] Remove unused msaa target file
IAmNotHanni May 12, 2023
85fb116
[sampler] Add wrapper for samplers
IAmNotHanni May 12, 2023
2d92705
[pipeline] Add wrapper for graphics pipelines
IAmNotHanni May 12, 2023
f140dfe
[pipeline-layout] Add wrapper for pipeline layouts
IAmNotHanni May 13, 2023
07aa64c
[make-info] Add more functions
IAmNotHanni May 13, 2023
568de1d
[gpu-texture] Use sampler wrapper (squash me)
IAmNotHanni May 17, 2023
00737f1
[render-graph] Use wrappers for pipelines and pipeline layouts (squas…
IAmNotHanni May 17, 2023
f66742e
[buffer] Add buffer wrapper
IAmNotHanni May 17, 2023
6ebdd69
[*] Use new buffer wrapper
IAmNotHanni May 17, 2023
ae04933
[*] Rewrite image wrapper
IAmNotHanni May 19, 2023
7020dd8
[render-graph] Use buffer wrapper
IAmNotHanni May 19, 2023
d4b2559
[render-graph] Simplify use of image wrapper
IAmNotHanni May 19, 2023
a2cf9d0
[render-graph] Move update of dynamic buffers into separate method
IAmNotHanni May 20, 2023
ada2e11
[image|render-graph] Improve image wrapper further
IAmNotHanni May 20, 2023
c47f810
[pipeline-builder|render-graph] Use graphics pipeline builder
IAmNotHanni May 20, 2023
59178a9
[render-graph|render-pass] Add wrapper for renderpasses
IAmNotHanni May 21, 2023
5f5ba9c
[*] Introduce update mechanism to ImGui
IAmNotHanni May 24, 2023
91dbcaa
[*] Remove renderer base class
IAmNotHanni May 24, 2023
5692271
[*] Add template for push constant ranges
IAmNotHanni May 24, 2023
226acf5
[render-graph] Remove build_pipeline_layout method
IAmNotHanni May 24, 2023
5cebeef
[*] Allow chaining rendergraph methods
IAmNotHanni May 24, 2023
f074710
[*] Move pipeline setup to stage wrapper
IAmNotHanni May 25, 2023
ac90edc
[*] Restructure renderer
IAmNotHanni Jun 1, 2023
5375033
[application|render-graph] Set texture format directly in constructor
IAmNotHanni Jun 1, 2023
fc61ec0
[render-graph] Make physical stage a physical resource
IAmNotHanni Jun 1, 2023
0242200
[render-graph] Simplify dynamic cast methods
IAmNotHanni Jun 1, 2023
844e450
[render-graph] Remove unused method
IAmNotHanni Jun 1, 2023
b8a1baa
[buffer|imgui] Improve ImGUI wrapper and update every frame
IAmNotHanni Jun 1, 2023
d4570da
[application|device] Move wait_idle to destructor of device wrapper
IAmNotHanni Jun 4, 2023
1a475e7
[application] Make depth buffer a member
IAmNotHanni Jun 4, 2023
ee8c1a8
[imgui|render-graph] Automate push constant range handling
IAmNotHanni Jun 4, 2023
cf9ec0c
[device] Query physical device properties in constructor
IAmNotHanni Jun 4, 2023
7ba29ee
[descriptors] Add new descriptor wrapper code
IAmNotHanni Jun 9, 2023
db25473
[*] Automate descriptor management and buffer updates
IAmNotHanni Jun 10, 2023
5c98148
[pipelines] Move pipeline related wrappers to subfolder
IAmNotHanni Jun 10, 2023
a5ad65d
[rendergraph] Put rendergraph compilation into smaller methods
IAmNotHanni Jun 10, 2023
87a021f
[render-graph] Improve formatting of console output
IAmNotHanni Jun 10, 2023
3fbf3b6
[render-graph] Small improvements
IAmNotHanni Jun 10, 2023
f6be7ac
[*] Cleanup
IAmNotHanni Jun 10, 2023
817f83a
[*] Small cleanup
IAmNotHanni Jun 10, 2023
512975b
[render-graph] Fix descriptor set updates
IAmNotHanni Jun 10, 2023
2baa257
[render-graph] Small cleanup
IAmNotHanni Jun 11, 2023
5aa0433
[descriptor] Fix descriptor pool management
IAmNotHanni Jun 11, 2023
a9d24c5
[application|render-graph] Omitting shader stage when specifying read…
IAmNotHanni Jun 11, 2023
d7226ba
[application] Small improvement to buffer updates
IAmNotHanni Jun 16, 2023
7728222
[descriptors] Improve overall descriptor management
IAmNotHanni Jun 16, 2023
20f9b6f
[rendergraph] Add more const
IAmNotHanni Jun 16, 2023
64fd3b4
[*] Rework descriptor management
IAmNotHanni Jun 17, 2023
33f8524
[rendergraph] Fix descriptors for combined image samplers
IAmNotHanni Jun 17, 2023
971f7c9
[*] Backup of work
IAmNotHanni Jun 18, 2023
9f38440
[*] Backup of work
IAmNotHanni Jun 18, 2023
7f16360
[instance] Switch to using Vulkan 1.3
IAmNotHanni Jun 19, 2023
a9c3b8e
[image|render-graph] Add another constructor for image wrapper
IAmNotHanni Jun 20, 2023
dffa1e8
[*] Switch to VK_EXT_debug_utils
IAmNotHanni Jun 20, 2023
12d23ac
[application|instance] Remove incorrect manual use of RenderDoc insta…
IAmNotHanni Jun 20, 2023
2f8f053
[doc] Correct use of RenderDoc in this project
IAmNotHanni Jun 20, 2023
197d1b8
[application] Remove option for disabling debug markers because they …
IAmNotHanni Jun 20, 2023
23e0957
[*] Use VK_EXT_debug_utils
IAmNotHanni Aug 2, 2023
64a9fec
[*] Move setup of debug messenger callback to instance wrapper
IAmNotHanni Aug 2, 2023
69c31d3
[*] Cleanup use of VK_EXT_debug_utils
IAmNotHanni Aug 2, 2023
a9818e7
[*] Fix debug utils
IAmNotHanni Aug 2, 2023
d1a7439
[device] Delete move constructor of device wrapper
IAmNotHanni Aug 2, 2023
53be5bd
[*] Remove misplaced methods in device wrapper
IAmNotHanni Aug 2, 2023
4039951
[*] Use debug utils naming system
IAmNotHanni Aug 2, 2023
1b979b6
[commad-buffer] Small cleanup
IAmNotHanni Aug 3, 2023
a283da7
[instance] Small cleanup
IAmNotHanni Aug 3, 2023
aae3d14
[*] Small cleanup of debug utils
IAmNotHanni Aug 3, 2023
bf30179
[swapchain] Allow vsync to be turned off again
IAmNotHanni Aug 3, 2023
6a526bf
[device] Add method for finding max sample count
IAmNotHanni Aug 3, 2023
e94d128
[*] Prepare for dynamic rendering
IAmNotHanni Aug 3, 2023
423b554
WIP
IAmNotHanni Aug 4, 2023
ab4c498
WIP
IAmNotHanni Aug 11, 2023
72530b3
[*] Use dynamic rendering
IAmNotHanni Oct 22, 2023
0cdf6eb
[*] WIP
IAmNotHanni Oct 23, 2023
92de322
[*] WIP
IAmNotHanni Oct 23, 2023
8b87f66
[*] WIP
IAmNotHanni Nov 3, 2023
d91c5e8
[*] WIP
IAmNotHanni Nov 3, 2023
160d7bf
[*] Backup of work
IAmNotHanni Nov 19, 2023
24ca21c
[*] WIP
IAmNotHanni Nov 19, 2023
9bd37ce
[*] WIP
IAmNotHanni Nov 19, 2023
d888c5b
[*] WIP
IAmNotHanni Nov 22, 2023
8258c7b
[*] WIP (broken)
IAmNotHanni Apr 10, 2024
f249425
[*] Improve set_debug_name
IAmNotHanni Apr 10, 2024
9a92d2e
[*] WIP
IAmNotHanni Apr 11, 2024
d9f98d6
[*] WIP
IAmNotHanni Apr 11, 2024
39e7e9c
[*] WIP
IAmNotHanni Apr 11, 2024
4097b45
[*] WIP
IAmNotHanni Apr 11, 2024
e71a1e7
[*] WIP
IAmNotHanni Apr 11, 2024
44a81e6
[*] WIP
IAmNotHanni Apr 11, 2024
c418427
[*] WIP
IAmNotHanni Apr 11, 2024
0cff923
[*] WIP
IAmNotHanni Apr 11, 2024
a663272
[*] WIP
IAmNotHanni Apr 11, 2024
a47e478
[*] WIP
IAmNotHanni Apr 12, 2024
c0c27ac
[WIP] Work in progress
IAmNotHanni Jun 24, 2024
7198888
[WIP] Work in progress
IAmNotHanni Jun 24, 2024
3ebc562
[WIP] Work in progress
IAmNotHanni Jun 24, 2024
a4bbfc6
[WIP] Work in progress
IAmNotHanni Jun 24, 2024
638e2e1
[WIP] Work in progress
IAmNotHanni Jun 26, 2024
85de555
[WIP] Work in progress
IAmNotHanni Jun 26, 2024
4ee9e44
[WIP] Work in progress
IAmNotHanni Jun 26, 2024
afc43c0
[WIP] Work in progress
IAmNotHanni Jun 27, 2024
bd8ad96
[WIP] Work in progress
IAmNotHanni Jun 27, 2024
0468c40
[WIP] Work in progress
IAmNotHanni Jun 30, 2024
2ac69f0
[WIP] Work in progress
IAmNotHanni Jun 30, 2024
e0600f5
[WIP] Work in progress
IAmNotHanni Jun 30, 2024
36a7691
[WIP] Work in progress
IAmNotHanni Jun 30, 2024
fa45441
[WIP] Work in progress
IAmNotHanni Jul 1, 2024
8365d87
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
386a949
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
aee8d7f
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
2ec2397
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
79f9de6
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
8c0356f
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
c557006
[WIP] Work in progress
IAmNotHanni Jul 2, 2024
8dd6bf9
[WIP] Work in progress
IAmNotHanni Jul 3, 2024
9bc5f7b
[WIP] Work in progress
IAmNotHanni Jul 3, 2024
0580be9
[WIP] Work in progress
IAmNotHanni Jul 3, 2024
e71abd9
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
7cf57c5
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
718219c
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
dca0128
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
b90e67f
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
ec78f20
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
106e5c6
[WIP] Work in progress
IAmNotHanni Jul 9, 2024
bce5a05
[WIP] Work in progress
IAmNotHanni Jul 11, 2024
b164185
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
e7b9d15
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
e0096b5
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
7c38a6f
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
7613930
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
8832357
[WIP] Work in progress
IAmNotHanni Jul 12, 2024
669c13e
[WIP] Work in progress
IAmNotHanni Jul 13, 2024
838523f
[WIP] Work in progress
IAmNotHanni Jul 13, 2024
62acd17
[*] Cleanup
IAmNotHanni Jul 14, 2024
c8facc6
[*] Cleanup
IAmNotHanni Jul 14, 2024
b544ad5
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
aa96b41
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
9f7245b
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
159e0d0
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
24ae683
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
a3c9543
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
f48bcba
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
46fea99
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
34fa113
[WIP] Work in progress
IAmNotHanni Jul 16, 2024
b7333bc
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
8036f89
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
0de1bb2
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
3ebe3b9
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
cda30a3
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
1882b8c
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
fffd0c6
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
a522e17
[WIP] Work in progress
IAmNotHanni Jul 17, 2024
e6a656b
[WIP] Work in progress
IAmNotHanni Jul 18, 2024
25fdabf
[WIP] Work in progress
IAmNotHanni Jul 18, 2024
0db8fa3
[WIP] Work in progress
IAmNotHanni Jul 19, 2024
d9f7fc6
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
1eece3e
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
d08b426
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
e9370d3
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
3c9153a
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
0d13451
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
6ec3597
[WIP] Work in progress
IAmNotHanni Jul 20, 2024
12d9f98
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
998af5f
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
29c34c5
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
20d3b1d
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
8b1c844
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
92acbd1
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
2e90e92
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
c83a871
[WIP] Work in progress
IAmNotHanni Jul 21, 2024
8134cc2
[WIP] Work in progress
IAmNotHanni Jul 22, 2024
691d277
[WIP] Work in progress
IAmNotHanni Jul 22, 2024
9392044
[WIP] Work in progress
IAmNotHanni Jul 23, 2024
c9cc646
[WIP] Work in progress
IAmNotHanni Jul 23, 2024
2611084
[WIP] Work in progress
IAmNotHanni Jul 23, 2024
9ef0b51
[WIP] Work in progress
IAmNotHanni Jul 23, 2024
9849f5f
[WIP] Work in progress
IAmNotHanni Jul 24, 2024
5933fb9
[WIP] Work in progress
IAmNotHanni Jul 24, 2024
315473b
›[WIP] Work in progress
IAmNotHanni Aug 1, 2024
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
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ BasedOnStyle: LLVM
AccessModifierOffset: -4
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
BinPackParameters: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
ColumnLimit: 120
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if(INEXOR_BUILD_DOC)
endif()

if(INEXOR_BUILD_EXAMPLE)
add_subdirectory(example)
add_subdirectory(example-app/src)
endif()

if(INEXOR_BUILD_TESTS)
Expand Down
8 changes: 0 additions & 8 deletions documentation/source/development/debugging/cla.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ You can start vulkan-renderer with the following command line arguments:

.. warning:: You should never disable validation layers because they offer extensive error checks for debugging.

.. option:: --no-vk-debug-markers

Disables `Vulkan debug markers <https://www.saschawillems.de/blog/2016/05/28/tutorial-on-using-vulkans-vk_ext_debug_marker-with-renderdoc/>`__ (even if ``--renderdoc`` is specified).

.. option:: --renderdoc

Enables the `RenderDoc <https://renderdoc.org/>`__ debug layer.

.. option:: --vsync

.. warning:: Vsync is currently not implemented. The command line argument will be ignored.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
96 changes: 1 addition & 95 deletions documentation/source/development/debugging/renderdoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,99 +2,5 @@ RenderDoc
=========

- `RenderDoc <https://renderdoc.org/>`__ is a free and open source graphics debugger for Vulkan API (and other APIs) developed by `Baldur Karlsson <https://github.com/baldurk>`__.
- It is a very powerful graphics debugging and visualization tool which makes debugging Vulkan application as easy as possible.
- Inexor has full RenderDoc integration. This includes `internal resource naming using Vulkan debug markers <https://www.saschawillems.de/blog/2016/05/28/tutorial-on-using-vulkans-vk_ext_debug_marker-with-renderdoc/>`__.
- The following tutorial shows how to debug Inexor using RenderDoc.
- It is a very powerful graphics debugging and visualization tool which simplifies debugging Vulkan application a lot.
- You can read up more details in `RenderDoc's documentation <https://renderdoc.org/docs/getting_started/quick_start.html>`__.

RenderDoc Tutorial for Windows
------------------------------

Step 1: Open Inexor in Visual Studio and add a breakpoint before Vulkan initialization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- The best spot would be right after ``main()``:

.. image:: /development/debugging/images/renderdoc/VisualStudioBreakpoint.jpg
:width: 800
:alt: A breakpoint after the main function in Visual Studio debugger.

Step 2: Open RenderDoc.
^^^^^^^^^^^^^^^^^^^^^^^

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_1.jpg
:width: 800
:alt: RenderDoc right after starting it.

Step 3: Start debugging inexor-vulkan-renderer and halt at the breakpoint
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: /development/debugging/images/renderdoc/VisualStudioDebugging.jpg
:width: 800
:alt: Visual Studio interrupts the program because of a breakpoint.

Step 4: "Inject into process" inexor-vulkan-renderer.exe using RenderDoc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_2.jpg
:width: 800
:alt: "Inject into process" in RenderDoc's menu.

Step 5: Search for "inexor-vulkan-renderer.exe" and click "inject"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- You will see a warning Windows Firewall the first time you do this.
- This is because RenderDoc is reading memory from inexor-vulkan-renderer.
- Accept the Windows Firewall warning to allow RenderDoc to read memory.

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_3.jpg
:width: 800
:alt: Injecting into inexor-vulkan-renderer.

Step 6: Continue debugging in Visual Studio
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- RenderDoc should now look like this.

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_4.jpg
:width: 800
:alt: Injecting into inexor-vulkan-renderer.

- Press ``F5`` to continue program execution from the breakpoint.
- RenderDoc is now connected to inexor-vulkan-renderer:

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_5.jpg
:width: 800
:alt: RenderDoc is connected inexor-vulkan-renderer.

- You can see RenderDoc's overlay in inexor-vulkan-renderer.exe:

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_6.jpg
:width: 800
:alt: Taking a RenderDoc snapshot.

Step 7: Debug inexor-vulkan-renderer.exe as usual and press F12 to take RenderDoc snapshots
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- You can take multiple snapshots with either ``PRINT`` or ``F12`` key.

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_7.jpg
:width: 800
:alt: Taking a RenderDoc snapshot.

- You can see the snapshots in RenderDoc right after you took them:

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_8.jpg
:width: 800
:alt: Taking a RenderDoc snapshot.

Step 8: Open a snapshot to analyze the rendering of this frame
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Double click on a snapshot to open it:

.. image:: /development/debugging/images/renderdoc/RenderDoc_step_9.jpg
:width: 800
:alt: Taking a RenderDoc snapshot.

- Have fun inspecting!
2 changes: 1 addition & 1 deletion documentation/source/development/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Optional Software
Improve your build times with ninja.

`RenderDoc <https://renderdoc.org/>`__
Powerful open source graphics debugger. Inexor has full RenderDoc integration.
A very powerful open source graphics debugger.

`Doxygen <http://www.doxygen.nl/download.html>`__
Required for generating the documentation.
Expand Down
47 changes: 47 additions & 0 deletions example-app/include/example_app.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include "../include/example_app_base.hpp"

#include "inexor/vulkan-renderer/rendering/imgui/imgui.hpp"
#include "inexor/vulkan-renderer/rendering/octree/octree_renderer.hpp"

#include <spdlog/spdlog.h>

namespace inexor::example_app {

/// An example application using Inexor vulkan-renderer
class ExampleApp : public ExampleAppBase {
private:
std::unique_ptr<ImGuiRenderer> m_imgui_renderer;
std::unique_ptr<OctreeRenderer> m_octree_renderer;

public:
ExampleApp(int argc, char **argv);
~ExampleApp();

ExampleApp(const ExampleApp &) = delete;
// TODO: Implement me!
ExampleApp(ExampleApp &&) noexcept;

ExampleApp &operator=(const ExampleApp &) = delete;
// TODO: Implement me!
ExampleApp &operator=(ExampleApp &&) noexcept;

void initialize() override;

void load_toml_configuration_file(const std::string &file_name);

void setup_render_graph() override;

void cursor_position_callback(GLFWwindow *window, double x_pos, double y_pos) override;

void keyboard_button_callback(GLFWwindow *window, int key, int scancode, int action, int mods) override;

void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) override;

void mouse_scroll_callback(GLFWwindow *window, double x_offset, double y_offset) override;

void update_imgui() override;
};

} // namespace inexor::example_app
102 changes: 102 additions & 0 deletions example-app/include/example_app_base.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#pragma once

#include "inexor/vulkan-renderer/input/keyboard_mouse_data.hpp"
#include "inexor/vulkan-renderer/rendering/render-graph/render_graph.hpp"
#include "inexor/vulkan-renderer/tools/cla_parser.hpp"
#include "inexor/vulkan-renderer/wrapper/device.hpp"
#include "inexor/vulkan-renderer/wrapper/instance.hpp"
#include "inexor/vulkan-renderer/wrapper/surface.hpp"
#include "inexor/vulkan-renderer/wrapper/swapchain.hpp"
#include "inexor/vulkan-renderer/wrapper/window.hpp"

#include <memory>
#include <string>

namespace inexor::example_app {

// Using declarations
using inexor::vulkan_renderer::input::KeyboardMouseInputData;
using inexor::vulkan_renderer::render_graph::RenderGraph;
using inexor::vulkan_renderer::tools::CommandLineArgumentParser;
using inexor::vulkan_renderer::wrapper::Device;
using inexor::vulkan_renderer::wrapper::Instance;
using inexor::vulkan_renderer::wrapper::Surface;
using inexor::vulkan_renderer::wrapper::Swapchain;
using inexor::vulkan_renderer::wrapper::Window;

/// The command line arguments will be parsed into these options
struct CommandLineOptions {
bool stop_on_validation_error{false};
bool vsync_enabled{false};
};

/// A base class for example apps which use Inexor vulkan-renderer
class ExampleAppBase {
private:
const std::string m_wnd_title = "inexor-vulkan-renderer-example";
std::uint32_t m_wnd_width{1280};
std::uint32_t m_wnd_height{720};
Window::Mode m_wnd_mode{Window::Mode::WINDOWED};
bool m_wnd_resized{false};

std::unique_ptr<Window> m_window;
std::unique_ptr<Instance> m_instance;
std::unique_ptr<Surface> m_surface;
std::unique_ptr<Device> m_device;
std::shared_ptr<Swapchain> m_swapchain;
std::unique_ptr<KeyboardMouseInputData> m_input_data;

void initialize_spdlog();

void recreate_swapchain();

/// Because GLFW is a C-style API, we can't use a pointer to non-static class methods as window or input callback.
/// A good explanation can be found on Stack Overflow:
/// https://stackoverflow.com/questions/7676971/pointing-to-a-function-that-is-a-class-member-glfw-setkeycallback
/// In order to fix this, we can pass a lambda to glfwSetKeyCallback, which calls our callbacks internally. There is
/// another problem: Inside of the lambda, we need to call the member function. In order to do so, we need to have
/// access to the this-pointer. Unfortunately, the this-pointer can't be captured in the lambda capture like
/// [this](){}, because the glfw would not accept the lambda then. To fix this problem, we store the this pointer
/// using glfwSetWindowUserPointer. Inside of these lambdas, we then cast the pointer to Application* again,
/// allowing us to finally use the callbacks.
void setup_window_and_input_callbacks();

protected:
CommandLineOptions m_options;

VKAPI_ATTR VkBool32 VKAPI_CALL
validation_layer_debug_messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT,
VkDebugUtilsMessageTypeFlagsEXT,
const VkDebugUtilsMessengerCallbackDataEXT *,
void *);

std::shared_ptr<RenderGraph> m_rendergraph;

public:
ExampleAppBase(int argc, char **argv);
virtual ~ExampleAppBase();

ExampleAppBase(const ExampleAppBase &) = delete;
// TODO: Implement me!
ExampleAppBase(ExampleAppBase &&) noexcept;

ExampleAppBase &operator=(const ExampleAppBase &) = delete;
// TODO: Implement me!
ExampleAppBase &operator=(ExampleAppBase &&) noexcept;

virtual void evaluate_command_line_arguments(const CommandLineArgumentParser &parser) = 0;
virtual void cursor_position_callback(GLFWwindow *, double, double) = 0;
virtual void keyboard_button_callback(GLFWwindow *, int, int, int, int) = 0;
virtual void mouse_button_callback(GLFWwindow *, int, int, int) = 0;
virtual void mouse_scroll_callback(GLFWwindow *, double, double) = 0;
virtual void initialize() = 0;
virtual void process_mouse_input() = 0;
virtual void process_keyboard_input() = 0;
virtual void render_frame() = 0;
virtual void setup_device() = 0;
virtual void setup_render_graph() = 0;
virtual void shutdown() = 0;
virtual void update_imgui() = 0;
};

} // namespace inexor::example_app
20 changes: 19 additions & 1 deletion example/CMakeLists.txt → example-app/src/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
add_executable(inexor-vulkan-renderer-example main.cpp)
set(INEXOR_EXAMPLE_APP_SOURCE_FILES
example_app_base.cpp
example_app.cpp)

foreach(FILE ${INEXOR_EXAMPLE_APP_SOURCE_FILES})
get_filename_component(PARENT_DIR "${FILE}" PATH)

string(REPLACE "/" "\\" GROUP "${PARENT_DIR}")

if("${FILE}" MATCHES ".*\\.cpp")
set(GROUP "Source Files\\${GROUP}")
elseif("${FILE}" MATCHES ".*\\.hpp")
set(GROUP "Header Files\\${GROUP}")
endif()

source_group("${GROUP}" FILES "${FILE}")
endforeach()

add_executable(inexor-vulkan-renderer-example ${INEXOR_EXAMPLE_APP_SOURCE_FILES})

target_compile_features(inexor-vulkan-renderer-example PRIVATE cxx_std_20)
target_link_libraries(inexor-vulkan-renderer-example PRIVATE inexor-vulkan-renderer)
Expand Down
66 changes: 66 additions & 0 deletions example-app/src/example_app.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "../include/example_app.hpp"

#include <toml.hpp>

#include <memory>

namespace inexor::example_app {

ExampleApp::ExampleApp(int argc, char **argv) : ExampleAppBase(argc, argv) {}

ExampleApp::~ExampleApp() {}

void ExampleApp::initialize() {
//
}

void ExampleApp::setup_render_graph() {
spdlog::trace("Setting up rendergraph");
m_octree_renderer = std::make_unique<OctreeRenderer>(m_rendergraph);
m_imgui_renderer = std::make_unique<ImGuiRenderer>(m_rendergraph);
}

void ExampleApp::update_imgui() {
ImGuiIO &io = ImGui::GetIO();
io.DeltaTime = m_time_passed + 0.00001f;
auto cursor_pos = m_input_data->get_cursor_pos();
io.MousePos = ImVec2(static_cast<float>(cursor_pos[0]), static_cast<float>(cursor_pos[1]));
io.MouseDown[0] = m_input_data->is_mouse_button_pressed(GLFW_MOUSE_BUTTON_LEFT);
io.MouseDown[1] = m_input_data->is_mouse_button_pressed(GLFW_MOUSE_BUTTON_RIGHT);
io.DisplaySize =
ImVec2(static_cast<float>(m_swapchain->extent().width), static_cast<float>(m_swapchain->extent().height));

ImGui::NewFrame();
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
ImGui::SetNextWindowPos(ImVec2(10, 10));
ImGui::SetNextWindowSize(ImVec2(330, 0));
ImGui::Begin("Inexor Vulkan-renderer", 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],
BUILD_GIT);
ImGui::Text("Vulkan API %d.%d.%d", VK_API_VERSION_MAJOR(wrapper::Instance::REQUIRED_VK_API_VERSION),
VK_API_VERSION_MINOR(wrapper::Instance::REQUIRED_VK_API_VERSION),
VK_API_VERSION_PATCH(wrapper::Instance::REQUIRED_VK_API_VERSION));
const auto &cam_pos = m_camera->position();
ImGui::Text("Camera position (%.2f, %.2f, %.2f)", cam_pos.x, cam_pos.y, cam_pos.z);
const auto &cam_rot = m_camera->rotation();
ImGui::Text("Camera rotation: (%.2f, %.2f, %.2f)", cam_rot.x, cam_rot.y, cam_rot.z);
const auto &cam_front = m_camera->front();
ImGui::Text("Camera vector front: (%.2f, %.2f, %.2f)", cam_front.x, cam_front.y, cam_front.z);
const auto &cam_right = m_camera->right();
ImGui::Text("Camera vector right: (%.2f, %.2f, %.2f)", cam_right.x, cam_right.y, cam_right.z);
const auto &cam_up = m_camera->up();
ImGui::Text("Camera vector up (%.2f, %.2f, %.2f)", cam_up.x, cam_up.y, cam_up.z);
ImGui::Text("Yaw: %.2f pitch: %.2f roll: %.2f", m_camera->yaw(), m_camera->pitch(), m_camera->roll());
const auto cam_fov = m_camera->fov();
ImGui::Text("Field of view: %d", static_cast<std::uint32_t>(cam_fov));
ImGui::PushItemWidth(150.0f);
ImGui::PopItemWidth();
ImGui::PopStyleVar();
ImGui::End();
ImGui::EndFrame();
ImGui::Render();
}

} // namespace inexor::example_app
Loading
Loading