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

Render Graph improvements #383

Merged
merged 19 commits into from
Jul 27, 2021
Merged

Render Graph improvements #383

merged 19 commits into from
Jul 27, 2021

Conversation

yeetari
Copy link
Member

@yeetari yeetari commented May 3, 2021

  • Ensure buffer and texture usage can't be in an invalid state
  • Expand BufferResource::upload_data() to allow for dynamically changing data at runtime
  • Changeable octree at runtime :)
  • Cleanup physical resource/stage system in render graph (use shared_ptr and unique_ptr)
  • Cleanup render graph docs
  • Switch to 32-bit indices
  • ImGUI with render graph (mostly)

This PR adds support to the render graph for dynamic buffers. This allows for changeable octree geometry at runtime, which a small demo has been created for. ImGUI support has also been rewritten to work with the render graph. It now fully uses the render graph for the two buffers and stage, however it still relies on textures being done externally. This brings around a 33% FPS improvement - and that's with the bigger octree. With the original octree, I get an FPS improvement of about 73%.

In terms of the internals of the render graph, the two std::unordered_maps used to map resources&stages to physical resources&stages has been removed. A RenderResource now holds a shared_ptr<PhysicalResource> and a RenderStage now holds a unique_ptr<PhysicalStage>. The reason a RenderResource holds a shared pointer is because, in the future, multiple render resources will be able to point to the same physical resource. This makes accessing the physical resource much easier, and removes the need for the ugly create functions.

Also, instead of storing just a std::vector<std::unique_ptr<RenderResource>>, each different type of resource (BufferResource, TextureResource, etc.) now has its own vector. This makes it faster to iterate each type of resource.

@IAmNotHanni IAmNotHanni added the cat:enhancement enhancement/requested feature/update of existing features label May 3, 2021
@IAmNotHanni IAmNotHanni added this to In progress in Rendergraph via automation May 3, 2021
@yeetari yeetari force-pushed the yeetari/render-graph branch 5 times, most recently from a2b30d3 to b6af393 Compare May 9, 2021 21:28
@yeetari yeetari force-pushed the yeetari/render-graph branch 2 times, most recently from 0c16b43 to 01a1dbe Compare May 15, 2021 13:04
@IAmNotHanni
Copy link
Member

Btw I can't seei ImGui. Not on Windows and neither on Ubuntu. I will debug this using RenderDoc.

@IAmNotHanni
Copy link
Member

IAmNotHanni commented May 16, 2021

It works now on Ubuntu 20.04 LTS!

image

@yeetari yeetari force-pushed the yeetari/render-graph branch 4 times, most recently from 1465098 to bdf97ca Compare May 16, 2021 12:02
@yeetari yeetari marked this pull request as ready for review May 16, 2021 12:18
@yeetari yeetari requested review from IAmNotHanni, IceflowRE and movabo and removed request for IAmNotHanni and IceflowRE May 16, 2021 12:18
Copy link
Collaborator

@movabo movabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021-05-17 00:48:57.078338 debug 11393 [vulkan-renderer] Running Application.
2021-05-17 00:48:57.079727 debug 11393 [vulkan-renderer] FPS: 0, window size: 800 x 800.
2021-05-17 00:48:57.083832 error 11393 [vulkan-renderer]  [ VUID-vkResetCommandPool-commandPool-00040 ] Object: 0x55f30a994950 (Type = 6) | Attempt to reset command pool with VkCommandBuffer 0x55f30a994950[] which is in use. The Vulkan spec states: All VkCommandBuffer objects allocated from commandPool must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandPool-commandPool-00040)
2021-05-17 00:48:57.083853 critical 11393 [vulkan-renderer] Command line argument --stop-on-validation-message is enabled.
2021-05-17 00:48:57.083857 critical 11393 [vulkan-renderer] Application will cause a break point now!

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

caused by

// Check if --stop-on-validation-message is enabled.
if (user_data != nullptr) {
// This feature stops command lines from overflooding with messages in case many validation
// layer messages are reported in a short amount of time.
spdlog::critical("Command line argument --stop-on-validation-message is enabled.");
spdlog::critical("Application will cause a break point now!");
// Wait for spdlog to shut down before aborting.
spdlog::shutdown();
std::abort();
}

even though no argument was passed. Could not test because of this, also I don't understand at most points what the code should do (on a conceptual level), thus I don't feel fit to give a (full) review, but still gladly test it and read through the code.

Copy link
Member

@IAmNotHanni IAmNotHanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work!

include/inexor/vulkan-renderer/render_graph.hpp Outdated Show resolved Hide resolved
include/inexor/vulkan-renderer/render_graph.hpp Outdated Show resolved Hide resolved
src/vulkan-renderer/application.cpp Show resolved Hide resolved
src/vulkan-renderer/application.cpp Outdated Show resolved Hide resolved
src/vulkan-renderer/imgui.cpp Outdated Show resolved Hide resolved
src/vulkan-renderer/imgui.cpp Show resolved Hide resolved
src/vulkan-renderer/imgui.cpp Show resolved Hide resolved
src/vulkan-renderer/render_graph.cpp Outdated Show resolved Hide resolved
src/vulkan-renderer/render_graph.cpp Outdated Show resolved Hide resolved
src/vulkan-renderer/application.cpp Outdated Show resolved Hide resolved
src/vulkan-renderer/world/cube.cpp Outdated Show resolved Hide resolved
include/inexor/vulkan-renderer/world/cube.hpp Outdated Show resolved Hide resolved
@@ -42,7 +42,7 @@ class Application : public VulkanRenderer {
void load_toml_configuration_file(const std::string &file_name);
void load_textures();
void load_shaders();
void load_octree_geometry();
void load_octree_geometry(bool initial);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void load_octree_geometry(bool initial);
/// @param initialize Initialize worlds with a fixed seed.
void load_octree_geometry(bool initialize);

@@ -183,24 +184,15 @@ void Application::load_shaders() {
spdlog::debug("Loading shaders finished.");
}

void Application::load_octree_geometry() {
void Application::load_octree_geometry(bool initial) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename variable.

IceflowRE and others added 16 commits July 26, 2021 20:38
Since we're storing them now anyway, this makes it look a lot ncier.
* Inline alloc_command_buffers function
* Remove maps used to assign a render stage/resource to a physical
  stage/resource. We now store a `unique_ptr<PhysicalStage>` in
  `RenderStage` and a `shared_ptr<PhysicalResource>` in
  `RenderResource`. The reason the latter is shared is because,
  in the future, multiple render resources will point to the same
  physical resource.
* Store separate vectors of BufferResource and TextureResourceo to
  allow for faster iteration
So we can see the beautiful octree :)
@yeetari yeetari merged commit e288b42 into master Jul 27, 2021
Rendergraph automation moved this from In progress to Done Jul 27, 2021
@yeetari yeetari deleted the yeetari/render-graph branch July 27, 2021 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:enhancement enhancement/requested feature/update of existing features
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants