Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
RenderGraphPass.hpp
1#pragma once
2
3#include <vector>
4#include <functional>
5
6#include <Common/HashedString.hpp>
7#include "GpuQueue.hpp"
8#include "AttachmentInfo.hpp"
9#include "BufferInfo.hpp"
10
11namespace Grindstone::Renderer {
12 class RenderGraphPass {
13 public:
14 RenderGraphPass() = default;
15 RenderGraphPass(HashedString name, GpuQueue queue) : name(name), queue(queue) {}
16 RenderGraphPass(const RenderGraphPass& other) = default;
17 RenderGraphPass(RenderGraphPass&& other) noexcept = default;
18 RenderGraphPass& operator=(const RenderGraphPass& other) = default;
19 RenderGraphPass& operator=(RenderGraphPass&& other) noexcept = default;
20
21 void AddInputImage(HashedString name, AttachmentInfo attachmentInfo);
22 void AddInputOutputImage(HashedString inName, HashedString outName, AttachmentInfo attachmentInfo);
23 void AddOutputImage(HashedString name, AttachmentInfo);
24
25 void AddInputBuffer(HashedString name, BufferInfo bufferInfo);
26 void AddInputOutputBuffer(HashedString inName, HashedString outName, BufferInfo bufferInfo);
27 void AddOutputBuffer(HashedString name, BufferInfo bufferInfo);
28
29 void RenderEnabled();
30 void RenderDisabled();
31
32 // Set up the pass for rendering in the future
33 RenderGraphPass& SetOnSetup(std::function<void* ()> fn);
34
35 // Set up the pass for rendering in the future
36 RenderGraphPass& SetOnDestroy(std::function<void(void*)> fn);
37
38 // The real rendering of a pass.
39 RenderGraphPass& SetOnRenderEnabled(std::function<void(void*)> fn);
40
41 // For when rendering a system is disabled but resources still need to be cleared, etc.
42 RenderGraphPass& SetOnRenderDisabledCallback(std::function<void(void*)> fn);
43 HashedString GetName() const;
44
45 struct ContextData {
46 // This data will be kept as long as this pass is in use. When the pass is removed from all framegraphs, this data will be deleted (uses dynamic allocator).
47 void* permanentData = nullptr;
48
49 // This pass will create an instance of this data for each camera (uses dynamic allocator).
50 void* perCameraContext = nullptr;
51
52 // This pass will create an allocate this data every frame and dispose of it at the end of the frame (uses frame/stack allocator).
53 void* perFrameContext = nullptr;
54 };
55
56 protected:
57 // What type of oass is this? Used for scheduling.
58 GpuQueue queue;
59
60 // The name of this pass (mostly used for debugging).
61 HashedString name;
62
63 // The names of all the resources required by this pass.
64 std::vector<HashedString> dependencyResourceNames;
65
66 // The names of all the resources emitted by this pass.
67 std::vector<HashedString> emittedResourceNames;
68
69 // Set up the pass for rendering in the future
70 std::function<void* ()> OnSetup;
71
72 // Set up the pass for rendering in the future
73 std::function<void(void*)> OnDestroy;
74
75 // The real rendering of a pass.
76 std::function<void(void*)> OnRenderEnabled;
77
78 // For when rendering a system is disabled but resources still need to be cleared, etc.
79 std::function<void(void*)> OnRenderDisabled;
80 };
81}
Definition HashedString.hpp:9
Definition AttachmentInfo.hpp:17
Definition BufferInfo.hpp:11