WGVK
A self-contained high-performance WebGPU implementation on Vulkan
git clone https://github.com/manuel5975p/WGVK.gitmanuel5975p/WGVKWGVK
A standalone, single-file, fully feature-conformant implementation WebGPU API in C11, built on top of Vulkan 1.1. WGVK is designed for easy integration into C/C++ projects, providing a modern graphics and compute API without the steep learning curve of raw Vulkan.
Implementation progress
- ▓▓▓▓▓▓▓▓▓▓ 100% WebGPU Conformity
- ▓▓▓▓▓▓▓▓░░ 80% WGSL Reflection
- ▓▓▓▓▓░░░░░ 50% HW Raytracing according to Dawn-RT
For more detailed insights, join us on Discord
Features
- Full WebGPU API: A modern interface for graphics and compute pipelines.
- Single Implementation File: Simply drop
wgvk.cand theincludedirectory into your project. - Cross-Platform Window System Integration:
- Windows (Win32)
- macOS (Metal)
- Linux (X11 & Wayland)
- Optional Memory Allocator: Integrates with the excellent Vulkan Memory Allocator for optimized memory management (requires C++).
- CMake Build System: Easy to configure and build the library and examples.
- Dependency-Free Core: The core library has no external dependencies for basic operation. GLFW is fetched by CMake for the examples.
Building
wgvk.c contains all implementations. Adding it to your compilation command line is already enough.
gcc src/wgvk.c your_file.c -I include
However, the recommended way to build is with CMake, which will also build the examples and configures platform-specific windowing options.
Prerequisites
- A C99 compatible compiler (GCC, Clang, MSVC)
- A Vulkan 1.1+ Driver (the SDK is not required)
- CMake (version 3.19 or newer)
- Linux:
pkg-configand development libraries for X11 (libx11-dev) and/or Wayland (libwayland-dev). - MacOS: MoltenVK capable of Vulkan 1.1.
CMake Build (Recommended)
-
Clone the repository:
git clone https://github.com/manuel5975p/WGVK cd wgvk
-
Configure and build with CMake:
mkdir build cd build cmake .. cmake --build .
The example binaries will be located in the
builddirectory. -
CMake Options:
- Enable VMA for better memory management:
cmake .. -DWGVK_USE_VMA=ON - Disable building examples:
cmake .. -DWGVK_BUILD_EXAMPLES=OFF
- Enable VMA for better memory management:
Manual Build (Simple Example)
For a quick test without dependencies, you can compile a basic example directly with GCC/Clang:
# Note: This simple command does not link against platform-specific libraries # for windowing and is best for compute-only examples. gcc examples/basic_compute.c src/wgvk.c -O3 -I include -o basic_compute
Or, if you are building with Visual Studio:
cl examples\basic_compute.c src\wgvk.c -O2 -DNDEBUG -I include /std:c11 /experimental:c11atomics cl examples\rgfw_surface.c src\wgvk.c -O2 -DNDEBUG -I include /std:c11 /experimental:c11atomics
Examples
The examples/ directory contains sample code to get you started:
basic_compute.c: Demonstrates a simple compute shader workflow.glfw_surface.c: Shows how to create a window with GLFW and render a triangle.rgfw_surface.c: Shows how to create a window with RGFW and render a triangle,
Run them from the build directory after compiling:
./basic_compute ./glfw_surface
Integrating into Your Project
You can use WGVK in two main ways:
- As a Library: Use CMake to build
wgvkas a static library and link it into your project. - Source Inclusion: Copy
src/wgvk.cand theinclude/directory into your project's source tree and compile them alongside your own code.
License
This project is licensed under the MIT License - see the LICENSE file for details.
more like this
aperture
WebGPU-only, ECS-native 3D runtime where simulation is authoritative and rendering is a derived view.