Snapchat/SnapRHI
À propos
A lightweight, modern Render Hardware Interface (RHI) abstraction layer for C++ SnapRHI provides a clean, unified API that abstracts away the complexity of modern graphics APIs — enabling you to write rendering code once and target multiple backends seamlessly.
Design et médiasProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalSnapRHI
SnapRHI is a cross-platform, low-level graphics abstraction layer — one API, multiple backends, many targets.
It provides a unified interface for modern rendering APIs (Metal, Vulkan, OpenGL/ES), enabling portable, high-performance graphics code. Its own backend-neutral semantics give engine authors explicit control over synchronization, resource lifetimes, and memory management.
Backend Support
| Backend | Platforms |
|---|---|
| Metal | macOS, iOS |
| Vulkan | Windows, Linux, Android, macOS/iOS (MoltenVK) |
| OpenGL/ES | Windows, Linux, macOS, Android, iOS |
WebAssembly: The OpenGL ES backend contains Emscripten code paths but the build system does not yet wire them up. See the Build Guide.
Quick Start
git clone <repo-url>
cd SnapRHI
# Library only — pick a backend
cmake --preset macos-metal # macOS Metal
cmake --preset macos-vulkan # macOS Vulkan (MoltenVK)
cmake --preset linux-vulkan # Linux Vulkan
cmake --preset windows-vulkan # Windows Vulkan
cmake --build build/<preset-name>
# Library + demo app — add "-demo" suffix
cmake --preset macos-metal-demo
cmake --build build/macos-metal-demo
# Or build manually with raw CMake
cmake -B build -DSNAP_RHI_ENABLE_METAL=ON # Library only
cmake -B build -DSNAP_RHI_ENABLE_METAL=ON -DSNAP_RHI_BUILD_EXAMPLES=ON -DSNAP_RHI_DEMO_APP_API=metal # + demo
cmake --build build
# Or use the shell helper (macOS / Linux)
./build.sh # Library only
./build.sh --vulkan --with-demo # Demo app
Run
cmake --list-presetsto see all available configurations.
→ Build Guide — all platforms (macOS, iOS, Windows, Linux, Android), all IDEs (VS Code, CLion, Xcode, Visual Studio, Android Studio), preset-based and raw CMake instructions, validation options, and integration guide.
Documentation
| Document | Description |
|---|---|
| Build Guide | Complete build instructions, IDE setup, CMake options |
| Demo App | Triangle demo application |
| API Overview | Public API documentation |
| Resource Management | Lifetime rules, threading, memory |
| Performance | Architecture for low overhead, profiling guidance |
| Debugging | Validation layers, sanitizers, frame capture |
| Profiling | Performance tools per platform |
Performance
SnapRHI is designed for low-latency, high-throughput rendering. The cost of using the library versus calling Metal, Vulkan, or OpenGL directly is minimal in Release builds.
| Design Decision | Impact |
|---|---|
| Allocation-controlled hot paths | Fixed API limits use inline storage; command buffers pre-reserve retention storage; larger variable workloads grow only when their retained capacity is exceeded |
| Compile-switchable validation | Tag-gated checks use if constexpr and disappear when disabled; only unrecoverable invariant reporting remains compiled |
| Aggressive resource pooling | Fences, command buffers, command pools, framebuffers, and descriptor memory are recycled — not created/destroyed per frame |
| OpenGL state cache | Comprehensive CPU-side state tracking eliminates redundant gl* calls without costly glGet* queries |
final backend classes |
All backend implementations are marked final, enabling the compiler to devirtualize in single-backend builds |
| Two retention modes | Opt out of automatic shared_ptr bookkeeping with UnretainedResources; recording then pays only a mode check per tracked resource |
Deep dive: docs/performance.md — overhead budget per operation, per-backend optimization details, validation cost model, and profiling guidance.
Integration
add_subdirectory(SnapRHI)
target_link_libraries(your_app PRIVATE
snap-rhi::public-api
snap-rhi::backend-metal # or backend-vulkan, backend-opengl
)
License
MIT — see LICENSE.md
Explorer des projets similaires
Chargement…