Skip to content
forked from meta/igl

About

LightweightVK is a deeply refactored bindless-only fork of https://github.com/meta/igl. It provides a lean cross-platform graphics API running on top of Vulkan 1.3.

Resources

Code of conduct

Contributing

Stars

492 stars

Watchers

14 watching

Forks

 
 

Repository files navigation

LightweightVK Build Status

LightweightVK is a deeply refactored bindless-only fork of IGL which is designed to run on top of Vulkan 1.3 with optional mesh shaders and ray tracing support.

The main goals of LightweightVK:

  1. Lean. Minimalistic API without bloat (no std::vector, std::unordered_map etc in the API).
  2. Bindless. Utilize Vulkan 1.3+ dynamic rendering, descriptor indexing, and buffer device address features for modern bindless-only API design. Ray tracing features are fully integrated with the bindless-only design.
  3. Agile. A playground for experiments to enable quick exploration of ideas and adoption of Vulkan API changes.
  4. Multilingual. In addition to raw SPIR-V, there's built-in support for Glslang (GLSL) and Slang shaders, which is invaluable for rapid prototyping.

Designed for rapid prototyping of modern Vulkan-based renderers.

There are no plans to keep this fork in sync with the IGL upstream, since the API was completely redesigned in a bindless manner.

Discord: https://discord.com/invite/bEyHyKCrvq

Supported rendering backends

  • Vulkan 1.3 (Windows, Linux, MacOS, Android)
    • mandatory VK_KHR_dynamic_rendering_local_read
    • mandatory VK_KHR_maintenance5
    • mandatory VK_KHR_push_descriptor
    • mandatory VK_EXT_surface_maintenance1
    • optional VK_KHR_maintenance6
    • optional VK_KHR_acceleration_structure
    • optional VK_KHR_ray_tracing_pipeline
    • optional VK_KHR_ray_query
    • optional VK_KHR_opacity_micromap (requires VK_KHR_device_address_commands)
    • optional VK_KHR_fragment_shading_rate
    • optional VK_KHR_cooperative_matrix
    • optional VK_EXT_fragment_density_map
    • optional VK_EXT_fragment_density_map2
    • optional VK_EXT_dynamic_rendering_unused_attachments
    • optional VK_EXT_host_image_copy
    • optional VK_EXT_layer_settings
    • optional VK_EXT_mesh_shader
    • optional VK_ARM_tensors
    • optional VK_ARM_data_graph

Supported platforms

  • Linux
  • Windows
  • MacOS (via KosmicKrisp)
  • Android

API Support

Windows Linux MacOS Android
Vulkan 1.3 ✔️ ✔️ ✔️ ✔️
VK_KHR_acceleration_structure ✔️ ✔️ ✔️
VK_KHR_ray_tracing_pipeline ✔️ ✔️ ✔️
VK_KHR_ray_query ✔️ ✔️ ✔️
VK_EXT_mesh_shader ✔️ ✔️ ✔️
OpenXR 1.1 ✔️

On MacOS, KosmicKrisp and VulkanSDK 1.4.363+ are required.

Build

Before building, run the deployment scripts:

python3 deploy_deps.py
python3 deploy_content.py

These scripts download external third-party dependencies. Please check LICENSE.md for the full list.

Windows

cd build
cmake .. -G "Visual Studio 18 2026"

Linux

sudo apt-get install clang xorg-dev libxinerama-dev libxcursor-dev libgles2-mesa-dev libegl1-mesa-dev libglfw3-dev libglew-dev libstdc++-12-dev extra-cmake-modules libxkbcommon-x11-dev wayland-protocols
cd build
cmake .. -G "Unix Makefiles"

❗ Use cmake .. -G "Unix Makefiles" -DLVK_WITH_WAYLAND=ON to build for Wayland, X11 is used by default.

MacOS

❗ Be sure that VulkanSDK 1.4.363+ for MacOS is installed https://vulkan.lunarg.com/sdk/home#mac

cd build
cmake .. -G "Xcode"

Android

❗ Be sure that Android Studio is set up.

❗ Be sure that the ANDROID_NDK environment variable points to your Android NDK.

❗ Be sure that the JAVA_HOME environment variable is set to the path of the Java Runtime.

