|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
#include <RenderContext.hpp>
Public Member Functions | |
| RenderContext (GfxDevice &device) | |
| RenderContext ()=delete | |
| ~RenderContext () | |
| RenderContext (const RenderContext &)=delete | |
| RenderContext & | operator= (const RenderContext &)=delete |
| void | init () |
| Initializes rendering resources. | |
| void | shutdown () |
| Releases all rendering resources. | |
| void | restoreBuiltinContent () |
| Builds again what this context made from code alone and the device lost: call once the device is back. | |
| bool | isInitialized () const |
| Checks if the context is initialized. | |
| u64 | programEpoch () const |
| Which generation of renderer PROGRAM readiness is current. | |
| void | advanceProgramEpoch () |
| Declares that programs which WERE ready have gone cold. | |
| glm::mat4 & | viewProjection () |
| Gets the current view-projection matrix. | |
| const glm::mat4 & | viewProjection () const |
| Gets the current view-projection matrix (const). | |
| u32 | getWhiteTextureId () const |
| Gets the white texture handle's raw value (for untextured quads). | |
| TextureHandle | getWhiteTexture () const |
| void | updateCameraConstants (const glm::mat4 &viewProjection) |
| Point the frame at what a CAMERA sees. | |
| void | updateCameraConstants (const glm::mat4 &viewProjection, const glm::vec2 &jitterNdc) |
The same, with the picture shifted by jitterNdc (a fraction of the clip square) — what temporal anti-aliasing samples a different sub-pixel position with each frame. | |
| void | updateFrameConstants (const glm::mat4 &viewProjection) |
| Point the frame at a pass whose projection already suits the device. | |
| void | useFrameConstants (BufferHandle ubo, const glm::mat4 &viewProjection) |
Frame constants for viewProjection in a buffer the CALLER owns, bound. | |
| void | prepareFrameConstants (BufferHandle ubo, const glm::mat4 &viewProjection) |
| Stage a light view before the render passes and switch to it without a mid-pass upload. | |
| void | bindFrameConstants (BufferHandle ubo) |
| BufferHandle | frameUbo () const |
| The buffer the camera's FrameConstants live in, for a compute pass that reads them (it is bound at group 0). | |
| void | setFrameTime (f32 elapsedSec, u32 viewportW, u32 viewportH) |
| Uploads the frame clock + canvas size into the injected TimeConstants UBO. | |
| void | setViewExposure (f32 ev) |
| The editor view's exposure, in stops, carried to the output blit in u_time.z. VIEW state: zero (the default, and every packaged build) is exp2(0) = 1, an exact no-op. | |
| void | setQualityConstants (const glm::vec4 &values) |
| f32 | viewExposure () const |
| QualityValues & | qualityValues () |
| const QualityValues & | qualityValues () const |
| MaterialStore & | materials () |
| The engine-side material registry (handle -> resolved render state). | |
| const MaterialStore & | materials () const |
| LightStore & | lights () |
| The engine-side per-frame 2D light registry (binding 2 LightConstants UBO). | |
| const LightStore & | lights () const |
| ProbeStore & | probes () |
| The frame's probe volumes. Gathered beside the lights, because it answers the same question at the points a light cannot be asked. | |
| const ProbeStore & | probes () const |
| ReflectionStore & | reflections () |
| The frame's reflection probes — the same question about the half of the environment a surface MIRRORS rather than scatters. | |
| const ReflectionStore & | reflections () const |
| PerDrawBlockSet | perDrawBlocks () |
| The blocks the draw loop rewrites before each draw. | |
| void | beginPerDrawBlocks () |
| Hand every one of them back at the top of a frame. | |
Static Public Member Functions | |
| static u32 | frameConstantsSize () |
| Bytes a buffer passed to useFrameConstants must hold. | |
Definition at line 63 of file RenderContext.hpp.
|
explicit |
Definition at line 33 of file RenderContext.cpp.
Referenced by RenderContext(), and operator=().
|
delete |
| esengine::RenderContext::~RenderContext | ( | ) |
Definition at line 37 of file RenderContext.cpp.
References shutdown().
|
delete |
References RenderContext().
|
inline |
Declares that programs which WERE ready have gone cold.
Renderer-wide, not stock-only: ANY operation that can make a previously-ready program requirement cold owes this call — a cache emptied after a device rebuild, a pipeline flush, a shader hot reload. Skipping it leaves a stamp vouching for nothing.
Definition at line 120 of file RenderContext.hpp.
|
inline |
Hand every one of them back at the top of a frame.
Definition at line 273 of file RenderContext.hpp.
| void esengine::RenderContext::bindFrameConstants | ( | BufferHandle | ubo | ) |
Definition at line 242 of file RenderContext.cpp.
References esengine::DRAW_PARAMS_BINDING, and esengine::FRAME_CONSTANTS_BINDING.
Referenced by useFrameConstants().
|
static |
Bytes a buffer passed to useFrameConstants must hold.
Definition at line 225 of file RenderContext.cpp.
|
inline |
The buffer the camera's FrameConstants live in, for a compute pass that reads them (it is bound at group 0).
Definition at line 189 of file RenderContext.hpp.
|
inline |
The white 1x1 as a typed handle — what a lost texture is parked on until its content is re-uploaded.
Definition at line 149 of file RenderContext.hpp.
|
inline |
Gets the white texture handle's raw value (for untextured quads).
Definition at line 145 of file RenderContext.hpp.
| void esengine::RenderContext::init | ( | ) |
Initializes rendering resources.
Creates the quad VAO, shaders, and default textures.
Definition at line 43 of file RenderContext.cpp.
References ES_LOG_WARN.
|
inline |
Checks if the context is initialized.
Definition at line 97 of file RenderContext.hpp.
|
inline |
The engine-side per-frame 2D light registry (binding 2 LightConstants UBO).
Filled by the render collect path from the scene's Light components and uploaded once per frame; Lit material shaders read it. Lives here next to materials() so the render path reaches one store / one UBO without a global lookup.
Definition at line 224 of file RenderContext.hpp.
|
inline |
Definition at line 225 of file RenderContext.hpp.
|
inline |
The engine-side material registry (handle -> resolved render state).
Written by the SDK material binding (defineMaterial) and read by the render collect path to resolve a component's material handle into shader + pipeline state. Lives here so both sides reach it without a global lookup.
Definition at line 215 of file RenderContext.hpp.
|
inline |
Definition at line 216 of file RenderContext.hpp.
|
delete |
References RenderContext().
|
inline |
The blocks the draw loop rewrites before each draw.
Definition at line 269 of file RenderContext.hpp.
| void esengine::RenderContext::prepareFrameConstants | ( | BufferHandle | ubo, |
| const glm::mat4 & | viewProjection ) |
Stage a light view before the render passes and switch to it without a mid-pass upload.
Definition at line 229 of file RenderContext.cpp.
References esengine::cameraFromViewProjection(), esengine::Invalid, esengine::renderOrigin(), and viewProjection().
Referenced by useFrameConstants().
|
inline |
The frame's probe volumes. Gathered beside the lights, because it answers the same question at the points a light cannot be asked.
Definition at line 229 of file RenderContext.hpp.
|
inline |
Definition at line 230 of file RenderContext.hpp.
|
inline |
Which generation of renderer PROGRAM readiness is current.
A record stamped with an older epoch names programs that may no longer exist, so it is re-derived rather than trusted. Distinct from the device generation, which says which device the GPU work happened on rather than whether readiness survived.
Definition at line 110 of file RenderContext.hpp.
|
inline |
Definition at line 206 of file RenderContext.hpp.
|
inline |
Definition at line 207 of file RenderContext.hpp.
|
inline |
The frame's reflection probes — the same question about the half of the environment a surface MIRRORS rather than scatters.
Definition at line 234 of file RenderContext.hpp.
|
inline |
Definition at line 235 of file RenderContext.hpp.
| void esengine::RenderContext::restoreBuiltinContent | ( | ) |
Builds again what this context made from code alone and the device lost: call once the device is back.
Definition at line 130 of file RenderContext.cpp.
References esengine::buildRippleNormals(), esengine::Invalid, esengine::RIPPLE_NORMALS_SIZE, and esengine::GfxOwedContent::Texture.
Uploads the frame clock + canvas size into the injected TimeConstants UBO.
Definition at line 269 of file RenderContext.cpp.
|
inline |
Definition at line 203 of file RenderContext.hpp.
|
inline |
The editor view's exposure, in stops, carried to the output blit in u_time.z. VIEW state: zero (the default, and every packaged build) is exp2(0) = 1, an exact no-op.
Definition at line 202 of file RenderContext.hpp.
| void esengine::RenderContext::shutdown | ( | ) |
Releases all rendering resources.
Definition at line 60 of file RenderContext.cpp.
References ES_LOG_INFO, and esengine::Invalid.
Referenced by ~RenderContext().
| void esengine::RenderContext::updateCameraConstants | ( | const glm::mat4 & | viewProjection | ) |
Point the frame at what a CAMERA sees.
Keeps the projection in the engine's convention and uploads it in the device's. This is the one place that conversion happens.
Definition at line 205 of file RenderContext.cpp.
References esengine::toClipDepthRange(), and viewProjection().
| void esengine::RenderContext::updateCameraConstants | ( | const glm::mat4 & | viewProjection, |
| const glm::vec2 & | jitterNdc ) |
The same, with the picture shifted by jitterNdc (a fraction of the clip square) — what temporal anti-aliasing samples a different sub-pixel position with each frame.
Only the UPLOADED matrix moves. The engine's own copy, which culling and the camera position are read from, is the unshifted one.
Definition at line 210 of file RenderContext.cpp.
References esengine::toClipDepthRange(), and viewProjection().
| void esengine::RenderContext::updateFrameConstants | ( | const glm::mat4 & | viewProjection | ) |
Point the frame at a pass whose projection already suits the device.
The shadow cascades: theirs spans exactly the occluders it draws, so it lands inside either clip volume untouched, and converting it would move the depths it writes away from the copy of the matrix the receiving shader compares against.
Definition at line 221 of file RenderContext.cpp.
References viewProjection().
| void esengine::RenderContext::useFrameConstants | ( | BufferHandle | ubo, |
| const glm::mat4 & | viewProjection ) |
Frame constants for viewProjection in a buffer the CALLER owns, bound.
For a pass that draws several views. A buffer write is a queue operation and does not land between draws already recorded into an open pass, so views sharing one UBO all read the last write. One buffer each makes the BINDING, an encoder command, what varies.
Definition at line 236 of file RenderContext.cpp.
References bindFrameConstants(), esengine::Invalid, prepareFrameConstants(), and viewProjection().
|
inline |
Definition at line 204 of file RenderContext.hpp.
|
inline |
Gets the current view-projection matrix.
Definition at line 130 of file RenderContext.hpp.
Referenced by prepareFrameConstants(), updateCameraConstants(), updateCameraConstants(), updateFrameConstants(), and useFrameConstants().
|
inline |
Gets the current view-projection matrix (const).
Definition at line 136 of file RenderContext.hpp.