5 releases (breaking)

0.5.0 Aug 28, 2024
0.4.0 Mar 22, 2024
0.3.0 Nov 18, 2023
0.2.0 May 31, 2023
0.1.1 Jan 26, 2023

#198 in Graphics APIs

Download history 2/week @ 2024-08-21 195/week @ 2024-08-28 5/week @ 2024-09-04 3/week @ 2024-09-11 13/week @ 2024-09-18 39/week @ 2024-09-25 10/week @ 2024-10-02 18/week @ 2024-10-09 7/week @ 2024-10-16 10/week @ 2024-10-30 15/week @ 2024-11-06 2/week @ 2024-11-13 6/week @ 2024-11-20 14/week @ 2024-11-27 64/week @ 2024-12-04

86 downloads per month
Used in 5 crates

MIT license

2.5MB
10K SLoC

Blade Graphics

Docs Crates.io

Blade-graphics is a lean and mean GPU abstraction aimed at ergonomics and fun. See motivation, FAQ, and performance for details.

Examples

ray-query example particles example

Platforms

The backend is selected automatically based on the host platform:

  • Vulkan on desktop Linux, Windows, and Android
  • Metal on desktop macOS, and iOS
  • OpenGL ES3 on the Web
Feature Vulkan Metal GLES
compute
ray tracing

Vulkan

Required instance extensions:

  • VK_EXT_debug_utils
  • VK_KHR_get_physical_device_properties2
  • VK_KHR_get_surface_capabilities2

Required device extensions:

  • VK_EXT_inline_uniform_block
  • VK_KHR_descriptor_update_template
  • VK_KHR_timeline_semaphore
  • VK_KHR_dynamic_rendering

Conceptually, Blade requires the baseline Vulkan hardware with a relatively fresh driver. All of these required extensions are supported in software by the driver on any underlying architecture.

OpenGL ES

GLES is also supported at a basic level. It's enabled for wasm32-unknown-unknown target, and can also be force-enabled on native:

RUSTFLAGS="--cfg gles" CARGO_TARGET_DIR=./target-gl cargo test

This path can be activated on all platforms via Angle library. For example, on macOS it's sufficient to place libEGL.dylib and libGLESv2.dylib in the working directory.

WebGL2

Following command will start a web server offering the bunnymark example:

cargo run-wasm --example bunnymark

Vulkan Portability

First, ensure to load the environment from the Vulkan SDK:

cd /opt/VulkanSDK && source setup-env.sh

Vulkan backend can be forced on using "vulkan" config flag. Example invocation that produces a vulkan (portability) build into another target folder:

RUSTFLAGS="--cfg vulkan" CARGO_TARGET_DIR=./target-vk cargo test

Dependencies

~6–19MB
~263K SLoC