Skip to content

glue: create one shared render factory per application - #29

Open
igagis wants to merge 22 commits into
mainfrom
ren_factory
Open

igagis wants to merge 22 commits into
mainfrom
ren_factory

Conversation

@igagis

@igagis igagis commented Nov 19, 2026

Copy link
Copy Markdown
Member

Follow-up to cppfw/ruis#190 (render context redesign).

Each platform glue (linux xorg/wayland, sdl, ios, android, windows, macos) now creates a single shared render factory (the shared/headless render context) in the application constructor and passes it into every per-window context and the resource loader. The shared-context member (resource_loader_ruis_rendering_context) is renamed to render_factory (shared_ref<const factory>) and the common_shaders type becomes factory::shaders.

The test app's cube widget is updated to create its geometry via the factory.

Depends on cppfw/ruis#192 and the renderer PRs.

Follow-up to ruis issue #190: each platform glue now creates a single
shared render factory (the shared/headless render context) in the
application constructor and passes it into every per-window context and
the resource loader. The shared-context member
(resource_loader_ruis_rendering_context) is renamed to render_factory
(shared_ref<const factory>) and the common_shaders type becomes
factory::shaders.
…ry member

Follows the ruis context::factory member -> factory() method change.
Refs cppfw/ruis#190
Wire up ruis-render-vulkan as a selectable renderer backend for the Linux
Xorg and Wayland backends, built on the shared render factory introduced
by the factory refactor (this is the Vulkan integration rebased from the
pre-factory 'vulkan' branch onto 'ren_factory').

- Add Vulkan variants of each Linux ruisapp library (ruisapp-vulkan-xorg,
  ruisapp-vulkan-wayland), built only when the ruis-render-vulkan package
  is available so the rest of the package keeps working until it is
  released.
- A single shared ruis::render::vulkan::factory (created from a headless
  surface provider, since Vulkan has no 'current context' and all GPU
  resources live on the VkDevice) is used for resource loading, shaders
  and common render objects.
- Each window creates its own VkSurface (Xlib or Wayland) plus a per-window
  vulkan::context bound to that surface and the shared factory.
- Add a Vulkan-native window implementation (vulkan_window.hxx) with proper
  WM_DELETE_WINDOW handling and an XFlush on destroy.
- Harden window lifecycle: destroy_window() no longer asserts when the
  window is already gone, and mouse button events send a move first so the
  GUI knows the pointer position.

Adapted to the factory API: contexts now take the shared factory,
and common_shaders/common_render_objects come from the factory.
- Extract graphics-agnostic X11 window base class (xorg_window.hxx):
  window creation, input, cursor management, display handling.
- GL leaf (window.hxx) now uses multiple inheritance:
  gl_visual_info (FBConfig + visual) + xorg_window (X11 base).
- Vulkan leaf (vulkan_window.hxx) simplified to ~80 lines:
  inherits xorg_window, uses default visual, adds present_func.
- Fix Wayland: create_egl_surface() now calls bind_rendering_context()
  so the EGL surface is bound even when the context is already current.
Comment thread build/cmake/CMakeLists.txt Resolved
Comment thread build/cmake/CMakeLists.txt Resolved
Comment thread build/cmake/CMakeLists.txt Resolved
Comment thread build/cmake/CMakeLists.txt Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread src/ruisapp/glue/linux/xorg/glue.cxx Resolved
Comment thread tests/app/src/cube_widget.cpp Resolved
Comment thread tests/app/src/text_input_window.cpp Resolved
- Remove Vulkan build gating from CMake (always build/export/declare vulkan variants)
- Change vulkan_device from unique_ptr to shared_ref (wayland + xorg)
- Remove vulkan_surface_provider member, construct null surface locally for factory
- Rename window.hxx to opengl_window.hxx
- Change negative #ifndef RUISAPP_RENDER_VULKAN to positive conditions
- Add explanatory comments (present_func, surface extensions, VU_CHECK,
  concrete factory, window mapped roundtrip, egl_dummy_surface)
- Remove unnecessary curly brackets in ConfigureNotify case
- Remove unnecessary send_mouse_move calls in ButtonPress/ButtonRelease
- Remove unused destroy_x11_window() from xorg_window
- Use ctx().ren().ctx().fac() shortcuts in test app
Comment thread build/cmake/CMakeLists.txt Resolved
- Remove ruisapp_export_targets list, pass targets directly to myci_export()
- Capture window by reference instead of raw pointer in close_handler
- Use make_shared for vulkan_device (ctor is now public)
- Update surface_provider references to surface
- Extract make_vulkan_device() helper (make_shared doesn't work with
  brace-enclosed initializer lists)
… Wayland window to base + per-API leaves

- Split opengl_window.hxx into opengl_window.hxx (GLX) and opengles_window.hxx (EGL)
- Create wayland_window.hxx (base), opengles_window.hxx (GLES leaf), vulkan_window.hxx (Vulkan leaf)
- Update includes and constructor signatures
…ntext

The shared_gl_context_native_window member is a shared_ref (cannot be null).
For Vulkan, it was being set to nullptr, causing an assertion failure. Now
a 1x1 hidden window is created for all APIs.
…c_cast

Create the Vulkan render context before the ruis::context so we can save a
pointer to it directly (owner_context) without a static_cast downcast.
- Store concrete factory type (no dynamic_cast needed)
- Create render context before ruis::context for all APIs
- Rename vulkan_ctx to render_context
- Move owner_context assignment to right after render context creation
- Remove answered review comments
…indows

- window.cpp calls render context's swap_frame_buffers() instead of
  native window's
- Removed owner_context pointer and swap_frame_buffers() override from
  Vulkan native windows (Xorg + Wayland) — the context handles presentation
- xdg_surface.cxx: moved swap_frame_buffers() call out of #ifdef since it
  is now identical for GL and Vulkan paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant