Skip to content

Pipeline: move the methods to a static vtable, call them through pl_* helpers - #35

Merged
resetius merged 1 commit into
masterfrom
objmodel-pipeline
Nov 7, 2026
Merged

resetius merged 1 commit into
masterfrom
objmodel-pipeline

Conversation

@resetius

@resetius resetius commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

PRs 31–34 are merged; this PR is now a single commit on master.

Part of the object model change from the tracker task: one vtbl pointer per object to a static const method table, like a C++ vptr.

What changed:

  • render/pipeline.h: new struct PipelineVtbl with the same 10 methods. struct Pipeline now holds only const struct PipelineVtbl* vtbl.
  • Call helpers (one-line macros) with the existing pl_ prefix for all 10 methods. The 7 old wrapper functions (pl_free, pl_start, pl_draw, ...) keep their names and became macros, so render/pipeline.c is empty and is removed (CMakeLists.txt and Makefile updated). New helpers: pl_storage_swap, pl_start_compute, pl_draw_indexed.
  • opengl/pipeline.c and vulkan/pipeline.c: one static const struct PipelineVtbl pipeline_vtbl before build(), with exactly the fields of the old literal (storage_assign still points to uniform_assign in both). build() sets pl->base.vtbl = &pipeline_vtbl.
  • Callers: 134 calls in the models and font/font.c. Two commented-out calls are left as they are. PipelineBuilder is not changed here.

Size of the struct Pipeline part on 64-bit: 80 bytes before, 8 bytes after (up to 11 pipelines in particles3).

No behavior change.

Verification (macOS, AppleClang, CMake + Ninja):

  • Clean rebuild: no new warnings (the same 5 as on master: one in contrib/astc-codec, four from glslc).
  • ctest: 3/3 passed.
  • Vulkan demos with VK_LAYER_KHRONOS_validation (layer load confirmed with VK_LOADER_DEBUG=layer), 10 s each: particles3, mandelbrot, stl, 0 validation messages.
  • Local test build of main.c (not in this PR): at frame 30 it sends key presses and releases for LEFT, RIGHT, UP, DOWN, A, Z, TAB and two mouse moves through the normal GLFW callbacks, then leaves the main loop after 8 s, so all free functions run. Vulkan particles3, mandelbrot, stl, gltf, triangle, torus, mandelbulb, particles, particles2 and OpenGL mandelbrot, stl, torus, triangle, mandelbulb, particles2: all exit with code 0. The logs are the same as on master after removing timings, FPS and pointer values (same buffer allocations, same validation output). On master, stl, gltf and triangle already report leaked objects at vkDestroyDevice (one message each); nothing else is reported.
  • particles3 compute time and FPS are the same as on master (compute Total about 7.9 ms, 120 FPS with vsync).

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Test Results

9 tests  ±0   9 ✅ ±0   0s ⏱️ ±0s
3 suites ±0   0 💤 ±0 
3 files   ±0   0 ❌ ±0 

Results for commit 5846bb1. ± Comparison against base commit dc5812a.

♻️ This comment has been updated with latest results.

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Independent review of head 724b798 (stack head 29-35)

Verdict: approve. No P1/P2/P3 findings.

  • OpenGL and Vulkan pipeline_vtbl have the same 10 members as the old initializers. The pre-existing .storage_assign = uniform_assign in both backends is preserved (not changed here, so no behavior change).
  • render/pipeline.c removed from CMakeLists.txt and Makefile. The 143 call-site lines in models and font were checked by a script: each new pl_M(A, args) equals the old A->M(A, args) exactly. Macro args are t->pl, t->nodes[i].pl, f->pl, etc.: no side effects. New macros pl_storage_swap, pl_start_compute, pl_draw_indexed are added for completeness.

Build: clean CMake+Ninja (Release, -Wall -Wextra) of this head on a fresh SSH clone with submodules: builds, 98 warnings, identical set to master (no new warnings); ctest 3/3 passed.
Also built every intermediate head 29..35 and 36: each builds with the same 98 warnings and ctest 3/3.
Demos (Vulkan/MoltenVK, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, loader debug confirmed the layer is loaded): particles3, mandelbrot, stl, 10 s each, then killed, no processes left. 0 validation messages, ~120 FPS, RSS flat. STL demo used a generated 2048-triangle sphere (no .stl in the repo).
Run on this head (contains 29-34).

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked on the updated PR 34; review only the last commit

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master eff69ca after PR 29

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master b76fe0a after PR 30.

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master a33ca6c after PR 31.

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master 4a501de after PRs 31–32.

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master 02aa325 after PRs 31–33.

@resetius

resetius commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Restacked onto master dc5812a after PRs 31–34.

@resetius
resetius merged commit 1a25e34 into master Nov 7, 2026
2 checks passed
@resetius
resetius deleted the objmodel-pipeline branch November 7, 2026 16:38
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