8 releases
| new 0.5.1 | Apr 13, 2026 |
|---|---|
| 0.5.0 | Apr 10, 2026 |
| 0.4.0 | Apr 5, 2026 |
| 0.1.15 | Mar 22, 2026 |
| 0.1.12 | Jan 19, 2026 |
#240 in Graphics APIs
Used in 5 crates
(4 directly)
2.5MB
48K
SLoC
blinc_gpu
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
GPU renderer for Blinc UI using wgpu with SDF-based rendering.
Overview
blinc_gpu provides high-performance GPU rendering for the Blinc UI framework. It uses Signed Distance Field (SDF) techniques for crisp, resolution-independent rendering of UI primitives.
Features
- SDF Primitives: Rounded rectangles, circles, ellipses with perfect anti-aliasing
- Shadows: Gaussian blur shadows via error function approximation
- Gradients: Linear and radial gradient fills
- Glass/Vibrancy: Backdrop blur effects for frosted glass UI
- Text Rendering: SDF-based text with glyph atlases
- Image Rendering: Efficient texture-based image display
- Compositing: Layer blending with various blend modes
- Cross-Platform: Works on macOS, Windows, Linux, iOS, Android, and WebGPU
Environment Overrides
Use these environment variables to override renderer capacities at startup. Values are clamped to adapter limits.
BLINC_WGPU_MAX_BUFFER_MB: Override wgpumax_buffer_size(MiB), clamped to adapter-supported max.BLINC_GPU_MAX_PRIMITIVES: Override max SDF primitives per batch (clamped by storage buffer binding size).BLINC_GPU_MAX_GLYPHS: Override max glyphs per batch (clamped by storage buffer binding size).BLINC_GPU_MAX_GLASS_PRIMITIVES: Override max glass primitives per batch (clamped by storage buffer binding size).
Architecture
blinc_gpu
├── renderer.rs # Main GpuRenderer
├── primitives.rs # GPU primitive types
├── paint.rs # Paint context implementation
├── text/ # Text rendering pipeline
├── image/ # Image rendering pipeline
├── shaders/ # WGSL shader modules
│ ├── sdf.wgsl # SDF primitive rendering
│ ├── text.wgsl # Text/glyph rendering
│ ├── glass.wgsl # Glass blur effects
│ ├── blur.wgsl # Gaussian blur
│ └── image.wgsl # Image rendering
└── backbuffer.rs # Double/triple buffering
Rendering Pipeline
- Primitive Collection: UI elements converted to
GpuPrimitiveinstances - Batching: Primitives grouped by type and texture
- SDF Rendering: Shapes rendered using signed distance functions
- Compositing: Layers blended in correct order
- Output: Final frame presented to surface
Shader Features
SDF Primitives
// Rounded rectangle with per-corner radius
fn sdf_rounded_rect(p: vec2<f32>, size: vec2<f32>, radii: vec4<f32>) -> f32
// Perfect anti-aliasing at any scale
fn alpha_from_sdf(d: f32) -> f32
Glass Effects
// Frosted glass with backdrop blur
fn glass_blur(uv: vec2<f32>, blur_radius: f32) -> vec4<f32>
// Vibrancy with tint and saturation
fn apply_vibrancy(color: vec4<f32>, tint: vec4<f32>, saturation: f32) -> vec4<f32>
Shadows
// Gaussian shadow via error function
fn shadow_alpha(d: f32, blur: f32) -> f32
Usage
use blinc_gpu::{GpuRenderer, GpuPrimitive};
// Create renderer
let renderer = GpuRenderer::new(&device, &queue, surface_format);
// Create primitives
let rect = GpuPrimitive::rect(0.0, 0.0, 100.0, 50.0)
.with_color(1.0, 0.0, 0.0, 1.0)
.with_corner_radius(8.0)
.with_border(2.0, 1.0, 1.0, 1.0, 1.0);
// Render
renderer.render_primitives(&view, &[rect]);
Performance
- Instanced Rendering: Single draw call for multiple primitives
- Texture Atlasing: Glyphs and icons packed into atlases
- Batch Optimization: Automatic primitive batching
- GPU-side AA: Anti-aliasing computed in shader
Requirements
- wgpu-compatible GPU
- Vulkan, Metal, DX12, or WebGPU backend
License
MIT OR Apache-2.0
Dependencies
~29–69MB
~1M SLoC