❗ Be sure that the adb platform tool is in the PATH environment variable.

cd build
cmake .. -DLVK_WITH_SAMPLES_ANDROID=ON
cd android/001_HelloTriangle            # or any other sample
./gradlew assembleDebug                 # or assembleRelease

You can also open the project in Android Studio and build it from there.

Before running demo apps on your device, connect the device to a desktop machine and run the deployment script:

python3 deploy_content_android.py

All demo apps share this content. Alternatively, it can be pushed as an OBB of selected demo apps, which then use their own copy:

python3 deploy_content_android.py --obb org.lvk.samples.lvk_001_HelloTriangle

NOTE: To run demos on an Android device, it should support Vulkan 1.3. Please check https://vulkan.gpuinfo.org/listdevices.php?platform=android

NOTE: At the moment, demo apps do not support touch input on Android.

Using the Slang compiler

By default, the Slang compiler is disabled, and only GLSL shaders are supported through the glslang compiler. To enable Slang, configure the project with the following CMake option:

cmake .. -DLVK_WITH_SLANG=ON

Arm tensors and data graphs (neural graphics)

LightweightVK supports VK_ARM_tensors and VK_ARM_data_graph. Neural networks run as data graph pipelines, and lvk::VgfModel (lvk/HelpersVgf.h) creates them from VGF files. Shaders never access tensors directly: a tensor aliases a buffer, which shaders reach through its device address, or a TextureUsageBits_TensorAliasing texture, which shaders sample or store.

lvk::VgfModel vgf;
vgf.load(data.data(), data.size());
lvk::Holder<lvk::TensorHandle> input = ctx_->createTensorBufferAliasing(bufInput, 0, vgf.getInput(0).toTensorDesc());
lvk::Holder<lvk::TensorHandle> output = ctx_->createTensorBufferAliasing(bufOutput, 0, vgf.getOutput(0).toTensorDesc());
const lvk::TensorHandle inputs[] = {input};
const lvk::TensorHandle outputs[] = {output};
lvk::Holder<lvk::DataGraphPipelineHandle> graph = vgf.createDataGraphPipeline(*ctx_, inputs, outputs);
...
buffer.cmdDispatchDataGraph(graph, inputs, outputs);

Samples: ARM_001_NeuralSuperSampling, ARM_002_NeuralOIT, ARM_003_NeuralGI.

GPUs without native support can use the Arm ML Emulation Layer for Vulkan. LightweightVK downloads and builds a fork of it from source, with no global installation:

cmake .. -DLVK_WITH_ML_EMULATION_LAYER=ON

The samples then load the layer automatically; --no-ml-emulation turns it off.

Screenshots

Check out https://github.com/corporateshark/lightweightvk/samples.

A comprehensive set of examples can be found in this repository 3D Graphics Rendering Cookbook: 2nd edition and in the book Vulkan 3D Graphics Rendering Cookbook - 2nd Edition.

Vulkan 3D Graphics Rendering Cookbook image Solar System Demo Neural GI

Interop with raw Vulkan API calls

The header file lvk/vulkan/VulkanUtils.h offers a collection of functions that allow you to access the underlying Vulkan API objects from LightweightVK handles. This makes it easy to mix LVK and Vulkan code, as shown in the following example:

lvk::Holder<lvk::BufferHandle> vertexBuffer = ctx_->createBuffer({...});
...
lvk::ICommandBuffer& buffer = ctx_->acquireCommandBuffer();
VkCommandBuffer cmdBuf = getVkCommandBuffer(buffer);
VkBuffer buf = getVkBuffer(vertexBuffer);
vkCmdUpdateBuffer(cmdBuf, buf, 0, sizeof(params), &params);
ctx_->submit(buffer, ctx_->getCurrentSwapchainTexture());

If you'd like to add more helper functions, feel free to submit a pull request.

License

LightweightVK is released under the MIT license, see LICENSE.md for the full text as well as third-party library acknowledgements.

About

LightweightVK is a deeply refactored bindless-only fork of https://github.com/meta/igl. It provides a lean cross-platform graphics API running on top of Vulkan 1.3.

Resources

Code of conduct

Contributing

Stars

492 stars

Watchers

14 watching

Forks

Releases

Used by

Contributors

Languages