Skip to content

Harden renderer lifecycle, frame flow, resize, backend selection and recovery (Statement 9) - #9

Merged
ercmine merged 1 commit into
mainfrom
codex/implement-renderer-lifecycle-and-recovery
Apr 6, 2026
Merged

Harden renderer lifecycle, frame flow, resize, backend selection and recovery (Statement 9)#9
ercmine merged 1 commit into
mainfrom
codex/implement-renderer-lifecycle-and-recovery

Conversation

@ercmine

@ercmine ercmine commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Make the renderer runtime robust and production-minded by owning startup/shutdown, backend selection, swapchain/frame lifecycle, resizing, pacing and a pragmatic recovery path.
  • Replace scattered booleans with an explicit engine-owned lifecycle model so future systems can query renderability and not fight init/resize ordering.
  • Ensure the runtime shell uses a disciplined begin/end frame contract and that resize and device-loss paths are deterministic and well-logged.

Description

  • Added explicit lifecycle types and status snapshots via RendererLifecycleState, RendererFrameStats, RendererStatus, and RendererConfigValidation, and utility helpers like is_explicit_backend_request and string converters; exposed new query APIs state(), status(), is_ready(), and can_render().
  • Hardened startup with validate_renderer_config, deterministic engine-owned backend mapping (RendererBackend) with requested-vs-actual logging, capability logging, and guarded re-init/shutdown transitions.
  • Reworked frame contract to guarded begin_frame() / end_frame() that detect misuse (double-begin, end-without-begin), apply deferred/deduplicated request_resize() at frame boundary, and record lightweight per-frame timing stats.
  • Implemented safe resize handling that defers zero/minimized dimensions, deduplicates apply requests, and updates backbuffer via bgfx::reset without requiring an app restart.
  • Introduced a lightweight frame pacing floor via RendererConfig::min_frame_time_ms applied in end_frame() (no simulation scheduler added).
  • Added a pragmatic recovery path with try_recover() and Recovering/Failed states that attempts in-place reset and logs outcomes, preparing the architecture for future full resource re-creation.
  • Integrated runtime shell changes to forward platform resize events with request_resize() and to gate rendering on begin_frame() success, and updated documentation and engine README to describe the lifecycle contract.
  • Added a small unit test exercising config validation and lifecycle pre-init behavior and wired it into CTest (render_renderer_lifecycle_tests) so CI can cover lifecycle regressions once dependencies are available.

Testing

  • Added unit test tests/render/renderer_lifecycle_tests.cpp and registered the unit.renderer.lifecycle CTest target so lifecycle checks are included in render_test_unit.
  • Attempted configure with cmake --preset linux-debug in this environment but configure failed due to unresolved third-party dependency roots for SDL3/bgfx, so the project could not be built or tests executed here.
  • The new unit test contains only header-level/runtime-safety assertions and will run in CI once dependencies are provided; configuration failures are environmental and not caused by the lifecycle changes.

Codex Task

@ercmine
ercmine merged commit 651a89e into main Apr 6, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant