Graphics: Vulkan renderer, native windows, input model and frame tooling #9

Open
agent wants to merge 5 commits from Graphics into master
Collaborator

Base: master @ ee08249. Five commits, authored by agent. Graphics only — no changes outside Graphics/.

Why

Graphics was a GLFW/OpenGL window with a small canvas. The ported applications need a Vulkan renderer, native Wayland and Android windows, high-rate input, and the frame-level tooling that used to sit in Modules (profiler, hang watchdog) and that review moved here because the application loop is their only user.

Commits

  1. Platform-independent input model — input codes, pointer samples, motion coalescing, input recording/replay, key mapping, platform queries, two-finger touch gestures. No window-system dependency; unit-tested.
  2. Vulkan context with Wayland and Android windows — VulkanContext owns instance, device, swapchain, depth-stencil and frames in flight, rebuilding the swapchain on surface changes. Native Wayland backend (xdg-shell, fractional scale, pointer gestures, cross-thread wake-up) and Android backend on native_app_glue, behind PlatformWindow. Also RenderTargetRegistry, GpuTimer, WindowFrame.
  3. NanoVG canvas and ImGui on Vulkan — Canvas uses the NanoVG Vulkan backend from Externals (#8), showing render targets via nvgCreateImageFromHandleVk / nvgUpdateImageFromHandleVk. Bundled fonts with symbol/emoji fallbacks and a glyph-coverage test. Debug GUI on the ImGui Vulkan backend.
  4. Frame profiler, hang watchdog and session recording — profiler with section and counter channels only (GPU time is just another section); hang watchdog with scope trail, thread stacks from Callstack, blocked/busy verdict and debugger-pause handling; session recording. The UI scope trail is private to Graphics.
  5. Build targets, examples, README — GraphicsInput / GraphicsVulkan / Graphics libraries, ExampleGraphics, OffscreenProof.

Adjustments for current master

  • The port's MODULES_BUILD_DESKTOP / MODULES_BUILD_TESTS / MODULES_BUILD_EXAMPLES gates are replaced by ANDROID checks — those options do not exist on master.
  • The desktop app id comes from cmake/DesktopEntry.cmake in the port; until that lands it is set directly (online.ilushabasic.modules).
  • TestGraphics now compiles Profiler.cpp (link error otherwise).
  • The font-coverage test skips UI source directories that do not exist yet (Taskboard/) and no longer asserts on an arrow glyph that only the new Widgets uses.

Verification

Full CMake configure of the repository; Graphics, TestGraphics, ExampleGraphics and OffscreenProof build.

TestGraphics: Success: 74 tests passed.

A full ninja -k 0 of the repository fails only in Connection (asio from_string) and the old Widgets — both fail identically on unmodified master, so this PR adds no breakage. The old Widgets is replaced in the Widgets PR.

No windowed or GPU runtime test was run.

**Base:** `master` @ `ee08249`. Five commits, authored by `agent`. Graphics only — no changes outside `Graphics/`. ## Why Graphics was a GLFW/OpenGL window with a small canvas. The ported applications need a Vulkan renderer, native Wayland and Android windows, high-rate input, and the frame-level tooling that used to sit in `Modules` (profiler, hang watchdog) and that review moved here because the application loop is their only user. ## Commits 1. **Platform-independent input model** — input codes, pointer samples, motion coalescing, input recording/replay, key mapping, platform queries, two-finger touch gestures. No window-system dependency; unit-tested. 2. **Vulkan context with Wayland and Android windows** — `VulkanContext` owns instance, device, swapchain, depth-stencil and frames in flight, rebuilding the swapchain on surface changes. Native Wayland backend (xdg-shell, fractional scale, pointer gestures, cross-thread wake-up) and Android backend on `native_app_glue`, behind `PlatformWindow`. Also `RenderTargetRegistry`, `GpuTimer`, `WindowFrame`. 3. **NanoVG canvas and ImGui on Vulkan** — `Canvas` uses the NanoVG Vulkan backend from Externals (#8), showing render targets via `nvgCreateImageFromHandleVk` / `nvgUpdateImageFromHandleVk`. Bundled fonts with symbol/emoji fallbacks and a glyph-coverage test. Debug GUI on the ImGui Vulkan backend. 4. **Frame profiler, hang watchdog and session recording** — profiler with section and counter channels only (GPU time is just another section); hang watchdog with scope trail, thread stacks from `Callstack`, blocked/busy verdict and debugger-pause handling; session recording. The UI scope trail is private to Graphics. 5. **Build targets, examples, README** — `GraphicsInput` / `GraphicsVulkan` / `Graphics` libraries, `ExampleGraphics`, `OffscreenProof`. ## Adjustments for current master - The port's `MODULES_BUILD_DESKTOP` / `MODULES_BUILD_TESTS` / `MODULES_BUILD_EXAMPLES` gates are replaced by `ANDROID` checks — those options do not exist on master. - The desktop app id comes from `cmake/DesktopEntry.cmake` in the port; until that lands it is set directly (`online.ilushabasic.modules`). - `TestGraphics` now compiles `Profiler.cpp` (link error otherwise). - The font-coverage test skips UI source directories that do not exist yet (`Taskboard/`) and no longer asserts on an arrow glyph that only the new Widgets uses. ## Verification Full CMake configure of the repository; `Graphics`, `TestGraphics`, `ExampleGraphics` and `OffscreenProof` build. ``` TestGraphics: Success: 74 tests passed. ``` A full `ninja -k 0` of the repository fails only in `Connection` (asio `from_string`) and the old `Widgets` — **both fail identically on unmodified master**, so this PR adds no breakage. The old Widgets is replaced in the Widgets PR. No windowed or GPU runtime test was run.
agent added 5 commits 2026-10-28 01:00:35 +03:00
Input codes, pointer samples and window input events shared by every
platform, plus the pieces built on them: coalescing of high-rate pointer
motion, recording and replay of input sessions, key mapping, platform
capability queries and two-finger touch gestures (pan, pinch, rotate).
None of it depends on a window system, so it is unit-tested directly.
Replaces the GLFW/OpenGL window with a Vulkan renderer. VulkanContext owns
the instance, device, swapchain, depth-stencil and frames in flight, and
rebuilds the swapchain when the surface changes. Windows are native: a
Wayland backend (xdg-shell, fractional scale, pointer gestures, wake-up
from other threads) and an Android backend on native_app_glue, both behind
PlatformWindow. Window input is routed through WindowInputDispatcher.

RenderTargetRegistry lets offscreen render targets be shown inside the 2D
canvas, GpuTimer measures GPU time per frame, and WindowFrame computes the
client-side window frame.
Canvas draws through the NanoVG Vulkan backend from Externals and shows
registered render targets with nvgCreateImageFromHandleVk, repointing them
on resize with nvgUpdateImageFromHandleVk. Text uses bundled faces (regular,
bold, mono, math) with symbol, special-character and emoji fallbacks; a
test checks that every bundled face loads and that characters used in UI
sources have a glyph. The debug GUI uses the ImGui Vulkan backend with its
own platform layer instead of the GLFW backend.
The application loop marks its phases and frames:

- Profiler samples section durations and counters per frame (wall and CPU
  time, mean/median/p95/p99). GpuTimer reports into the same section
  channel, so there is no GPU-specific API.
- HangWatchdog writes a report when a non-idle phase stalls: open scope
  trail, input count, thread stacks sampled through Callstack, and a
  blocked/busy verdict. Debugger pauses are not counted as hangs. The scope
  trail is private to Graphics.
- SessionRecording captures input and per-frame profiles for replay.

These live in Graphics because GraphicApplication owns the frame loop and
is their only user.
Graphics: build targets, examples and README
Some checks are pending
Windows / build (pull_request) Waiting to run
CMake on a single platform / build (pull_request) Waiting to run
CMake / build (pull_request) Waiting to run
f8291c3eb1
Splits the module into GraphicsInput (platform-free input), GraphicsVulkan
(context and frame core) and Graphics (windowed application). Graphics links
NanovgVk, Imgui, Callstack and Threads; desktop builds use Wayland, Android
builds use native_app_glue. The port's MODULES_BUILD_* gates are replaced by
ANDROID checks because those options do not exist on master.

ExampleGraphics shows the windowed application, OffscreenProof renders
NanoVG into an offscreen image, and the README describes the layers.
requested review from ilusha 2026-10-28 01:00:36 +03:00
Some checks are pending
Windows / build (pull_request) Waiting to run
CMake on a single platform / build (pull_request) Waiting to run
CMake / build (pull_request) Waiting to run
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Graphics:Graphics
git checkout Graphics

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout master
git merge --no-ff Graphics
git checkout Graphics
git rebase master
git checkout master
git merge --ff-only Graphics
git checkout Graphics
git rebase master
git checkout master
git merge --no-ff Graphics
git checkout master
git merge --squash Graphics
git checkout master
git merge --ff-only Graphics
git checkout master
git merge Graphics
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ilusha/Modules#9
No description provided.