MCPcopy Index your code
hub / github.com/attackgoat/vk-graph

github.com/attackgoat/vk-graph @v0.14.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.14.4 ↗ · + Follow
2,003 symbols 5,852 edges 94 files 454 documented · 23%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Vulkan Graph Driver

Crates.io Docs.rs Guide Book

vk-graph is a high-performance Vulkan driver for the Rust programming language featuring automated resource management and execution. It is blazingly-fast, built for real-world use, and supports modern Vulkan commands[^modern].

[dependencies]
vk-graph = "0.14"

Changelog

Overview

vk-graph supports desktop, mobile, and AR/VR platforms in headless, windowed, or full-screen modes. An accessory crate is provided for winit support:

use vk_graph_window::{Window, WindowError};

fn main() -> Result<(), WindowError> {
    Window::new()?.run(|frame| {
        // It's time to do some graphics! 😲
    })
}

Usage

vk-graph centers frame work around a Graph. Bind Vulkan smart-pointer resources such as buffers, images, acceleration structures, and swapchain images into the graph to get statically typed node handles. Commands then reference those nodes instead of raw Vulkan handles. When recording is complete, finalize the graph into a Submission and submit it with a pool.

The normal flow is:

  • Create a Device, resources, and pipelines.
  • Start a fresh Graph for the frame or workload.
  • Bind resources into typed nodes with Graph::bind_resource or receive nodes from a swapchain integration crate.
  • Record compute, graphics, transfer, or ray tracing commands with Graph::begin_cmd.
  • Declare each resource access on the command so the graph can build synchronization and pass data.
  • Finalize and submit the graph.

CommandStream is available when part of the command graph is reusable. A stream records commands once with typed arguments, then each frame binds those arguments to the frame's concrete graph nodes. This is useful for overlays, post-processing, or other repeated command sequences that still need per-frame resources such as the current swapchain image.

Device extension support is exposed through the selected physical device:

if let Some(ray_tracing) = &device.physical.vk_khr_ray_tracing_pipeline {
    println!("max recursion depth: {}", ray_tracing.properties.max_ray_recursion_depth);
}

if device.physical.vk_khr_synchronization2 {
    println!("synchronization2 is available");
}

Features

  • Compute, graphics, and ray tracing pipelines
  • Automatic Vulkan management (render passes, subpasses, descriptors, pools, etc.)
  • Automatic render pass scheduling, re-ordering, merging, with resource aliasing
  • Interoperable with existing Vulkan code
  • Optional shader hot-reload from disk

Example code:

graph
    .begin_cmd()
    .debug_name("Fancy new algorithm for shading a moving character who is actively on fire")
    .bind_pipeline(&gfx_pipeline)
    .shader_resource_access(0, prev_image, AccessType::FragmentShaderReadColorInputAttachment)
    .shader_resource_access(1, some_image, AccessType::FragmentShaderReadOther)
    .shader_resource_access(3, fire_buffer, AccessType::FragmentShaderReadUniformBuffer)
    .color_attachment_image(0, swapchain_image, LoadOp::CLEAR_BLACK_ALPHA_ZERO, StoreOp::Store)
    .depth_stencil_attachment_image(depth_image, LoadOp::Load, StoreOp::DontCare)
    .record_cmd(move |cmd| {
        cmd
            .push_constants(0, some_u8_slice)
            .draw(6, 1, 0, 0);
    });

Optional features

vk-graph puts a lot of functionality behind optional features in order to optimize compile time for the most common use cases. The following features are available.

  • checked (enabled by default) — Runtime validation of common misuse patterns (missing access declarations, buffer bounds, image aspects) that the Vulkan Validation Layer cannot catch, including cross-graph node ownership checks. Disable for zero-overhead in validated releases.
  • loaded (enabled by default) — Support searching for the Vulkan loader manually at runtime.
  • linked — Link the Vulkan loader at compile time.
  • ash-molten — Enable ash-molten support for MoltenVK-based platforms.
  • parking_lot (enabled by default) — Use parking_lot synchronization primitives.
  • profile-with-* — Use the specified profiling backend: profile-with-puffin, profile-with-optick, profile-with-superluminal, or profile-with-tracy

