|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
#include <RenderGraph.hpp>
Public Member Functions | |
| RenderGraph (GfxDevice &device, TargetPool &pool) | |
| RenderGraph (GfxDevice &device) | |
| ~RenderGraph () | |
| RenderGraph (const RenderGraph &)=delete | |
| RenderGraph & | operator= (const RenderGraph &)=delete |
| void | begin (u32 refWidth, u32 refHeight) |
| ResourceId | importTexture (TextureHandle texture, u32 width, u32 height) |
| ResourceId | importTarget (FramebufferHandle target, u32 width, u32 height, bool output=true, TextureHandle readable=TextureHandle::Invalid) |
| The framebuffer the graph must end in (the screen, an editor FBO). | |
| ResourceId | createTarget (const TargetDesc &desc) |
| ResourceId | createExternalTarget (const TargetDesc &desc) |
| A pooled target filled by a producer OUTSIDE any pass callback. | |
| FramebufferHandle | framebufferOf (ResourceId id) const |
| void | addPass (PassDesc pass) |
| void | execute () |
| void | setPassTimer (PassTimer *timer) |
| TextureHandle | textureOf (ResourceId id) const |
| TextureHandle | depthTextureOf (ResourceId id) const |
| TextureHandle | gbufferTextureOf (ResourceId id) const |
| TextureHandle | albedoTextureOf (ResourceId id) const |
| The third attachment of a gbuffer target: the surface's diffuse colour (alpha 1 where one was written). | |
| void | releasePool () |
| TargetPool & | pool () |
| u32 | pooledTargetCount () const |
| u64 | pooledTargetBytes () const |
| u32 | lastExecutedPassCount () const |
Definition at line 240 of file RenderGraph.hpp.
| esengine::rg::RenderGraph::RenderGraph | ( | GfxDevice & | device, |
| TargetPool & | pool ) |
Borrows the caller's pool: a frame's chains share one.
Definition at line 16 of file RenderGraph.cpp.
References pool().
Referenced by RenderGraph(), and operator=().
|
explicit |
Owns a pool of its own — for a lone chain and for tests.
Definition at line 19 of file RenderGraph.cpp.
References esengine::makeUnique().
|
default |
|
delete |
References RenderGraph().
| void esengine::rg::RenderGraph::addPass | ( | PassDesc | pass | ) |
Definition at line 224 of file RenderGraph.cpp.
Referenced by esengine::DynamicGI::declare(), and esengine::VoxelGI::declare().
| TextureHandle esengine::rg::RenderGraph::albedoTextureOf | ( | ResourceId | id | ) | const |
The third attachment of a gbuffer target: the surface's diffuse colour (alpha 1 where one was written).
Definition at line 464 of file RenderGraph.cpp.
References esengine::Invalid, and esengine::rg::kNoTarget.
Referenced by esengine::DynamicGI::declare(), and esengine::VoxelGI::declare().
Starts a new graph. refWidth/refHeight are what scale is a fraction of.
Definition at line 152 of file RenderGraph.cpp.
References esengine::rg::kNoResource.
| ResourceId esengine::rg::RenderGraph::createExternalTarget | ( | const TargetDesc & | desc | ) |
A pooled target filled by a producer OUTSIDE any pass callback.
The scene cannot be written from inside execute(): a frame reaches the host as several calls with the geometry drawn between them, so its target has to exist first. Pooled and recycled at its last read like any transient — the exception is WHEN it is filled, not who owns it.
Definition at line 207 of file RenderGraph.cpp.
References createTarget(), esengine::rg::kNoResource, and esengine::rg::kNoTarget.
| ResourceId esengine::rg::RenderGraph::createTarget | ( | const TargetDesc & | desc | ) |
A target the graph allocates from the pool and recycles after its last read.
Definition at line 198 of file RenderGraph.cpp.
Referenced by createExternalTarget(), esengine::DynamicGI::declare(), and esengine::VoxelGI::declare().
| TextureHandle esengine::rg::RenderGraph::depthTextureOf | ( | ResourceId | id | ) | const |
Its depth attachment, for a resource declared with one. Invalid for an import (the graph did not make it) and for a target without depth.
Definition at line 450 of file RenderGraph.cpp.
References esengine::Invalid, and esengine::rg::kNoTarget.
Referenced by esengine::DynamicGI::declare(), and esengine::VoxelGI::declare().
| void esengine::rg::RenderGraph::execute | ( | ) |
Culls, assigns physical targets, and runs what survives.
Definition at line 290 of file RenderGraph.cpp.
References esengine::rg::PassDesc::asyncCompute, esengine::rg::PassDesc::clear, esengine::RenderPassDesc::clearColor, esengine::rg::PassDesc::clearColor, esengine::RenderPassDesc::clearColorValue, esengine::RenderPassDesc::clearDepth, esengine::rg::PassDesc::clearDepth, esengine::RenderPassDesc::clearH, esengine::rg::PassDesc::clearViewportOnly, esengine::RenderPassDesc::clearW, esengine::RenderPassDesc::clearX, esengine::RenderPassDesc::clearY, esengine::rg::PassDesc::compute, esengine::rg::PassDesc::computePriority, esengine::ctx(), esengine::Default, esengine::rg::PassDesc::dependencies, esengine::RenderPassDesc::discardDepth, esengine::rg::PassDesc::discardDepth, esengine::RenderPassDesc::discardMultisampled, ES_LOG_ERROR, esengine::rg::PassDesc::execute, esengine::Invalid, esengine::kNoAsyncComputeFence, esengine::rg::kNoTarget, esengine::rg::PassDesc::name, esengine::rg::PassDesc::reads, esengine::RenderPassDesc::target, textureOf(), esengine::rg::PassDesc::viewportH, esengine::rg::PassDesc::viewportW, esengine::rg::PassDesc::viewportX, esengine::rg::PassDesc::viewportY, and esengine::rg::PassDesc::write.
| FramebufferHandle esengine::rg::RenderGraph::framebufferOf | ( | ResourceId | id | ) | const |
The framebuffer behind a resource, for an external target to be drawn into.
Definition at line 216 of file RenderGraph.cpp.
References esengine::Default, and esengine::rg::kNoTarget.
| TextureHandle esengine::rg::RenderGraph::gbufferTextureOf | ( | ResourceId | id | ) | const |
Its second colour attachment, for a resource declared with one. Invalid otherwise.
Definition at line 457 of file RenderGraph.cpp.
References esengine::Invalid, and esengine::rg::kNoTarget.
Referenced by esengine::DynamicGI::declare(), and esengine::VoxelGI::declare().
| ResourceId esengine::rg::RenderGraph::importTarget | ( | FramebufferHandle | target, |
| u32 | width, | ||
| u32 | height, | ||
| bool | output = true, | ||
| TextureHandle | readable = TextureHandle::Invalid ) |
The framebuffer the graph must end in (the screen, an editor FBO).
Also what culling works back from: a pass no path reaches from here did not contribute to the image and is dropped. Set output false for a persistent intermediate capture: importing it must not move the final output away from the scene or its post stack. readable is the colour texture behind target, so a later pass can read what this one wrote — a history buffer is imported to be written and then sampled, by the next pass and by the next frame.
Definition at line 184 of file RenderGraph.cpp.
| ResourceId esengine::rg::RenderGraph::importTexture | ( | TextureHandle | texture, |
| u32 | width, | ||
| u32 | height ) |
A texture the graph reads but does not own — the scene capture.
Definition at line 174 of file RenderGraph.cpp.
|
inline |
Passes the last execute() ran, after culling. Diagnostics and tests.
Definition at line 324 of file RenderGraph.hpp.
|
delete |
References RenderGraph(), and esengine::Invalid.
|
inline |
The targets this graph draws from — shared with the frame's other chains when one was given, its own otherwise.
Definition at line 314 of file RenderGraph.hpp.
Referenced by RenderGraph().
|
inline |
What those targets cost in GPU memory, so the number a budget reads is bytes rather than a count of things with no common size.
Definition at line 321 of file RenderGraph.hpp.
|
inline |
How many physical targets the pool is holding. Diagnostics and tests.
Definition at line 317 of file RenderGraph.hpp.
| void esengine::rg::RenderGraph::releasePool | ( | ) |
Drops every pooled target. For shutdown and for device loss, after which the handles the pool holds name nothing.
Definition at line 471 of file RenderGraph.cpp.
References esengine::Invalid, and esengine::rg::kNoTarget.
|
inline |
Times each pass of the next execute()s into timer; null stops. Borrowed.
Definition at line 293 of file RenderGraph.hpp.
| TextureHandle esengine::rg::RenderGraph::textureOf | ( | ResourceId | id | ) | const |
The texture behind a resource — valid for imports, and for a transient only while it holds a physical target.
Definition at line 445 of file RenderGraph.cpp.
References esengine::Invalid.
Referenced by execute().