23#ifdef ES_ENABLE_POSTPROCESS
40#include <unordered_map>
44#include <unordered_map>
45#include <unordered_set>
83 static constexpr int kRing = 3;
84 u32 queries_[kRing] = {0, 0, 0};
85 bool inflight_[kRing] = {
false,
false,
false};
157 if (texture == 0 || !(side > 0.0f))
return;
158 f32& held = texture_wants_[texture];
159 if (side > held) held = side;
164 f32 viewHeightPx()
const {
return static_cast<f32>(scene_viewport_.h > 0 ? scene_viewport_.h : height_); }
173 if (texture == 0 || frames < 2) { impostor_atlases_.erase(entity.
raw);
return; }
174 impostor_atlases_[entity.
raw] = {texture, frames};
177 const auto it = impostor_atlases_.find(entity.
raw);
178 return it == impostor_atlases_.end() ?
nullptr : &it->second;
181 return entity == planar_receiver_ ? planar_texture_ : 0;
223 const PassClear& clear);
241 void setScreenDomain(
const std::unordered_set<u32>* domain) { screen_domain_ = domain; }
243 void setUITreeLayers(
const std::unordered_map<u32, i32>* layers) { ui_tree_layers_ = layers; }
246 void setScreenRoots(
const std::vector<u32>* roots,
const std::vector<u32>* rootByIndex) {
247 screen_roots_ = roots;
248 screen_root_by_index_ = rootByIndex;
295 const glm::vec2& position,
const glm::vec2& size,
296 const glm::vec2& uvOffset,
const glm::vec2& uvScale,
297 const glm::vec4& color,
u32 textureId,
307 const f32* vertices,
i32 vertexCount,
308 const u16* indices,
i32 indexCount,
309 u32 textureId,
const f32* transform16,
365 const f32* vertices,
i32 vertexCount,
366 const u16* indices,
i32 indexCount,
367 u32 textureId,
i32 blendMode,
368 const f32* transform16,
369 Entity entity,
i32 layer,
f32 depth,
u32 materialId = 0,
bool premultipliedColor =
false,
370 f32 treeAlpha = 1.0f,
u32 cullBit = 0
375 return ui_tree_layers_ && ui_tree_layers_->count(entity.
id()) != 0;
381#ifdef ES_ENABLE_POSTPROCESS
408 draw_list_.setDepthMask(mask);
411 applySceneDepthNeed();
437 for (
const auto& plugin : plugins_) {
438 if (plugin->clusterInspect(entity.
id(), outTriangles, outClusters))
return true;
444 u8& outLevels,
f32& outSize)
const {
445 return lod_view_state_.inspect(view, entity, outLevel, outUnbiased, outLevels, outSize);
457 lod_view_state_.preview(view, entity, level);
478 if (count == 0) { view_selection_.erase(view);
return; }
479 view_selection_[view] = std::unordered_set<u32>(ids, ids + count);
495 if (environment != 0 && slot != 0) probe_reflections_[entity] = {environment, slot};
496 else probe_reflections_.erase(entity);
501 world_units_per_meter_ = units > 0.0f ? units : 100.0f;
503 context_.materials().setWorldUnitsPerMeter(world_units_per_meter_);
534 return {shadow_held_builds_, shadow_mover_collects_, shadow_lists_kept_, shadow_held_stale_,
535 cover_builds_, cover_mover_collects_, cover_draws_total_, cover_kept_total_};
638 const f32* vertices,
i32 vertexCount,
639 const u16* indices,
i32 indexCount,
640 u32 textureId,
i32 blendMode,
const f32* transform16,
641 i32 layer,
f32 depth,
u32 materialId,
bool premultipliedColor =
false);
666 void addPlugin(std::unique_ptr<RenderTypePlugin> plugin);
695 bool visibleToCamera(
i32 layer,
const glm::vec3& center,
const glm::vec3& halfExtents)
const;
703#ifdef ES_ENABLE_GPU_PARTICLES
705 GpuParticles* gpuParticles() {
return gpu_particles_.get(); }
716#ifdef ES_ENABLE_POSTPROCESS
719#ifdef ES_ENABLE_GPU_PARTICLES
725 u64 skin_cache_frame_ = ~0ull;
728 struct MaterialBake {
u32 ticket;
u32 material;
u32 shader;
u32 target;
u32 x, y, w, h; glm::vec4 a, b;
u32 projection = 0, receiver = 0, instances = 0; };
730 std::vector<MaterialBake> material_bakes_;
731 std::vector<rg::ResourceId> projected_bake_resources_;
732 std::unordered_map<u32, i32> material_bake_states_;
733 u32 next_material_bake_ = 1;
734 u32 material_bakes_drawn_ = 0;
735 struct WaterSunField {
738 glm::vec4 rect{}, depth{}, sun{};
739 glm::vec3 sunDirection{};
741 WaterSunField water_sun_;
743 u64 material_bakes_frame_ = ~0ull;
745 glm::mat4 view_projection_{1.0f};
748 OcclusionView occlusion_;
763 void renderSurface(ecs::Registry& registry,
const glm::mat4& viewProjection,
765 std::span<const PendingSkeletalBatch> extraSkeletalBatches);
777 std::unordered_map<const char*, std::string> pass_scope_names_;
778 f32 pass_graph_ms_ = -1.0f;
780 bool gpu_frame_open_ =
false;
781 bool gpu_frame_passes_ =
false;
783 rg::PassTimer* running_pass_timer_ =
nullptr;
784 bool gpuDetailWanted()
const;
785 FrameCapture frame_capture_;
786 std::vector<u8> snapshot_pixels_;
789 i32 replay_pass_ = -1;
790 i32 replay_draw_ = -1;
791 bool snapshot_matches_ =
false;
792 void runPendingReplay(
const glm::mat4& projection,
u32 w,
u32 h);
793 void tallyPass(
const DrawList& list);
794 void publishFrameCounters();
795 u32 frame_merged_ = 0;
802 struct SkeletalPreview {
803 ecs::Registry registry;
805 std::vector<PendingSkeletalBatch> pending;
806 PreviewSurface surface;
810 static constexpr u32 kPreviewViewId = 0xFFFFFFFEu;
813 lod::LodViewState lod_view_state_;
814 ViewShading view_shading_;
815 lod::SelectionCounts lod_counts_;
817 std::unordered_map<SkeletalPreviewId, Unique<SkeletalPreview>> skeletal_previews_;
823 bool in_frame_ =
false;
824 bool flushed_ =
false;
827 bool depth_seen_ =
false;
829 bool frame_depth_seen_ =
false;
831 bool scene_picture_seen_ =
false;
832 bool frame_scene_picture_seen_ =
false;
835 bool frame_collected_ =
false;
837 bool depth_answered_ =
false;
841 std::unordered_map<u32, ScissorRect> clip_rects_;
843 struct EntityStencilInfo {
845 bool is_mask =
false;
846 bool hierarchical =
false;
848 std::unordered_map<u32, EntityStencilInfo> stencil_masks_;
850 u32 batch_shader_id_ = 0;
851 std::unordered_map<std::string, resource::ShaderHandle> batch_variants_;
852 std::array<const resource::ShaderHandle*, static_cast<usize>(
BatchVariant::Count)> batch_variant_handles_{};
853 TransientBufferPool pool_;
855 bool linear_color_ =
false;
856 ClipState clip_state_;
857 std::vector<std::unique_ptr<RenderTypePlugin>> plugins_;
859 RenderFrameContext makeContext();
860 void buildClipState();
862 void buildSpriteMasks(ecs::Registry& registry);
864 void buildSortingGroups(ecs::Registry& registry);
866 void buildTreeSequence(ecs::Registry& registry);
867 std::vector<Entity> tree_pending_;
869 void accumulateStats(
const DrawList& list);
872 void drawScreenOverlay();
882 void applySceneDepthNeed();
886 void collectLights(ecs::Registry& registry);
888 void collectStudioLights(ecs::Registry& registry);
891 void collectProbes(ecs::Registry& registry);
897 void collectOccluders(ecs::Registry& registry);
900 void collectReflections(ecs::Registry& registry);
901 void declarePlanarReflection(ecs::Registry& registry);
902 void declareProbeCapture(ecs::Registry& registry);
903 void collectProbeFace(ecs::Registry& registry);
904 void executeProbeFace();
905 struct ProbeCapture {
906 enum class State :
u8 { Idle, Capturing, Drawn, Reading };
907 State state = State::Idle;
908 glm::vec3 position{0.0f};
912 glm::mat4 viewProjection{1.0f};
917 std::vector<u8> pixels;
919 ProbeCapture probe_capture_;
920 std::unordered_map<u32, resource::ProbeVolumeHandle> probe_overrides_;
921 struct CapturedReflection {
u32 environment = 0;
u32 slot = 0; };
922 std::unordered_map<u32, CapturedReflection> probe_reflections_;
923 void collectPlanarReflection(ecs::Registry& registry,
u32 view);
924 void executePlanarReflection(
u32 view);
925 struct PlanarCapture {
929 PlanarReflectionCamera camera;
933 u32 mask = 0xFFFFFFFFu;
934 f32 lastTime = -1.0f;
939 std::unordered_map<u32, PlanarCapture> planar_captures_;
940 TransientBufferPool planar_pool_{device_};
941 TransientBufferPool probe_pool_{device_};
942 DrawList probe_list_;
943 f32 world_units_per_meter_ = 100.0f;
947 std::vector<u16> probe_atlas_texels_;
948 DrawList planar_list_;
949 u64 planar_frame_ = 0;
950 f32 planar_elapsed_ = 0;
951 f32 planar_scale_ = 0.5f;
952 bool planar_float_refused_ =
false;
953 u32 planar_max_size_ = 1024;
954 f32 planar_rate_ = 0;
955 bool planar_capped_ =
false;
957 u32 planar_texture_ = 0;
959 std::unordered_map<u32, ImpostorAtlas> impostor_atlases_;
961 std::unordered_map<u32, f32> texture_wants_;
962 PlanarConstants planar_constants_;
963 glm::vec4 scene_clear_{0.0f, 0.0f, 0.0f, 1.0f};
965 void releasePlanarCaptures();
971 bool collectEnvironment(
const ecs::Light& light,
const glm::vec3& scale,
bool withoutSun);
983 void buildShadowPlan(ecs::Registry& registry);
992 void declareShadowPass(ecs::Registry& registry);
994 void declareMaterialBakes(ecs::Registry& registry);
995#ifdef ES_ENABLE_POSTPROCESS
996 struct ReceiverCapture {
997 explicit ReceiverCapture(GfxDevice& device) : pool(device) {}
1000 if (constants != BufferHandle::Invalid) pool.device().deleteBuffer(constants);
1003 TransientBufferPool pool;
1006 Unique<Framebuffer> target;
1010 struct ReceiverMaps {
1011 rg::ResourceId fixed = rg::kNoResource, moving = rg::kNoResource;
1012 glm::vec4 window{0, 0, 1, 0};
1014 std::vector<Unique<ReceiverCapture>> receiver_captures_;
1015 ReceiverMaps declareCausticReceivers(ecs::Registry& registry,
const MaterialBake& bake,
const glm::vec4& sun,
usize index);
1021 bool collectShadowViews(ecs::Registry& registry,
u64 inputs,
bool vouched,
u64 heldInputs,
bool heldVouched,
u64& key);
1022 void collectShadowLists(ecs::Registry& registry,
CasterSplit split, TransientBufferPool& pool, std::vector<DrawList>& lists,
1024 u32 shadowViewDraws(
usize vi)
const;
1026 void executeShadowPass();
1036 void collectShadow2D(ecs::Registry& registry);
1039 bool hasShape2DLight(ecs::Registry& registry);
1042 void declareShadow2DPass();
1046 void executeShadow2DPass(
u32 mask);
1049 void buildShadow2DGeometry(
u32 mask);
1052 void releaseShadow2DResources();
1055 bool ensureShadow2DShader();
1059 bool shadow2DActive()
const {
return shadow_2d_masks_[0].textureId != 0; }
1067 void collectShape2D(ecs::Registry& registry);
1070 void declareShape2DPass();
1073 void executeShape2DPass();
1076 void releaseShape2DResources();
1079 bool ensureShape2DShader();
1082 bool shape2DActive()
const {
return shape_2d_texture_id_ != 0; }
1085 void ensureShadowFrameUbos(
u32 count);
1088 void releaseShadowFrameUbos();
1092 void submitColorList(DrawList& list, TransientBufferPool& buffers, FrameCapture* capture,
1096 void releaseFrameTargets();
1099 glm::vec3 min{0.0f}, max{0.0f};
1101 void include(
const glm::vec3& centre,
const glm::vec3& half) {
1102 min = valid ? glm::min(min, centre - half) : centre - half;
1103 max = valid ? glm::max(max, centre + half) : centre + half;
1107 struct ShadowBounds { MeshBounds all, casters, hair; };
1109 ShadowBounds gatherShadowBounds(ecs::Registry& registry,
bool includeHair);
1113 u32 initBatchShader();
1125 struct ShadowCaster {
1133 glm::vec3 dir{0.0f, 0.0f, -1.0f};
1135 glm::vec3 pos{0.0f};
1141 f32 outerAngle = 0.0f;
1144 f32 slopeFloor = 0.15f;
1149 struct CollectedLight {
1151 bool castsMeshShadow;
1152 ShadowCaster caster;
1154 std::vector<CollectedLight> light_scratch_;
1157 std::vector<ShadowCaster> shadow_casters_;
1160 i32 cloud_sun_slot_ = -1;
1161 glm::vec3 cloud_sun_aim_{0.0f, -1.0f, 0.0f};
1164 i32 cloud_tile_ = -1;
1165 glm::mat4 cloud_matrix_{1.0f};
1169 rg::TargetPool target_pool_;
1173 rg::RenderGraph graph_;
1181 GfxDevice::Viewport scene_viewport_{};
1190 struct ShadowRing2D {
1194 glm::vec2 centre{0.0f};
1199 struct Shadow2DLight {
1201 glm::vec2 pos{0.0f};
1203 glm::vec2 dir{0.0f};
1208 f32 softness = 0.0f;
1215 bool directional =
false;
1218 std::vector<glm::vec2> shadow_points_2d_;
1219 std::vector<ShadowRing2D> shadow_rings_2d_;
1220 std::vector<Shadow2DLight> shadow_2d_lights_;
1222 u32 shadow_2d_unplaced_ = 0;
1226 struct Shadow2DMask {
1231 std::vector<f32> vertices;
1235 Shadow2DMask shadow_2d_masks_[2];
1236 RetainedTextStore retained_text_;
1239 bool shadow_2d_shader_tried_ =
false;
1242 struct Shape2DLight {
1244 glm::vec2 corners[4]{};
1251 std::vector<Shape2DLight> shape_2d_lights_;
1254 u32 shape_2d_texture_id_ = 0;
1256 std::vector<f32> shape_2d_vertices_;
1258 u32 shape_2d_vbo_bytes_ = 0;
1261 bool shape_2d_shader_tried_ =
false;
1274 glm::mat4 view_projection{1.0f};
1281 glm::vec3 ray{0.0f, -1.0f, 0.0f};
1283 f32 reachCap = 0.0f;
1286 bool shadow_receiver_cull_ =
true;
1289 std::vector<ShadowView> shadow_views_;
1298 TransientBufferPool shadow_pool_;
1303 TransientBufferPool velocity_pool_;
1304 DrawList velocity_list_;
1306 std::unordered_map<u32, std::unordered_set<u32>> view_selection_;
1307 TransientBufferPool selection_pool_;
1308 DrawList selection_list_;
1311 void collectSelection(ecs::Registry& registry);
1312 void executeSelectionPass();
1316 glm::vec2 velocity_jitter_{0.0f};
1318 void collectMotion(ecs::Registry& registry);
1319 void executeMotionPass();
1327 void collectCover(ecs::Registry& registry);
1328 void executeCoverPass();
1329 TransientBufferPool cover_pool_;
1330 DrawList cover_list_;
1331 TransientBufferPool cover_mover_pool_{device_};
1332 DrawList cover_mover_list_;
1333 u64 cover_held_hash_ = 0;
1334 bool cover_held_trusted_ =
false;
1335 u64 cover_held_inputs_ = 0;
1336 bool cover_held_valid_ =
false;
1337 bool cover_held_uploaded_ =
false;
1338 bool cover_movers_uploaded_ =
false;
1339 u64 cover_lists_inputs_ = 0;
1340 bool cover_lists_valid_ =
false;
1342 bool cover_trusted_ =
false;
1343 u64 cover_drawn_key_ = 0;
1344 bool cover_drawn_valid_ =
false;
1345 u32 cover_drawn_target_ = 0;
1346 u32 cover_builds_ = 0;
1347 u32 cover_mover_collects_ = 0;
1348 u32 cover_draws_total_ = 0;
1349 u32 cover_kept_total_ = 0;
1350 bool cover_wanted_ =
false;
1351 bool coverInputs(ecs::Registry& registry,
u64& key,
u64& heldKey,
bool& heldVouched);
1352 u32 coverCommandCount()
const {
return cover_list_.commandCount() + cover_mover_list_.commandCount(); }
1354 glm::mat4 cover_view_projection_{1.0f};
1356 glm::vec2 scene_jitter_{0.0f};
1358 bool depth_prepass_ =
false;
1359 bool probes_per_pixel_ =
true;
1360 bool lighting_direct_ =
false;
1361 f32 lod_distance_scale_ = 1.0f;
1364 std::vector<DrawList> shadow_view_lists_;
1370 u64 shadow_drawn_key_ = 0;
1371 bool shadow_drawn_valid_ =
false;
1373 u64 shadow_pending_key_ = 0;
1374 bool shadow_pending_trusted_ =
false;
1376 bool shadow_reused_ =
false;
1379 u64 shadow_drawn_inputs_ = 0;
1380 bool shadow_drawn_inputs_valid_ =
false;
1381 u64 shadow_pending_inputs_ = 0;
1382 bool shadow_pending_inputs_valid_ =
false;
1384 u32 shadow_inputs_stale_ = 0;
1385 bool warned_shadow_inputs_ =
false;
1387 bool shadowInputs(ecs::Registry& registry,
u64& key,
u64& heldKey,
bool& heldVouched);
1388 TransientBufferPool shadow_mover_pool_{device_};
1389 std::vector<DrawList> shadow_mover_lists_;
1390 std::vector<u64> shadow_held_hash_;
1391 std::vector<u8> shadow_held_trusted_;
1392 u32 shadow_held_culled_ = 0;
1393 u64 shadow_held_inputs_ = 0;
1394 bool shadow_held_valid_ =
false;
1395 bool shadow_held_uploaded_ =
false;
1396 u64 shadow_lists_inputs_ = 0;
1397 bool shadow_lists_valid_ =
false;
1398 u64 shadow_lists_key_ = 0;
1399 bool shadow_lists_trusted_ =
false;
1400 u32 shadow_held_builds_ = 0;
1401 u32 shadow_mover_collects_ = 0;
1402 u32 shadow_lists_kept_ = 0;
1403 u32 shadow_held_stale_ = 0;
1404 bool warned_shadow_held_ =
false;
1405 u32 shadow_casters_culled_ = 0;
1407 u32 shadow_held_tiles_ = 0;
1408 u32 shadow_held_draws_ = 0;
1413 std::vector<u64> shadow_tile_keys_;
1414 std::vector<u8> shadow_tile_held_;
1415 std::vector<u32> shadow_tile_draws_;
1416 u64 shadow_tile_layout_ = 0;
1417 bool shadow_tiles_known_ =
false;
1419 std::vector<u64> shadow_view_keys_;
1420 std::vector<u8> shadow_view_trusted_;
1421 std::vector<u8> shadow_view_redraw_;
1422 u64 shadow_layout_ = 0;
1424 u32 shadow_tile_passes_left_ = 0;
1425 bool shadow_pool_uploaded_ =
false;
1426 u32 shadow_frame_tiles_ = 0, shadow_frame_draws_ = 0;
1427 u32 shadow_squares_kept_total_ = 0, shadow_squares_drawn_total_ = 0;
1429 void drawShadowView(
usize vi);
1431 void recordShadowTiles(
bool all);
1433 void executeShadowTile(
usize vi);
1437 std::vector<BufferHandle> shadow_frame_ubos_;
1444 f32 shadow_distance_ = 0.0f;
1445 u32 shadow_2d_soft_samples_ = 16;
1446 ShadowPlanReport shadow_plan_;
1447 ShadowPlanReport previous_shadow_plan_;
1448 LightCapReport light_cap_;
1450 bool scene_sky_available_ =
false;
1452 u32 shadow_texture_id_ = 0;
1454 u32 environment_texture_id_ = 0;
1456 bool draw_sky_ =
false;
1458 u32 sky_texture_id_ = 0;
1460 u32 sky_programs_[2] = {};
1461 bool sky_compiled_[2] = {};
1463 void collectSky(RenderCollectContext&
ctx);
1466 const std::unordered_set<u32>* screen_domain_ =
nullptr;
1467 const std::unordered_map<u32, i32>* ui_tree_layers_ =
nullptr;
1468 bool overlay_active_ =
false;
1469 bool retained_text_collected_ =
false;
1473 struct OverlayHold {
1474 explicit OverlayHold(GfxDevice& device) : pool(device) {}
1475 TransientBufferPool pool;
1478 std::unique_ptr<OverlayHold> overlay_hold_;
1479 bool overlay_swapped_ =
false;
1481 bool overlay_kept_ =
false;
1483 bool overlay_reset_pending_ =
false;
1485 bool overlay_valid_ =
false;
1486 u64 overlay_key_ = 0;
1487 u32 overlay_tick_ = 0;
1488 double overlay_journal_ = -1;
1489 u64 overlay_pending_key_ = 0;
1490 u32 overlay_pending_tick_ = 0;
1491 double overlay_pending_journal_ = -1;
1493 u64 overlay_watched_ = 0;
1494 u32 overlay_reader_ = 0;
1496 u32 overlay_passes_ = 0;
1498 u64 overlay_content_ = 0;
1499 bool overlay_would_keep_ =
false;
1500 u32 overlay_stale_ = 0;
1501 bool warned_overlay_stale_ =
false;
1502 u32 overlay_kept_total_ = 0;
1503 u32 overlay_why_ = 0;
1504 void swapOverlayIn();
1505 void swapOverlayOut();
1506 void resetOverlayContents();
1507 u64 overlayInputs(ecs::Registry& registry,
bool whole)
const;
1508 bool overlayRegistryMoved(ecs::Registry& registry);
1513 struct OverlaySegment {
1515 std::unique_ptr<OverlayHold> hold;
1518 bool wouldKeep =
false;
1522 const std::vector<u32>* screen_roots_ =
nullptr;
1523 const std::vector<u32>* screen_root_by_index_ =
nullptr;
1524 std::vector<OverlaySegment> segments_;
1526 bool overlay_segmented_ =
false;
1529 bool segments_trusted_ =
false;
1530 u64 segments_key_ = 0;
1531 u32 segments_tick_ = 0;
1532 double segments_journal_ = -1;
1534 bool segments_refused_ =
false;
1535 u64 segments_refused_roots_ = 0;
1536 u32 overlay_segments_rebuilt_ = 0;
1538 u32 overlay_rebuilt_last_ = 0;
1539 ecs::Registry* overlay_registry_ =
nullptr;
1540 u32 screenRootAt(
u32 entity)
const;
1541 u64 screenRootsHash()
const;
1542 bool keepSegments(ecs::Registry& registry);
1543 void segmentIn(OverlaySegment& segment);
1544 void segmentOut(OverlaySegment& segment);
1545 void collectScreenOverlayInto(ecs::Registry& registry,
u32 onlyRoot);
1547 glm::mat4 overlay_projection_{1.0f};
1548 i32 overlay_vp_x_ = 0, overlay_vp_y_ = 0;
1549 u32 overlay_vp_w_ = 0, overlay_vp_h_ = 0;
1550 u32 overlay_effect_ = 0;
1553 u32 overlay_grab_w_ = 0, overlay_grab_h_ = 0;
1555 void executeOverlayGraph();
1556 void releaseOverlayBackdrop();
1559 std::vector<ResolvedMask> sprite_mask_scratch_;
1560 std::vector<Entity> mask_entities_scratch_;
1562 std::vector<Entity> mask_scissor_scratch_;
1563 std::vector<Entity> mask_stencil_scratch_;
1564 std::vector<Entity> mask_root_scratch_;
1565 std::vector<std::pair<Entity, ScissorRect>> mask_scissor_walk_scratch_;
1566 std::vector<std::pair<Entity, i32>> mask_stencil_walk_scratch_;
1567 std::unordered_set<u32> mask_set_scratch_;
1568 std::unordered_set<u32> stencil_set_scratch_;
One frame's draw calls as the device received them, for the frame debugger.
Abstract graphics device interface.
Per-frame 2D lighting constants — the third tier of the engine's constant-buffer layering (after per-...
Which lights reached the frame, and who was turned away.
Post-processing effects pipeline.
Central ECS registry for entity and component management.
Rendering context containing all renderer state.
Full-screen passes as a declared graph: what each one reads, what it writes, and at what size — the g...
Central resource management system.
Glyph geometry the engine keeps between frames, and the clipping of it against a view.
Who owns which square of the one shadow texture.
What each caster asked the shadow atlas for, and what it got.
Skinned meshes posed once a frame by a compute shader, into vertices every pass then draws as they ar...
Which SpriteMask, if any, cuts a sprite — the rule, apart from the frame.
The render targets a frame borrows from, keyed by shape — owned by the frame, not by any one graph th...
GPU texture abstraction for 2D images.
Core type definitions and utilities for ESEngine.
Abstract graphics device interface.
void end(GfxDevice &device)
void poll(GfxDevice &device)
void begin(GfxDevice &device)
Post-processing effects pipeline.
void wantTextureSide(u32 texture, f32 side)
Note that a view drew a mesh with texture texture (a resource handle) where it needs side texels acro...
void setScreenDomain(const std::unordered_set< u32 > *domain)
The screen's entities (UISystem::screenDomain), borrowed for the frame. Null partitions nothing — eve...
void setPlanarQuality(f32 scale, u32 maxSize, f32 updatesPerSecond, bool capAuthored)
void setEntityStencilMask(u32 entity, i32 refValue, bool hierarchical=false)
void renderToTarget(ecs::Registry ®istry, const glm::mat4 &viewProjection, u32 w, u32 h)
void submitScreenOverlay(ecs::Registry ®istry)
Collects the screen's renderables. Between this and endScreenOverlay a host may submit its own screen...
ShadingMode viewShading(u32 view) const
The mode view asked for; Shaded when it never did.
const u8 * getPreviewPixels() const
u32 skeletalPreviewWidth(SkeletalPreviewId id) const
void endFrame()
Closes the FRAME, once, after every camera and every overlay.
void setDepthLayers(u32 mask)
void setColorSpace(bool linear)
Switch the frame to linear-light rendering (project colorSpace).
void setStage(RenderStage stage)
bool probesPerPixel() const
void processMasks(ecs::Registry ®istry, i32 vpX, i32 vpY, i32 vpW, i32 vpH)
void requestProbeCapture(const glm::vec3 &position, u32 face)
Capture the scene around position (world) into six face-pixel faces, one a frame, and read them back:...
void setPresentedOverlayDraw(ImmediateDraw *draw)
bool projectMaterialBake(u32 ticket, u32 material, u32 target, u32 instances)
void addPlugin(std::unique_ptr< RenderTypePlugin > plugin)
const ImpostorAtlas * impostorAtlas(Entity entity) const
void setUITreeLayers(const std::unordered_map< u32, i32 > *layers)
The layers of what a Canvas holds with no uiOrder, borrowed for the frame.
void setSkyEnvironment(resource::EnvironmentHandle environment)
The environment the sky lights the scene with (the Sky Atmosphere's, worked out by the SDK as the sky...
void submitTileQuad(const glm::vec2 &position, const glm::vec2 &size, const glm::vec2 &uvOffset, const glm::vec2 &uvScale, const glm::vec4 &color, u32 textureId, Entity entity, i32 layer, f32 depth)
SkeletalPreviewId createSkeletalPreview(u32 w, u32 h)
std::string planarStatus(u32 view, u32 entity) const
void setEntityClipRect(u32 entity, i32 x, i32 y, i32 w, i32 h)
void setShadowBudget(u32 atlasSize, u32 cellSize, u32 cascades)
u32 stagedVertexBytes(LayoutId layout) const
The vertex bytes staged for layout since the last begin().
void setPlanarTime(f32 seconds)
void setOcclusionGridSize(u32 size)
FrameCapture & frameCapture()
void setImpostorAtlas(Entity entity, u32 texture, u32 frames)
Hand entity the atlas its Impostor draws from; a zero texture takes it away.
void setViewShading(u32 view, ShadingMode mode)
Shade view's meshes as mode says instead of as authored.
void setScreenRoots(const std::vector< u32 > *roots, const std::vector< u32 > *rootByIndex)
The screen's root Canvases in drawing order and, by entity index, the root each screen entity draws u...
RenderPrewarmResult prewarmDocument(const MeshDocumentRecord *rows, u32 count)
The same readiness, from a prepared cell's own description — no entity of it need exist.
bool inFrame() const
Whether begin() opened a frame; false when it refused one for a lost device.
CasterCacheStats casterCacheStats() const
void endScreenOverlay(RenderTargetManager::Handle target)
const LightCapReport & lightCap() const
Which lights the cap turned away last frame, and why.
u32 getPreviewHeight() const
void setDepthPrepass(bool on)
void begin(const glm::mat4 &view_projection, RenderTargetManager::Handle target=0)
const ShadowPlanReport & shadowPlan() const
What each caster asked the shadow atlas for last frame, and what it got.
void setProbeVolumeOverride(u32 entity, resource::ProbeVolumeHandle grid)
The grid a volume reads instead of its own probes (a capture's), or an invalid handle to stop.
void drawOverScreen(i32 vpX, i32 vpY, u32 vpW, u32 vpH, RenderTargetManager::Handle target)
Draws the immediate geometry collected since the screen overlay over everything the frame shows,...
bool retainedTextCollected() const
bool lightingDirect() const
const std::vector< u8 > & probeCapturePixels() const
The six faces side by side, +X -X +Y -Y +Z -Z, RGBM over 8 in RGBA8 (alpha 0 = nothing drawn),...
void init(u32 width, u32 height)
void clearAllStencilMasks()
void setViewSelection(u32 view, const u32 *ids, u32 count)
The editor's selection in view, outlined on screen (by Entity::id()); empty clears it.
void setTargetPoolIdleBudget(u64 bytes)
bool keepScreenOverlay(ecs::Registry ®istry, bool hostStill)
Asked after beginScreenOverlay and the layers: true, and the host submits nothing and endScreenOverla...
void setCullingMask(u32 mask)
Layers the camera about to be collected renders — see DrawList::setCullingMask.
RenderFrame & operator=(const RenderFrame &)=delete
u32 skeletalPreviewHeight(SkeletalPreviewId id) const
u32 getSnapshotWidth() const
void setLodPreview(u32 view, Entity entity, u8 level)
Show level for entity in view instead of the level that view chose; lod::kNoPreview goes back to choo...
i32 pollSnapshotReadback()
u32 displayProgram(u32 program)
u32 getPreviewWidth() const
void setTreeSortLayers(u32 mask)
Layers (bits 0..31) that paint in hierarchy order within the layer — see DrawList::setTreeMask.
void replayToDrawCall(i32 drawIndex)
void setViewSkinWeights(u32 view, Entity entity, u32 joint)
Colour entity in view by how much joint moves each of its vertices.
const u8 * skeletalPreviewPixels(SkeletalPreviewId id) const
std::string takeTextureWants()
What each texture was asked for since the last take, as handle:side pairs joined by commas; the recor...
bool sceneSkyAvailable() const
Whether the frame found a scene environment it could draw as the background.
void submitRetainedText(ecs::Registry ®istry, bool screen, const f32 *projection, u32 onlyRoot=0)
Every retained label laid out for one domain into the open list, culled against projection (world,...
void setLightingDirect(bool on)
f32 lodDistanceScale() const
u32 queueMaterialBake(u32 material, u32 shader, u32 target, u32 x, u32 y, u32 w, u32 h, const glm::vec4 &a, const glm::vec4 &b)
Draws material material through shader (a PostProcess-domain shader) into the rect (x,...
u32 getSnapshotSize() const
void setProbesPerPixel(bool on)
Whether a mesh without lightmap UVs reads its probe volume per pixel (the grid through the frame's br...
void cancelMaterialBakesFor(u32 target)
void beginFrame()
Opens the FRAME, once, before any of its cameras.
bool lodInspect(u32 view, Entity entity, u8 &outLevel, u8 &outUnbiased, u8 &outLevels, f32 &outSize) const
void setRetainedTextCollected(bool collected)
The retained labels drawn by the frame's own collects (the camera's world labels, the overlay's scree...
void setYSortLayers(u32 mask)
Layers (bits 0..31) that sort by world Y within the layer — see DrawList::setYSortMask.
u32 getSnapshotHeight() const
RenderFrame(const RenderFrame &)=delete
void setLodDistanceScale(f32 scale)
bool clusterInspect(Entity entity, u32 &outTriangles, u32 &outClusters) const
The LOD decision view last made about entity: the level, what the bare thresholds asked for,...
void setViewId(u32 view)
Names the view the camera about to be collected looks from, which is what its LOD levels are remember...
bool submitSkeletalPreviewBatch(SkeletalPreviewId id, const f32 *vertices, i32 vertexCount, const u16 *indices, i32 indexCount, u32 textureId, i32 blendMode, const f32 *transform16, i32 layer, f32 depth, u32 materialId, bool premultipliedColor=false)
RenderTargetManager & targetManager()
void collectAll(ecs::Registry ®istry, bool sceneGBuffer=true)
RetainedTextStore & retainedText()
The glyph quads of every label the text system laid out and handed over once, which the engine submit...
const PlanarConstants & planarConstants() const
void submitSkeletalBatch(const f32 *vertices, i32 vertexCount, const u16 *indices, i32 indexCount, u32 textureId, i32 blendMode, const f32 *transform16, Entity entity, i32 layer, f32 depth, u32 materialId=0, bool premultipliedColor=false, f32 treeAlpha=1.0f, u32 cullBit=0)
Batch vertices posed by a skeletal runtime, drawn as one entity's geometry.
u32 batchProgram(BatchVariant variant)
u32 planarTextureFor(Entity entity) const
const ViewLighting & viewLighting() const
u32 getPreviewSize() const
i32 materialBakeState(u32 ticket)
A bake's state: 0 waiting, 1 drawn, -1 not drawable (no target, shader or material,...
usize lodPreviewCount() const
How many (view, entity) pairs are held up for inspection.
void resize(u32 width, u32 height)
i32 pollProbeCapture()
0 = not yet, 1 = ready (probeCapturePixels), 2 = none asked for or it failed. Between frames only.
static constexpr u32 STAGE_COUNT
f32 viewHeightPx() const
The pixel height of the view being collected: what a texel is held to.
i32 pollPreviewReadback()
void setShadow2DSoftSamples(u32 samples)
How many samples across a light source a soft 2D shadow is drawn with: the quality level's say on the...
bool screenOverlayOpen() const
Whether the overlay is open — what routes a host's submissions.
void submitTextBatch(const f32 *vertices, i32 vertexCount, const u16 *indices, i32 indexCount, u32 textureId, const f32 *transform16, Entity entity, i32 layer, f32 depth, TextGlyphMode mode, u32 cullBit=0)
RenderFrame(GfxDevice &device, RenderContext &context, resource::ResourceManager &resource_manager)
void beginScreenOverlay(const glm::mat4 &projection, i32 vpX, i32 vpY, u32 vpW, u32 vpH)
Opens the overlay: projection maps the layout domain onto the pixel rect vpX/vpY/vpW/vpH of the surfa...
bool renderSkeletalPreview(SkeletalPreviewId id, const glm::mat4 &viewProjection)
bool uiTreeHolds(Entity entity) const
Whether a Canvas holds entity with no uiOrder of its own (an emitter, a skeleton, a plain Sprite).
const Stats & stats() const
void destroySkeletalPreview(SkeletalPreviewId id)
bool setQualityValue(const std::string &name, f32 value)
RenderStage getStage() const
bool snapshotMatchesCapture() const
RenderPrewarmResult prewarmPrograms(ecs::Registry ®istry, const Entity *entities, u32 count)
Make ready the programs entities will need, drawing nothing.
u32 skeletalPreviewSize(SkeletalPreviewId id) const
void setEntityStencilTest(u32 entity, i32 refValue, bool hierarchical=false)
void setScreenOverlayEffect(u32 material)
void setShadowDistance(f32 distance)
const u8 * getSnapshotPixels() const
void setWorldUnitsPerMeter(f32 units)
How many world units make a metre (the project's setting): what an inverse-square light measures in.
i32 pollSkeletalPreview(SkeletalPreviewId id)
bool visibleToCamera(i32 layer, const glm::vec3 ¢er, const glm::vec3 &halfExtents) const
Whether the camera being rendered right now would draw something of layer at these world bounds.
void setProbeVolumeReflection(u32 entity, u32 environment, u32 slot)
The volume on entity reflects column slot of environment (an atlas built from captures,...
void setViewLighting(const ViewLighting &lighting)
The retained geometry of every label, by entity. Ordered: a frame submits in entity order,...
Central container for all entities and components.
Central manager for GPU resources.
Handle< esengine::Shader > ShaderHandle
Handle to a shader resource.
Handle< esengine::Environment > EnvironmentHandle
Handle to a baked environment (irradiance + prefiltered reflection).
Handle< esengine::ProbeVolume > ProbeVolumeHandle
Handle to a grid of baked irradiance.
constexpr ResourceId kNoResource
FramebufferHandle
Handle 0 is the default framebuffer (backbuffer); it cannot be created or deleted.
std::int32_t i32
Signed 32-bit integer.
std::uint64_t u64
Unsigned 64-bit integer.
constexpr u32 kShadowCellSize
std::size_t usize
Size type for indexing and sizes.
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
constexpr u32 kShadowAtlasSize
std::unique_ptr< T > Unique
Unique ownership smart pointer.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
ShadingMode
What a mesh is drawn WITH in a view, whatever its own material says.
std::uint16_t u16
Unsigned 16-bit integer.
LayoutId
Identifies a transient vertex stream / vertex format. Each layout has its own VBO+EBO+VAO in Transien...
static EstellaContext & ctx()
constexpr u32 kShadowCascadeCells
ReadbackHandle
An in-flight framebuffer readback (GfxDevice::requestReadback).
float f32
32-bit floating point
ShadowShape
The shape a light's map has to cover — the one thing a shadow pass differs by.
constexpr u32 MAX_SHADOW_CASCADES
Slices one directional shadow map is split into, each covering a stretch of the view — so the near on...
Entity identifier with packed index + generation.
constexpr u32 id() const
Returns the raw packed value for FFI serialization.
What the frame's light cap came to.
What a renderable's program key is made of, with no say in where the facts came from — a live entity'...
An impostor's pictures: the atlas texture and how many frames along its side.
The frame's main-pass load-op: which attachments to clear, the color, and an optional region (w == 0 ...
Skeletal geometry a caller holds until it renders, owning its bytes.
std::vector< u16 > indices
std::vector< f32 > vertices
One offscreen render's resources, correct only together.
RenderTargetManager::Handle target
u32 gpu_draws
Every draw the GPU was asked for in the frame, every pass included; draw_calls is the scene's and the...
u32 lightsSpared
Loop lights the lit quads did not have to work out (RenderCollectContext::lightsSpared).
u32 occluded
Of culled, how many an occluder refused rather than the frustum.
u32 waiting_for_program
Scene draws left out of the frame because a program they use was still compiling in the background.
The editor view's own lighting, in place of the scene's.
bool showSky
Draw the scene's environment as the background while studio-lit.
f32 skyIntensity
Scales the neutral sky's light; the scene's own Ambient is not consulted.
f32 rotation
Degrees about +Y that the key and fill turn together.
What readying a set of renderables' programs found. Counts, not JSON: this crosses no boundary and pa...
The frame's whole shadow allocation, as numbers something outside it can check.
A 2D light contributing to Lit-shaded materials.