Skip to content

koubaa/goldy

Repository files navigation

Goldy Logo

Goldy: Modern GPU Library

License: LGPL v2.1+

A modern Rust GPU library that deliberately sheds legacy baggage. Goldy targets only modern GPU APIs (Vulkan 1.4+, DX12, Metal Tier2+) and can therefore be significantly simpler than libraries that must maintain backward compatibility.

Quick Example

use goldy::{Color, DeviceType, Instance, RenderTarget, TaskGraph, TextureFormat};

fn main() -> anyhow::Result<()> {
    let instance = Instance::new()?;
    let device = instance.create_device(DeviceType::DiscreteGpu)?;
    let ctx = device.create_context()?;

    let target = RenderTarget::new(&device, 800, 600, TextureFormat::Rgba8Unorm)?;
    let mut graph = TaskGraph::new();
    let mut pass = graph.render_pass("clear", &target);
    pass.clear(Color::CORNFLOWER_BLUE);
    pass.finish_recorded();
    graph.dispatch(&ctx)?;

    let _pixels = target.read_to_cpu()?;
    Ok(())
}

Features

Attribute Description
Rust-native Idiomatic Rust API, not a wrapper around C
Modern-only Vulkan 1.4+, DX12, Metal Tier 2
Slang shaders Single shader language for all backends
Unified Graphics and compute in one API

Installation

[dependencies]
goldy = "0.1"

Slang Compiler

Goldy uses Slang for shader compilation. The Rust build.rs downloads (if needed) and embeds the pinned Slang version at compile time; at runtime Goldy extracts and loads it automatically. Application developers do not install Slang separately.

  • Set GOLDY_SLANG_PATH only to override with a custom Slang build
  • slang/download.sh is for maintainers bumping the pinned Slang version in slang/manifest.json, not for normal project setup

Release packaging for Python wheels and FFI redistributions is described in PACKAGING.md. See DEBUGGING.md if shader compilation fails at runtime.

Optional Rust vs Slang struct layout checks at shader compile time: set GOLDY_VALIDATE_LAYOUTS=1 and pass LayoutCheck data from #[derive(LayoutCheckable)] into ShaderModule::from_slang_with_options (see DEBUGGING.md and the gradient / checkerboard examples).

Documentation

📖 Full Documentation

Examples

Run the interactive examples:

cargo run --example triangle --release      # Basic triangle
cargo run --example digital_clock --release # 7-segment clock
cargo run --example plasma --release        # Demoscene plasma
cargo run --example mandelbrot --release    # Fractal explorer
cargo run --example starfield --release     # 3D starfield
cargo run --example particles --release     # Rain/snow

Selecting a Backend

By default, Goldy uses DX12 on Windows and Vulkan on Linux. Override with GOLDY_BACKEND:

# Run with Vulkan backend (on Windows)
GOLDY_BACKEND=vulkan cargo run --example triangle --release

# Run with DX12 backend
GOLDY_BACKEND=dx12 cargo run --example triangle --release

See all examples.

Motivation

Goldy is inspired by Sebastian Aaltonen's "No Graphics API" vision of what's possible with modern GPU hardware. By targeting only modern GPUs (2018+), Goldy can:

  • Use dynamic rendering (no render pass objects)
  • Use bindless descriptors (no descriptor sets)
  • Assume coherent caches (simpler synchronization)
  • Provide a dramatically simpler API

Goldy is also inspired by:

Read more in Design Philosophy.

Target Hardware

Platform Minimum
NVIDIA RTX 2000 / GTX 1600 (2018+)
AMD RDNA 1 / RX 5000 (2019+)
Intel Xe / Alchemist (2022+)
Apple M1 / A14 (2020+)

Development

Before submitting a PR, run the CI checks locally:

cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo test

License

Goldy is dual-licensed:

  • Open sourceGNU Lesser General Public License v2.1 or later (LGPL-2.1-or-later). You may use, modify, and distribute Goldy as a dynamically linked library in any project, including proprietary software, under the terms of the LGPL.
  • Commercial — A commercial license is available for use cases where LGPL terms are not suitable (static linking, proprietary modifications, embedded distribution without LGPL obligations, etc.). Contact [koubaa at github](permanent email TBD) for terms.

Author

Mohamed Koubaa

About

Runtime for GPU accelerated compute

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors