Skip to content

starling-browser/skyline

Repository files navigation

Skyline

Ten lines from an empty Main to a live GPU frame.

Skyline is a WebGPU-first window and GPU library for .NET. It puts a window on screen, hands you a working device and swapchain, and gets out of the way. The rendering stays yours, in raw wgpu.

using var win = new AppWindow(new() { Title = "hello" });
using var gpu = GpuContext.Create(win.Surface);

win.Resized     += f => gpu.Surface!.Configure(f.PixelWidth, f.PixelHeight);
win.RenderFrame += f =>
{
    if (!gpu.Surface!.TryAcquireFrame()) return;   // stale swapchain, retry next frame
    // encode passes against gpu.Surface.CurrentView with raw wgpu (gpu.Api)
    gpu.Surface.Present();
};
return win.Run();

What you get

  • A window in one line. OS chrome, event loop, DPI tracking, and clipboard. Input arrives as plain C# structs — pointer, key, text.
  • The chrome you ask for. Pick standard, fixed, borderless, or transparent with one option. On macOS you get real native chrome — a see-through title bar with content drawn under it. Other platforms get the matching GLFW window. Same code either way.
  • A GPU without the boilerplate. The few hundred lines of unsafe setup every wgpu app starts with — instance, adapter, device, error callbacks that crash if you forget to root them — already written and tested.
  • Resizes that just work. A resize or display change kills the swapchain mid-flight. Skyline catches it, rebuilds, and your next frame lands.
  • Tests that see pixels. Read the presented frame back and assert on it. The sample's smoke test checks its own overlay this way.
  • Idle apps that idle. Nothing changed, nothing renders. The loop sleeps instead of burning a core.
  • Latency that stays flat. FramePacer caps frames in flight, so the CPU can't queue work the GPU hasn't earned. One native call per frame, zero allocation.
  • Windows that don't wait on each other. AppHost runs many windows — one event loop, one render thread each. A window on a 60 Hz monitor never throttles one on a 144 Hz monitor.
  • Nothing locked away. Every raw wgpu handle is one property away. If WebGPU can do it, you still can.

See it run

dotnet run --project samples/HelloWindow

A window, a clear color steered by your pointer, and a text overlay — rendered through the full stack. Space toggles a hue cycle. Escape quits.

Headless checks:

  • --frames N auto-closes after N presented frames (smoke test).
  • --dump-hud prints the text panel as ASCII art to check the built-in pixel font.
  • --verify-hud reads the final frame back from the GPU and asserts the panel's pixels are in the presented image.

Two windows on one device, each with its own render thread:

dotnet run --project samples/TwoWindows

A spiral galaxy as one app-owned full-screen shader — a blazing white core with a light shaft, purple nebulosity, and arms swirled out of millions of slowly turning stars:

dotnet run --project samples/TexturedQuad

An interactive canvas that turns pointer input into dynamic GPU geometry:

dotnet run --project samples/InteractiveCanvas

The approvals overlay from the interaction tier, drawn on top of an app frame. Each prompt says who is asking, what they want, and how long you have to answer — a kind-colored badge, the request in plain words, and a countdown that runs green to red. Answer with the mouse — Allow, Allow once, or Deny. Each answer flashes a banner that says what you chose:

dotnet run --project samples/Approvals

Window chrome

Pick the kind of window with one option:

using var win = new AppWindow(new()
{
    Title = "borderless",
    // Standard, Fixed, Borderless, Transparent, UnifiedTitlebar
    Chrome = ChromeMode.Borderless,
});

On macOS, Transparent is a real native title bar that content draws under, with a see-through backing so the desktop shows behind the window. UnifiedTitlebar is the same merged-toolbar look on a solid window: the traffic lights float over the content and there is no separate top bar. To get either, the app references the Skyline.Apple backend. The core finds it at run time and uses it. There is nothing else to wire up. Set ForceGlfw = true to opt back to the portable window on any platform.

# macOS, needs the macos workload
dotnet run --project samples/TransparentWindow   # drag the slider to change the transparency
dotnet run --project samples/UnifiedTitlebar     # opaque, merged title bar

On Windows and Linux the same ChromeMode maps to the matching GLFW window. A native backend for those platforms can slot into the same seam later.

Tests

Both libraries are at 100% line coverage, from three vehicles:

  • tests/Skyline.Tests and tests/Skyline.Gpu.Tests — MSTest, headless. The GPU tests run against a real device with no window.
  • tests/Skyline.WindowedTests — a console harness for everything that needs a real window. GLFW requires the main thread on macOS, and test runners execute on worker threads, so these checks run as a plain program with an exit code.

Run everything and get the merged report:

./tools/cover.sh

The only excluded lines are native-failure guards (no GPU adapter, no device, surface creation refused) collected in Skyline.Gpu/Guard.cs — they cannot fire on a working machine, and the exclusion is documented there. The macOS backend (src/Skyline.Apple) is a native, Mac-only assembly outside this gate. It builds and runs only on macOS with the macos workload, so it is checked on Apple hardware, not by the line gate. Its decision logic lives in the covered core.

Requirements

  • .NET 10 SDK or later.
  • A GPU. The sample uses wgpu (the native WebGPU implementation) and ships its binary via the Silk.NET.WebGPU.Native.WGPU package.

Design

The rule behind the library: mirror WebGPU, batteries with an eject. Helpers fill WebGPU's own descriptors with overridable defaults, encode only into encoders you pass in, and take and return raw handles — so helper code and raw wgpu mix freely in the same frame. What each project owns, why this beats a renderer abstraction, what Skyline adds over raw Silk.NET, and how present modes and buffering work: ARCHITECTURE.md.

Status

Early. The window host, the WebGPU layer, and the sample are real and tested on macOS. Windows and Linux paths exist through GLFW and wgpu but are not yet exercised. The native macOS chrome backend (Skyline.Apple) is new — it ships the committed-character text path, not full input-method editor composition yet. Planned next: key modifier state, pointer enter and leave, and native backends for Windows and Linux.

License

Apache-2.0. See LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors