Repository navigation
render: extract object creation into ruis::render::factory (issue #190) - #192
Merged
Merged
Conversation
Implement issue #190 (render context redesign). Object creation (make_shaders, make_texture_*, make_vertex_buffer, make_index_buffer, make_vertex_array) is split out of ruis::render::context into a new ruis::render::factory class. The factory is the shared (headless) render context and owns the make_* functions; every per-window context holds an injected shared_ref<const factory> and no longer creates shareable objects. Every GPU object (texture_2d, texture_depth, texture_stencil, texture_cube, vertex_buffer, index_buffer, vertex_array and the four shader base classes) now stores a shared_ref<const factory> instead of a shared_ref<const context>, so an object created for one window is safely usable in any other window (it is bound to the shared context, not a single window). make_framebuffer stays on the context: a frame buffer is inherently per-window. The resource_loader and renderer::objects now take the factory, and the ~42 make_* call sites in the ruis core are routed through it. This makes the 'create shared objects via the shared context' rule enforced by the type system: a per-window context no longer exposes the shareable make_* at all.
This was referenced Nov 19, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
==========================================
+ Coverage 28.50% 28.54% +0.03%
==========================================
Files 238 239 +1
Lines 8934 8941 +7
Branches 2785 2785
==========================================
+ Hits 2547 2552 +5
- Misses 6053 6055 +2
Partials 334 334 ☔ View full report in Codecov by Harness. |
- Make the factory destructor public virtual (matching context) to satisfy the cppcoreguidelines-virtual-class-destructor clang-tidy check. - Bump the tests/harness/modules submodules (ruisapp, ruis-render-opengl, ruis-render-opengles, ruis-render-null) to their ren_factory commits so the CI builds a consistent set (new ruis core + matching ruisapp/renderers).
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
The myci-actions/checkout default is 'remote_recursive', which runs 'git submodule update --remote --recursive' and resets the tests/harness submodules (ruisapp + renderers) to their 'branch = main' tips, ignoring the pinned gitlink commits. That broke the harness build for the factory change (new ruis core vs old main ruisapp/renderers). Set 'submodules: recursive' on the harness/library jobs so the submodules are checked out at the recorded gitlink commits (pinned to the ren_factory commits for now; to be bumped to main once the dependent PRs land).
…th_vao - texture_font / texture_font_face: rename rendering_context member/param to factory - ellipse_vao / rectangle_vao: drop stale 'resource-loader'/'outlive' doc comments - path_vao: retain only the shared factory; take renderer as a render() parameter; ctor takes (factory, objects) - update tests (paint, wire_area) accordingly
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
…ing_context members to factory - Convert the public context::factory member to a private factory_ref member plus a public fac() accessor (avoids the name clash with the ruis::render::factory type and the public-member design smell). - Rename the rendering_context members/params to factory in the shareable object and shader base classes and res/* helpers. - Update all callers to use context.fac(). - CI: use 'submodules: true' (no nested submodules) for the checkout.
The render factory stays a public member of the context (as before). fac() is just a shorthand that returns a const reference to it, for the common context.fac().make_*() call sites.
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
igagis
commented
Nov 19, 2026
- rectangle_vao: rename the factory-typed 'ctx' params/vars to 'factory' - context::fac(): drop the explicit .get() (shared_ref auto-casts to ref) - resource_loader: add a fac() shorthand; use it in the res/* loaders - widget/gradient/texture_font: use the renderer's ctx() instead of poking at the rendering_context member directly
Replace the verbose context.get().renderer.get().ctx().fac() chains with the this->ctx().ren().ctx().fac() shortcut, and shorten other long chains in widget.cpp to r.ctx()/this->ctx().ren().ctx().
factory.hpp is a header-only class with no corresponding source file. Add a dummy factory.cpp that just includes the header so the header is compiled and linted during the lint preset build (per the add-new-source-file convention).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #190 (render context redesign).
Splits object creation out of
ruis::render::contextinto a newruis::render::factoryclass. The factory is the shared (headless) render context and owns themake_*object-creation functions. Every per-windowcontextholds an injectedshared_ref<const factory>and no longer creates shareable objects.Why
Previously
make_texture_2d(),make_vertex_array(), etc. lived on the per-windowcontext, and the objects they returned retained ashared_ref<const context>. Nothing stopped a user from creating a shared object through a window's context and then using it in another window — the object would be pinned to the first window (the root cause of the multi-window freeze/ghost bug). The correct approach was to create shared objects via the shared context, but that was only a convention.Now the shareable-object
make_*functions exist only on the factory, and the resulting objects are bound to the shared context (not any single window). The rule is enforced by the type system: a per-window context no longer exposes thosemake_*at all.Changes
ruis::render::factory(abstract): owns the shareable-objectmake_*+ the movedshadersstruct andtexture_2d_parameters.ruis::render::context: removed the shareablemake_*and the nestedshaders; added an injectedfactorymember.make_framebufferstays on the context (a frame buffer is inherently per-window).shared_ref<const factory>instead of ashared_ref<const context>.resource_loaderandrenderer::objectstake the factory; the ~42 coremake_*call sites are routed through it.Depends on
This is the ruis core change. It must be merged before/with the matching renderer and ruisapp PRs (ruis-render-{null,opengl,opengles,vulkan}, ruisapp, carcockpit, cod, ruis-sdl-example).