shdrlib
- systems for shaders, shaders for systems.β
A three-tiered Vulkan shader compilation and rendering framework built in pure Rust.
π― What is shdrlib?
shdrlib is a backend Vulkan rendering library with a unique three-tier architecture that lets you choose your abstraction level:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β EZ TIER β One-liners with smart defaults β 13x code reduction
β (Easy) β Perfect for learning & prototyping β ~30 lines
ββββββββββββββΌββββββββββββββββββββββββββββββββββββββ€
β EX TIER β β Explicit control, ergonomic APIs β 4-8x code reduction
β (Explicit)β Production-ready, type-safe β ~100 lines
ββββββββββββββΌββββββββββββββββββββββββββββββββββββββ€
β CORE TIER β Thin Vulkan wrappers β Maximum control
β (Control) β For frameworks and engines β ~400 lines
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Features:
- β Pure Rust - No external build tools (uses naga for shader compilation)
- β Zero-cost abstractions - All tiers compile to identical machine code
- β Memory safe - Rust's ownership prevents use-after-free
- β Progressive disclosure - Drop to lower tiers anytime for more control
- β All three tiers complete - CORE, EX, and EZ are production-ready!
This is NOT a game engine - it's a backend library. You bring your own windowing (winit, sdl2, etc.).
π Quick Start
Installation
[]
= "0.1.0"
= "0.38" # For Vulkan types
Your First Triangle (EZ Tier)
Just 30 lines to render with Vulkan:
use *;
That's it! You just rendered a triangle with Vulkan.
π Read the full Quick Start Guide β
π Choose Your Tier
π― EZ Tier - Perfect for Learning
Best for: Prototyping, learning Vulkan, quick demos
// One-liner setup
let mut renderer = new?;
// One-liner pipelines
let graphics = renderer.quick_pipeline?;
let compute = renderer.quick_compute?;
// One-liner buffers
let vertices = renderer.create_vertex_buffer?;
Pros:
- β 13x less code than CORE (30 lines vs 400)
- β Perfect for learning Vulkan
- β Intelligent defaults
- β Hard to misuse
Use when: Learning, prototyping, teaching, demos
π EZ Tier Guide β | π¨ Examples β
β EX Tier - Recommended for Production
Best for: Real applications, games, production code
// Explicit but ergonomic
let mut runtime = new?;
let mut shaders = new?;
let shader_id = shaders.add_shader?;
let pipeline_id = shaders.build_pipeline?;
Pros:
- β 4-8x less code than CORE (100 lines vs 400)
- β Type-safe (ShaderId, PipelineId)
- β Zero-cost abstractions
- β Memory safe
- β Production-ready
Use when: Building apps/games, need safety + control
π EX Tier Guide β | π¨ Examples β
π§ CORE Tier - Maximum Control
Best for: Engine development, custom frameworks
// Direct Vulkan control
let instance = new?;
let device = new?;
let shader = from_glsl?;
Pros:
- β Maximum control
- β Zero overhead
- β Drop down anytime from higher tiers
- β Direct Vulkan access
Use when: Building frameworks, need absolute control
π CORE Tier Guide β | π¨ Examples β
οΏ½ Documentation
π Getting Started
- Quick Start - Your first triangle in 5 minutes
- Installation - Set up your environment
- Choosing a Tier - Which tier is right for you?
- FAQ - Common questions answered
- Troubleshooting - Fix common issues
π Guides
- EZ Tier Guide - High-level API guide
- EX Tier Guide - Production tier guide β
- CORE Tier Guide - Low-level API guide
- Migration Guide - Moving between tiers
ποΈ Architecture
- Overview - Design philosophy
- Three-Tier Design - Why three tiers?
- Zero-Cost Abstractions - Performance details
π API Reference
- Complete Index - Full documentation map
- Run
cargo doc --openfor detailed API docs
π¨ Examples
Run Examples
# EZ tier (learning & prototyping)
# EX tier (production) β Recommended
# CORE tier (advanced)
Example Comparison
| Example | CORE Tier | EX Tier | EZ Tier |
|---|---|---|---|
| Triangle | 400 lines | 100 lines | 30 lines |
| Textured Quad | 400 lines | 50 lines | 35 lines |
| Compute Shader | 300 lines | 75 lines | 25 lines |
Code reduction: 4x to 13x while maintaining identical performance!
π§ͺ Testing
# Run all tests
# Run tier-specific tests
# Run with output
Status: 73 tests passing β (48 CORE + 25 EX)
ποΈ Project Status
| Component | Status | LOC | Tests |
|---|---|---|---|
| CORE Tier | β Complete | ~3,440 | 48 β |
| EX Tier | β Complete | ~3,000 | 25 β |
| EZ Tier | β Complete | ~600 | 3 demos β |
| Documentation | π§ In Progress | - | - |
All three tiers are production-ready! π
πΊοΈ Roadmap
Current Release (v0.1) - Q4 2025
- β CORE tier complete (12 modules)
- β EX tier complete (6 components)
- β EZ tier complete
- β 9 working demos
- π§ Documentation overhaul
Next Release (v0.2) - Q1 2026
- π Performance benchmarks
- π Texture loading from files
- π Enhanced EZ tier features
- π More advanced examples
Future (v0.3+)
- π Ray tracing support
- π Render graph system
- π Multi-threaded recording
- π Advanced profiling
π€ Contributing
We welcome contributions! Please read:
- CONTRIBUTING.md - Contribution guidelines
- Code of Conduct - Be respectful
- Development Workflow - How to contribute
Areas we need help:
- π Documentation improvements
- π§ͺ More test coverage
- π¨ Additional examples
- π Bug fixes
οΏ½ Dependencies
- ash 0.38 - Vulkan bindings
- naga 22 - Pure Rust GLSLβSPIR-V compiler
- spirv-reflect 0.2 - SPIR-V reflection
- thiserror 1.0 - Error handling
No external build tools required! Pure Rust shader compilation.
π§ Requirements
- Rust: Edition 2024 (Rust 1.82+)
- Vulkan: 1.3+ with dynamic rendering support
- OS: Windows, Linux, or macOS
π License
Dual-licensed under MIT or Apache-2.0 (your choice).
See LICENSE-MIT and LICENSE-APACHE.
π Acknowledgments
- ash - Excellent Vulkan bindings for Rust
- naga - Pure Rust shader compilation
- Vulkan - Powerful graphics API
οΏ½ Quick Links
| Resource | Link |
|---|---|
| π Quick Start | QUICKSTART.md |
| π Documentation | docs/README.md |
| π¨ Examples | demos/ |
| π€ Contributing | CONTRIBUTING.md |
| π Roadmap | CHANGELOG.md |
| οΏ½ Issues | GitHub Issues |
| π¬ Discussions | GitHub Discussions |
Ready to render?
Then follow the Quick Start Guide to render your first triangle!
Last Updated: October 30, 2025 | Version: 0.1.0