memkit-gpu
Backend-agnostic GPU memory management for the memkit ecosystem.
Version: 0.1.0-alpha.1
Overview
memkit-gpu provides a unified GPU memory management API that works across different graphics backends. Write your code once, run it on Vulkan, Metal, or DirectX 12.
Features
- Backend-Agnostic — Same API works across all GPU backends
- Staging Buffers — Efficient CPU → GPU data transfers
- Device Buffers — Fast device-local memory
- Batch Transfers — Coalesce multiple transfers for efficiency
- Memory Pools — Reuse GPU buffers to reduce allocation overhead
Quick Start
use ;
// Create GPU allocator (using dummy backend for testing)
let gpu = new;
// Create staging buffer and upload data
let vertices: & = &;
let staging = gpu.staging_buffer_with_data.unwrap;
// Create device-local buffer
let device = gpu.create_device_buffer.unwrap;
// Transfer data
gpu.transfer.unwrap;
Backend-Agnostic Code
use ;
// Generic function works with ANY backend
Backends
| Backend | Feature Flag | Status |
|---|---|---|
| Dummy (CPU simulation) | (default) | ✅ Ready |
| Vulkan | vulkan |
✅ Ready |
| Metal | metal |
🚧 Planned |
| DirectX 12 | dx12 |
🚧 Planned |
Dummy Backend
The dummy backend simulates GPU operations in CPU memory. Useful for:
- Unit testing without a GPU
- Running on systems without GPU support
- Prototyping before implementing a real backend
use ;
// Default config
let backend = new;
// Custom config
let config = DummyBackendConfig ;
let backend = with_config;
Vulkan Backend
Requires the vulkan feature flag. Uses ash and gpu-allocator.
[]
= { = "0.1.0-alpha.1", = ["vulkan"] }
use ;
let config = VulkanConfig ;
let backend = new?;
let gpu = new;
Types
| Type | Description |
|---|---|
MkGpu<B> |
Main GPU allocator, generic over backend |
MkDeviceBuffer<B> |
Device-local buffer |
MkStagingBuffer<B> |
CPU-accessible staging buffer |
MkGpuTransfer |
Pending transfer operation |
MkGpuPool<B> |
Buffer pool for reuse |
MkMemoryType |
Memory type classification |
MkBufferUsage |
Buffer usage flags |
License
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE.md file for details.