41 , _renderPassTimer(&Time::ADD_TIMER(
"Render Passes"))
42 , _buildCommandBufferTimer(&Time::ADD_TIMER(
"Build Command Buffers"))
43 , _processGUITimer(&Time::ADD_TIMER(
"Process GUI"))
44 , _flushCommandBufferTimer(&Time::ADD_TIMER(
"Flush Command Buffers"))
45 , _postFxRenderTimer(&Time::ADD_TIMER(
"PostFX Timer"))
46 , _blitToDisplayTimer(&Time::ADD_TIMER(
"Flush To Display Timer"))
74 shaderDescriptor.
_modules.push_back(vertModule);
75 shaderDescriptor.
_modules.push_back(fragModule);
82 shaderDescriptor.
_modules.back()._defines.emplace_back(
"USE_MSAA_TARGET");
96 shaderDescriptor.
_modules.push_back(vertModule);
97 shaderDescriptor.
_modules.push_back(fragModule);
104 if (executor !=
nullptr)
128 [&, i](
const Task& parentTask) {
141 if (!passData.
_pass->dependencies().empty())
148 if ( !_renderPassCompleted[to_base( dep )] )
185 const Camera* cam = Attorney::ProjectManagerRenderPass::playerCamera(projectManager);
187 LightPool& activeLightPool = Attorney::ProjectManagerRenderPass::lightPool(projectManager);
206 PROFILE_SCOPE(
"RenderPassManager::update sky light", Profiler::Category::Scene );
208 SceneEnvironmentProbePool::UpdateSkyLight(gfx, *skyLightRenderBuffer, memCmd );
212 context.
gui().
preDraw( gfx, targetViewport, *postFXCmdBuffer, memCmd );
215 beginRenderPassCmd.
_name =
"Flush Display";
216 beginRenderPassCmd._clearDescriptor[
to_base( RTColourAttachmentSlot::SLOT_0 )] = { DefaultColours::BLACK,
true };
217 beginRenderPassCmd._descriptor._drawMask[
to_base( RTColourAttachmentSlot::SLOT_0 )] =
true;
218 beginRenderPassCmd._target = RenderTargetNames::BACK_BUFFER;
219 GFX::EnqueueCommand(*postFXCmdBuffer, beginRenderPassCmd);
222 const auto& texData =
Get(screenAtt->texture())->getView();
224 gfx.
drawTextureInViewport(texData, screenAtt->_descriptor._sampler, targetViewport,
false,
false,
false, *postFXCmdBuffer );
228 Attorney::ProjectManagerRenderPass::drawCustomUI(projectManager, targetViewport, *postFXCmdBuffer, memCmd);
229 if constexpr(Config::Build::ENABLE_EDITOR)
233 context.
gui().
draw(gfx, targetViewport, *postFXCmdBuffer, memCmd);
238 GFX::EnqueueCommand<GFX::EndRenderPassCommand>( *postFXCmdBuffer );
241 Attorney::ProjectManagerRenderPass::postRender( projectManager, *postFXCmdBuffer, memCmd );
242 GFX::EnqueueCommand( *postFXCmdBuffer, memCmd );
247 startRenderTasks(params, pool, renderTask);
248 Start( *renderTask, pool );
252 PROFILE_SCOPE(
"RenderPassManager::FlushCommandBuffers", Profiler::Category::Scene );
258 PROFILE_SCOPE(
"PostFX: CommandBuffer build", Profiler::Category::Scene );
261 _context.getRenderer().postFX().apply( params.
_playerPass, cam->
snapshot(), *postFXCmdBuffer );
263 postFXCmdBuffer->
batch();
268 if constexpr ( Config::Build::ENABLE_EDITOR )
270 Attorney::EditorRenderPassExecutor::getCommandBuffer(context.
editor(), *postRenderBuffer, flushMemCmd);
272 _parent.platformContext().idle();
276 if ( !GFX::Merge( &flushMemCmd, &passData._memCmd ) )
283 PROFILE_SCOPE(
"PostFX: CommandBuffer flush", Profiler::Category::Scene );
284 _context.flushCommandBuffer(
MOV(postFXCmdBufferHandle) );
288 GFX::EnqueueCommand( *postRenderBuffer, flushMemCmd );
295 PROFILE_SCOPE(
"Executor post-render", Profiler::Category::Scene );
297 for (
auto& executor : _executors)
299 if ( executor !=
nullptr )
302 [&executor](
const Task&)
304 executor->postRender();
308 Start( *sortTask, pool );
309 Wait( *sortTask, pool );
319 if (_executors[
to_base(renderStage)] ==
nullptr)
321 _executors[
to_base(renderStage)] = std::make_unique<RenderPassExecutor>(*
this, _context, renderStage);
322 _renderPassData[
to_base(renderStage)]._pass = std::make_unique<RenderPass>( *
this, _context, renderStage, dependencies );
325 item = _renderPassData[
to_base( renderStage )]._pass.get();
326 item->dependencies( dependencies );
330U32 RenderPassManager::getLastTotalBinSize(
const RenderStage renderStage)
const noexcept
337 return *_renderPassData[
to_base(renderStage)]._pass;
342 const PlayerIndex playerPass = _parent.projectManager()->playerPass();
343 _executors[
to_base(params.
_stagePass.
_stage)]->doCustomPass(playerPass, camera, params, bufferInOut, memCmdInOut);
#define WAIT_FOR_CONDITION(...)
#define PROFILE_SCOPE_AUTO(CATEGORY)
#define PROFILE_TAG(NAME,...)
#define PROFILE_SCOPE(NAME, CATEGORY)
const CameraSnapshot & snapshot() const noexcept
Returns the internal camera snapshot data (eye, orientation, etc)
void drawScreenOverlay(const Camera *camera, const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) const
Render any editor specific element that needs to be part of the scene (e.g. Control Gizmo)
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
void drawTextureInViewport(const ImageView &texture, SamplerDescriptor sampler, const Rect< I32 > &viewport, bool convertToSrgb, bool drawToDepthOnly, bool drawBlend, GFX::CommandBuffer &bufferInOut)
GFXRTPool & renderTargetPool() noexcept
void renderDebugUI(const Rect< I32 > &targetViewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void updateSceneDescriptorSet(GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut) const
void flushCommandBuffer(Handle< GFX::CommandBuffer > &&commandBuffer)
RenderTarget * getRenderTarget(const RenderTargetID target) const
void preDraw(GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Render all elements that need their own internal render targets (e.g. CEGUI)
void draw(GFXDevice &context, const Rect< I32 > &viewport, GFX::CommandBuffer &bufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
Go through all of the registered scene gui elements and gather all of the render commands.
The kernel is the main system that connects all of our various systems: windows, gfx,...
FORCE_INLINE PlatformContext & platformContext() noexcept
void preRenderAllPasses(const Camera *playerCamera)
Editor & editor() noexcept
TaskPool & taskPool(const TaskPoolType type) noexcept
Configuration & config() noexcept
SceneEnvironmentProbePool * getEnvProbes() const noexcept
U32 getLastTotalBinSize() const noexcept
Handle< ShaderProgram > _gbufferResolveShader
Handle< ShaderProgram > _oitCompositionShader
Time::ProfileTimer * _processGUITimer
RenderPassManager(Kernel &parent, GFXDevice &context)
void startRenderTasks(const RenderParams ¶ms, TaskPool &pool, Task *parentTask)
Time::ProfileTimer * _buildCommandBufferTimer
Mutex _waitForDependenciesLock
Time::ProfileTimer * _flushCommandBufferTimer
Handle< ShaderProgram > _oitCompositionShaderMS
std::array< RenderPassExecutor_uptr, to_base(RenderStage::COUNT)> _executors
Time::ProfileTimer * _renderPassTimer
std::array< std::atomic_bool, to_base(RenderStage::COUNT)> _renderPassCompleted
Time::ProfileTimer * _blitToDisplayTimer
std::array< RenderPassData, to_base(RenderStage::COUNT)> _renderPassData
std::array< Time::ProfileTimer *, to_base(RenderStage::COUNT)> _processCommandBufferTimer
std::condition_variable _waitForDependencies
RTAttachment * getAttachment(RTAttachmentType type, RTColourAttachmentSlot slot=RTColourAttachmentSlot::SLOT_0) const
void addChildTimer(ProfileTimer &child)
bool hasChildTimer(const ProfileTimer &child) const
FColour4 WHITE
Random stuff added for convenience.
CommandBuffer * Get(Handle< CommandBuffer > handle)
Handle< CommandBuffer > AllocateCommandBuffer(const char *name, const size_t reservedCmdCount)
constexpr Optick::Category::Type Scene
ProfileTimer & ADD_TIMER(const char *timerName)
const char * RenderStageToString(const RenderStage stage) noexcept
Str StringFormat(const char *fmt, Args &&...args)
Handle console commands that start with a forward slash.
std::lock_guard< mutex > LockGuard
FORCE_INLINE void DestroyResource(Handle< T > &handle, const bool immediate=false)
static constexpr U32 RT_DEPTH_ATTACHMENT_IDX
void Wait(const Task &task, TaskPool &pool)
void SetDefaultDrawDescriptor(RenderPassParams ¶ms)
Task * CreateTask(Predicate &&threadedFunction, bool allowedInIdle=true)
bool Finished(const Task &task) noexcept
std::unique_lock< mutex > UniqueLock
eastl::vector< Type > vector
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
void Start(Task &task, TaskPool &pool, TaskPriority priority=TaskPriority::DONT_CARE, const DELEGATE< void > &onCompletionFunction={})
RTClearEntry DEFAULT_CLEAR_ENTRY
FORCE_INLINE T * Get(const Handle< T > handle)
constexpr auto to_base(const Type value) -> Type
mat4< F32 > _projectionMatrix
struct Divide::Configuration::Rendering rendering
vector< ShaderModuleDescriptor > _modules
SceneRenderState * _sceneRenderState
Time::ProfileTimer * _parentTimer
Rect< I32 > _targetViewport
std::unique_ptr< RenderPass > _pass
GFX::MemoryBarrierCommand _memCmd
RTClearDescriptor _clearDescriptorPrePass
RTDrawDescriptor _targetDescriptorMainPass
RenderStagePass _stagePass
RTClearDescriptor _clearDescriptorMainPass
PropertyDescriptor< T > _propertyDescriptor