Skip to content

Add LowLevelDemo: ThorVG rasterising into an Evergine texture - #3

Merged
jcant0n merged 1 commit into
mainfrom
feat/lowlevel-demo
Aug 16, 2026
Merged

Add LowLevelDemo: ThorVG rasterising into an Evergine texture#3
jcant0n merged 1 commit into
mainfrom
feat/lowlevel-demo

Conversation

@jcant0n

@jcant0n jcant0n commented Aug 16, 2026

Copy link
Copy Markdown
Member

Validation-by-usage before the first publish, mirroring MuJoCo.NET's demo — with the roles inverted: ThorVG is a CPU rasteriser, so it supplies finished pixels and Evergine's low-level API does the upload-and-present bridge (per-frame UpdateTextureData + fullscreen SV_VertexID triangle, the engine's video-player pattern).

The animated scene exercises the API corners the headless Test cannot: Tvg_Color_Stop[] gradients, Tvg_Matrix transforms, parallel command/point path arrays, float[] dash patterns, Lottie loaded from memory through the byte* payload path, and the animation API driven by wall clock. Runs at 120 fps.

One generator fix fell out of writing it: TVG_PATH_COMMAND_* lives in an anonymous enum behind typedef uint8_t Tvg_Path_Command, which the generator dropped entirely. Anonymous enum members now land in Constants.cs, per the C2CSharpBinding spec. Caught before first publish.

Verified live: window sustains 120 fps, and PrintWindow captures show the scene animating between frames with correct colors — confirming the ABGR8888 → R8G8B8A8_UNorm byte mapping needs no swizzle.

Drives the binding the way an application would, which is the half the
headless Test cannot reach: per-frame animation, the array-marshalling
corners of the API, and a CPU buffer shared with the GPU at the window's
refresh rate.

The roles are the inverse of MuJoCo.NET's demo. There Evergine drew
geometry and the native library supplied transforms; here ThorVG supplies
finished pixels -- it is a CPU rasteriser -- and Evergine's job is the
upload-and-present bridge: UpdateTextureData each frame into a
Default-usage texture and a fullscreen SV_VertexID triangle, the same
pattern as the engine's video player and ComputeTextureTest.

The scene exercises, per frame at 120 fps on this machine:

- tvg_gradient_set_color_stops with a Tvg_Color_Stop[] (struct array)
- tvg_paint_set_transform with Tvg_Matrix by pointer (9-float struct)
- tvg_shape_append_path with parallel byte[] command / Tvg_Point[] arrays
- tvg_shape_set_stroke_dash with a float[] pattern
- tvg_picture_load_data from memory (the byte* payload path)
- tvg_animation_set_frame driven by wall clock against
  tvg_animation_get_total_frame / get_duration out-params

ABGR8888 maps byte-for-byte to Evergine's R8G8B8A8_UNorm on
little-endian, and ThorVG writes row 0 at the top, so there is no swizzle
and no flip anywhere.

The generator gained one fix the demo forced: TVG_PATH_COMMAND_* lives in
an anonymous enum behind `typedef uint8_t Tvg_Path_Command`, which the
generator used to drop entirely. Anonymous enum members are standalone
constants and now land in Constants.cs, per the C2CSharpBinding spec.
Caught before first publish, so no released surface changes.

Assets/animation.lot is test/resources/test5.lot from thorvg v1.1.0, MIT.
@github-actions

Copy link
Copy Markdown
Contributor

API gate: additive

Every symbol that existed still exists, unchanged. Nothing that compiled before stops compiling.

Target framework Added Removed
net10.0 +4 -0

Enum and constant values are part of the measured surface: a renumbering keeps compiling and sends the wrong number to the driver, so it counts as a removal.

@jcant0n
jcant0n merged commit 72751ed into main Aug 16, 2026
5 checks passed
@jcant0n
jcant0n deleted the feat/lowlevel-demo branch August 16, 2026 06:40
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