Debug Logging

This crate uses log for low-overhead logging.

To enable logging, set the RUST_LOG environment variable to trace, debug, info, warn or error and initialize the logging provider of your choice. Examples use pretty_env_logger.

You may also filter messages, for example:

RUST_LOG=vk_graph::driver=trace,vk_graph=warn cargo run --example ray_tracing
TRACE vk_graph::driver::instance > created a Vulkan instance
DEBUG vk_graph::driver::physical_device > physical device: NVIDIA GeForce RTX 3090
DEBUG vk_graph::driver::physical_device > extension "VK_KHR_16bit_storage" v1
DEBUG vk_graph::driver::physical_device > extension "VK_KHR_8bit_storage" v1
DEBUG vk_graph::driver::physical_device > extension "VK_KHR_acceleration_structure" v13
...

Performance Profiling

This crate uses profiling and supports multiple profiling providers. When not in use profiling has zero cost.

To enable profiling, compile with one of the profile-with-* features enabled and initialize the profiling provider of your choice.

Example code uses puffin:

cargo run --features profile-with-puffin --release --example vsm_omni

Flamegraph of performance data

Quick Start

Included are some examples you might find helpful:

  • hello_world.rs — Displays a window on the screen. Please start here.
  • triangle.rs — Shaders and full setup of index/vertex buffers; < 100 LOC.
  • shader-toy/ — Recreation of a two-pass Shadertoy using the original shader code.

See the example code, documentation, or helpful guide book for more information.

NOTE: Required development packages and libraries are listed in the guide. All new users should read and understand the guide.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[^modern]: Modern Vulkan usage means no pixel queries. Anything else unsupported is due to there being better options, no current need, or no interest. Please open an issue.

Extension points exported contracts — how you extend this code

NodeSealed (Interface)
Prevents external implementations of [`Node`] and provides crate-private node internals. [6 implementers]
src/lib.rs
Pool (Interface)
Allows requesting resources using driver information structures. [17 implementers]
src/pool/mod.rs
FenceDroppable (Interface)
(no doc) [4 implementers]
src/driver/fence.rs
StreamArgBindable (Interface)
(no doc) [3 implementers]
src/stream.rs
Glyph (Interface)
Common accessors for glyph geometry and atlas placement. [1 implementers]
crates/vk-graph-fx/src/bitmap_font.rs
Pipeline (Interface)
A trait for pipelines which may be bound to a `Command`. See [`Command::bind_pipeline`](crate::cmd::Command::bind_pipel
src/cmd/pipeline.rs
Face (Interface)
(no doc) [1 implementers]
examples/vr/src/main.rs
Node (Interface)
(no doc) [6 implementers]
src/lib.rs

Core symbols most depended-on inside this repo

as_slice
called by 253
src/driver/swapchain.rs
bind_resource
called by 241
src/lib.rs
len
called by 238
src/driver/swapchain.rs
iter
called by 151
src/driver/swapchain.rs
resource
called by 140
src/lib.rs
image_subresource_range
called by 124
src/driver/image.rs
push
called by 115
src/lib.rs
debug_name
called by 112
src/stream.rs

Shape

Method 1,085
Function 493
Class 345
Enum 57
Interface 23

Languages

Rust100%

Modules by API surface

src/submission.rs274 symbols
src/driver/image.rs161 symbols
src/lib.rs148 symbols
src/driver/swapchain.rs91 symbols
src/driver/buffer.rs84 symbols
src/stream.rs78 symbols
src/cmd/graphics.rs65 symbols
src/driver/device.rs56 symbols
src/cmd/mod.rs52 symbols
src/driver/shader.rs46 symbols
src/driver/accel_struct.rs46 symbols
src/driver/instance.rs38 symbols

For agents

$ claude mcp add vk-graph \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact