Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
RenderPassManager.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_MANAGERS_RENDER_PASS_MANAGER_H_
34#define DVD_MANAGERS_RENDER_PASS_MANAGER_H_
35
37
40
43
44namespace Divide
45{
46 struct NodeTransformData;
47 struct NodeMaterialData;
48 struct PerPassData;
49 struct RTDrawDescriptor;
50
51 class Camera;
52 class SceneGraph;
53 class RenderTarget;
54 class SceneEnvironmentProbePool;
55
56 enum class RenderStage : U8;
57
59 {
60 enum class Flags : U8
61 {
65 COUNT
66 };
67
69 vec3<F32> _minExtents{ 0.f, 0.f, 0.f };
70 // source node is used to determine if the current pass is triggered by a specific node:
71 // e.g. a light node for shadow mapping, a reflector for reflection (or refraction), etc
72 // safe to be set to null
74 const SceneGraphNode* _sourceNode{ nullptr };
76 I64 _singleNodeRenderGUID{ -1 }; //-1 = none;
77 I32 _maxLoD{ -1 }; //-1 = all
78
81
84
89
90
94
96 bool _useMSAA{false};
97 };
98
99 void SetDefaultDrawDescriptor(RenderPassParams& params);
100
102 {
103
104 public:
105 // Just an upper cap for containers. Increasing it will not break anything
106 static constexpr U32 MAX_RENDER_PASSES = 16u;
107
109 {
114 };
115
116 explicit RenderPassManager( Kernel& parent, GFXDevice& context );
118
120 void render( const RenderParams& params );
121
123 RenderPass& setRenderPass( RenderStage renderStage, const vector<RenderStage>& dependencies = {} );
124
125 [[nodiscard]] U32 getLastTotalBinSize( RenderStage renderStage ) const noexcept;
126 [[nodiscard]] I32 drawCallCount( const RenderStage stage ) const noexcept
127 {
128 return _drawCallCount[to_base( stage )];
129 }
130
131 void doCustomPass( Camera* const camera, RenderPassParams params, GFX::CommandBuffer& bufferInOut, GFX::MemoryBarrierCommand& memCmdInOut );
132 void postInit();
133
134 private:
135 void startRenderTasks( const RenderParams& params, TaskPool& pool, Task* parentTask );
136
137 private:
138 friend class RenderPassExecutor;
139 [[nodiscard]] const RenderPass& getPassForStage( RenderStage renderStage ) const noexcept;
140
141 private:
143
144 Handle<ShaderProgram> _oitCompositionShader = INVALID_HANDLE<ShaderProgram>;
145 Handle<ShaderProgram> _oitCompositionShaderMS = INVALID_HANDLE<ShaderProgram>;
146 Handle<ShaderProgram> _gbufferResolveShader = INVALID_HANDLE<ShaderProgram>;
147
149 {
150 Task* _workTask{ nullptr };
151 std::unique_ptr<RenderPass> _pass{ nullptr };
153 };
154
156 std::condition_variable _waitForDependencies;
157
159 std::array<std::atomic_bool, to_base( RenderStage::COUNT )> _renderPassCompleted{};
160
161
162 std::array<RenderPassExecutor_uptr, to_base( RenderStage::COUNT )> _executors;
163 std::array<Time::ProfileTimer*, to_base( RenderStage::COUNT )> _processCommandBufferTimer = create_array<to_base( RenderStage::COUNT ), Time::ProfileTimer*>( nullptr );
164 std::array<I32, to_base( RenderStage::COUNT )> _drawCallCount = create_array<to_base( RenderStage::COUNT ), I32>( 0 );
165
172 };
173
174} // namespace Divide
175
176#endif //DVD_MANAGERS_RENDER_PASS_MANAGER_H_
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Kernel & parent() noexcept
The kernel is the main system that connects all of our various systems: windows, gfx,...
Definition: Kernel.h:81
Handle< ShaderProgram > _gbufferResolveShader
Handle< ShaderProgram > _oitCompositionShader
static constexpr U32 MAX_RENDER_PASSES
Time::ProfileTimer * _processGUITimer
U32 getLastTotalBinSize(RenderStage renderStage) const noexcept
RenderPass & setRenderPass(RenderStage renderStage, const vector< RenderStage > &dependencies={})
Add a new pass that will run once for each of the RenderStages specified.
void startRenderTasks(const RenderParams &params, TaskPool &pool, Task *parentTask)
Time::ProfileTimer * _postFxRenderTimer
Time::ProfileTimer * _buildCommandBufferTimer
Time::ProfileTimer * _flushCommandBufferTimer
const RenderPass & getPassForStage(RenderStage renderStage) const noexcept
Handle< ShaderProgram > _oitCompositionShaderMS
std::array< RenderPassExecutor_uptr, to_base(RenderStage::COUNT)> _executors
std::array< I32, to_base(RenderStage::COUNT)> _drawCallCount
Time::ProfileTimer * _renderPassTimer
std::array< std::atomic_bool, to_base(RenderStage::COUNT)> _renderPassCompleted
void render(const RenderParams &params)
Call every render queue's render function in order.
Time::ProfileTimer * _blitToDisplayTimer
std::array< RenderPassData, to_base(RenderStage::COUNT)> _renderPassData
I32 drawCallCount(const RenderStage stage) const noexcept
std::array< Time::ProfileTimer *, to_base(RenderStage::COUNT)> _processCommandBufferTimer
std::condition_variable _waitForDependencies
void doCustomPass(Camera *const camera, RenderPassParams params, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::mutex Mutex
Definition: SharedMutex.h:40
void SetDefaultDrawDescriptor(RenderPassParams &params)
int32_t I32
uint8_t U8
eastl::vector< Type > vector
Definition: Vector.h:42
constexpr RenderTargetID INVALID_RENDER_TARGET_ID
std::array< RTClearEntry, RT_MAX_ATTACHMENT_COUNT > RTClearDescriptor
U32 RenderTargetID
int64_t I64
uint32_t U32
constexpr auto to_base(const Type value) -> Type
vector< VisibleNode > FeedBackContainer
RTClearDescriptor _clearDescriptorPrePass
const SceneGraphNode * _sourceNode
RTDrawDescriptor _targetDescriptorPrePass
RTDrawDescriptor _targetDescriptorMainPass
FeedBackContainer * _feedBackContainer
FrustumClipPlanes _clippingPlanes
RTClearDescriptor _clearDescriptorMainPass