oxgpu
A lightweight GPU compute library built on wgpu, providing a simple and ergonomic API for GPU-accelerated computing.
Features
- 🚀 Simple API: Easy-to-use interface for GPU compute operations
- 🔧 Type-safe buffers: Generic buffer types with compile-time safety
- 📝 WGSL shaders: Support for WebGPU Shading Language
- ⚡ Async operations: Async/await support for GPU operations
- 🎯 Zero-cost abstractions: Minimal overhead over raw wgpu
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use ;
async
Compute Shader Example
use ;
async
Examples
You can find more examples in the examples/ directory:
- Basic Buffer: Basic buffer creation, writing, and reading.
- Vector Add: Simple vector addition using a compute shader.
- Matrix Multiplication: Matrix multiplication using a compute shader.
To run an example:
API Overview
Core Types
Context: GPU context managing device and queueBuffer<T>: Typed GPU buffer for data storageBufferUsage: Flags for buffer usage (storage, uniform, etc.)ComputeKernel: Compiled compute shaderComputeKernelBuilder: Builder for creating compute kernels
Buffer Operations
Buffer::new()- Create buffer with custom usageBuffer::from_slice()- Create from sliceBuffer::zeros()- Create zero-initialized bufferbuffer.read()- Read data from GPUbuffer.write()- Write data to GPU
Requirements
- Rust 2024 edition
- A GPU with WebGPU support
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.