Skip to content

Feat/linux cairo vulkan backend - #176

Open
OmarSiwy wants to merge 3 commits into
vercel-labs:mainfrom
OmarSiwy:feat/linux-cairo-vulkan-backend
Open

Feat/linux cairo vulkan backend#176
OmarSiwy wants to merge 3 commits into
vercel-labs:mainfrom
OmarSiwy:feat/linux-cairo-vulkan-backend

Conversation

@OmarSiwy

Copy link
Copy Markdown

See #175

OmarSiwy added 2 commits July 21, 2026 11:33
…ilds to Debug

Zig 0.16.0's self-hosted x86_64 backend mis-lowers the SysV C ABI for wide
mixed signatures — interleaved f32/pointer args and long stack-spilled
parameter lists land a slot off, corrupting safe-area insets and view
descriptors. The build graph worked around this by forcing LLVM on x86_64
for every artifact, which also forced slow Release-style link steps on
Debug rebuilds.

Fix the seams instead of the backend:

- Linux GTK host: create/update view and GPU-surface present cross the seam
  through a single descriptor struct pointer (GtkViewDesc, GtkViewPatch,
  GtkGpuPresentDesc); thin C wrappers unpack them into the existing wide
  functions (C->C, correctly lowered).
- Mobile embed: native_sdk_app_viewport takes one native_sdk_viewport_t
  pointer instead of 11 interleaved f32s. iOS, Android, and the example
  hosts build the struct and pass its address.

With the seams safe, drop the blanket useLlvmWorkaround. App builds default
to Debug (safety checks + markup hot-reload) on Zig's self-hosted backend
for faster rebuilds; Release still uses LLVM. Consumers pick the backend
and optimize mode explicitly through AppOptions/MobileLibOptions.

Not compiled in this environment: the iOS/Android host sources; a mobile
build must confirm they compile against the updated headers.

Signed-off-by: omare <ok.elsawy@gmail.com>
Mirror the macOS backend's two halves on Linux. macOS rasterizes the canvas
on the CPU with Core Graphics / Core Text, then presents through Metal; the
Linux backend does the same with Cairo + Pango and Vulkan.

- Vulkan presenter (native_sdk_vk.c/.h): a gpu_surface view scans out through
  an SDK-owned Vulkan swapchain riding a native child surface the compositor
  composites directly — a wl_subsurface on Wayland or a child InputOutput
  window on X11. The reference renderer's RGBA8 uploads into a canvas image
  and presents via a full-screen quad (shaders compiled inline via shaderc,
  mirroring the Metal host's inline MSL). Falls back to software when no
  Vulkan surface backend applies.
- Cairo/Pango packet renderer (native_sdk_cairo.c, opt-in SCHEMIFY_CAIRO=1):
  an immediate-mode 2D surface driven command-by-command from the canvas
  packet, with payload-structural dispatch — any unpaintable command refuses
  the frame and the runtime falls back to the reference renderer.

Both present through the descriptor-pointer GPU seam, so they draw correctly
under the self-hosted x86_64 backend. root.zig references the Cairo symbols
unconditionally, so every Linux link (framework and each example build.zig)
compiles native_sdk_cairo.c and links freetype2.

Verified: `zig build test-webview-system-link -Dplatform=linux
-Dweb-engine=system` compiles and links gtk_host.c + native_sdk_vk.c +
native_sdk_cairo.c against gtk4 / webkitgtk-6.0 / cairo / pango / vulkan /
shaderc / wayland / x11.

Signed-off-by: omare <ok.elsawy@gmail.com>
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

@OmarSiwy is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

};
VkResult pr = vkQueuePresentKHR(ctx->queue, &pi);
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_SUBOPTIMAL_KHR) {
native_sdk_vk_build_swapchain(v, v->px_width > 0 ? (uint32_t)v->px_width : width, v->px_height > 0 ? (uint32_t)v->px_height : height);

@vercel vercel Bot Jul 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present-path swapchain rebuild destroys in-flight framebuffers/image views without waiting for the GPU to go idle, causing undefined behavior on window resize.

Fix on Vercel

Drop the SCHEMIFY_CAIRO opt-in gate and the SCHEMIFY_CAIRO_DIAG
diagnostic. The Cairo path (box-blur backdrop, pixman fills) is the
accelerated draw path; the reference rasterizer's O(kernel^2) Gaussian
was making every modal/overlay frame ~26ms on the CPU fallback.
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