Skip to main content

rlx_vulkan/
lib.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! RLX native Vulkan compute backend.
17//!
18//! A from-scratch Vulkan compute backend built directly on `ash` (raw
19//! Vulkan) with hand-written GLSL compute kernels compiled to SPIR-V at
20//! build time and embedded in the binary. Unlike `rlx-wgpu` (which can
21//! reach Vulkan via the wgpu portability layer), this backend owns the
22//! Vulkan instance/device/queue, its own arena `VkBuffer`, descriptor
23//! sets, and compute pipelines — the dedicated `Device::Vulkan` path.
24//!
25//! Layout mirrors the other native GPU backends (rlx-cuda / rlx-rocm):
26//! - `device`  — Vulkan instance/physical-device/device/queue singleton
27//!   (dynamic-loaded; gracefully unavailable with no driver)
28//! - `shaders` — embedded SPIR-V blobs (built from `shaders/*.comp`)
29//! - `kernels` — per-kernel compute-pipeline cache
30//! - `buffer`  — host-visible f32 arena + memory plan mapping
31//! - `backend` — `VulkanExecutable`: compile a graph → schedule → run
32
33pub mod backend;
34pub mod buffer;
35pub mod device;
36pub mod host;
37pub mod kernels;
38pub mod shaders;
39
40/// True if a Vulkan compute device is reachable on this system. The
41/// runtime registry only registers `Device::Vulkan` when this returns
42/// `true`, so hosts with no Vulkan driver (e.g. macOS without MoltenVK)
43/// fall through cleanly instead of panicking.
44pub fn is_available() -> bool {
45    device::vulkan_device().is_some()
46}
47
48/// Human-readable name of the selected Vulkan physical device, if any.
49pub fn device_name() -> Option<String> {
50    device::vulkan_device().map(|d| d.name.clone())
51}