Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 46 additions & 91 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Wrapper crate for SPIRV-Tools"
repository = "https://github.com/rust-gpu/spirv-tools-rs"
version = "0.12.2"
authors = ["Embark <opensource@embark-studios.com>"]
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
readme = "README.md"
documentation = "https://docs.rs/spirv-tools"
Expand Down
2 changes: 1 addition & 1 deletion spirv-tools-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Wrapper crate for SPIRV-Tools"
repository = "https://github.com/rust-gpu/spirv-tools-rs"
version = "0.12.2"
authors = ["Embark <opensource@embark-studios.com>"]
edition = "2021"
edition = "2024"
# This is the same license for the underlying SPIRV-Tools code
license = "Apache-2.0"
documentation = "https://docs.rs/spirv-tools-sys"
Expand Down
2 changes: 1 addition & 1 deletion spirv-tools-sys/generated/build-version.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"v2025.3", "SPIRV-Tools v2025.3 v2025.3.rc1-0-g33e02568"
"v2025.3", "SPIRV-Tools v2025.3 v2025.3-0-g33e02568"
2 changes: 1 addition & 1 deletion spirv-tools-sys/src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum DisassembleOptions {
Comment = 0x80,
}

extern "C" {
unsafe extern "C" {
/// Encodes the given SPIR-V assembly text to its binary representation. The
/// length parameter specifies the number of bytes for text. Encoded binary will
/// be stored into *binary. Any error will be written into *diagnostic if
Expand Down
2 changes: 1 addition & 1 deletion spirv-tools-sys/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub type MessageCallback = extern "C" fn(
*mut std::ffi::c_void, // context we use for mapping
);

extern "C" {
unsafe extern "C" {
/// Destroys a diagnostic object. This is a no-op if diagnostic is a null
/// pointer.
#[link_name = "spvDiagnosticDestroy"]
Expand Down
2 changes: 2 additions & 0 deletions spirv-tools-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unsafe_code)]

#[cfg(not(any(feature = "use-installed-tools", feature = "use-compiled-tools")))]
compile_error!("Enable at least one of `use-compiled-tools` or `use-installed-tools` features");

Expand Down
2 changes: 1 addition & 1 deletion spirv-tools-sys/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ pub enum Passes {
WrapOpKill,
}

extern "C" {
unsafe extern "C" {
pub fn optimizer_create(env: crate::shared::TargetEnv) -> *mut Optimizer;
pub fn optimizer_destroy(opt: *mut Optimizer);

Expand Down
28 changes: 10 additions & 18 deletions spirv-tools-sys/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ use std::fmt;
/// often necessary to specify which one applies. `Universal_*` implies an
/// environment-agnostic SPIR-V.
///
/// When an API method needs to derive a SPIR-V version from a target environment
/// the method will choose the highest version of SPIR-V supported by the target
/// environment. Examples:
///
/// ```text
/// SPV_ENV_VULKAN_1_0 -> SPIR-V 1.0
/// SPV_ENV_VULKAN_1_1 -> SPIR-V 1.3
/// SPV_ENV_VULKAN_1_1_SPIRV_1_4 -> SPIR-V 1.4
/// SPV_ENV_VULKAN_1_2 -> SPIR-V 1.5
/// ```
///
/// Consult the description of API entry points for specific rules.
/// This enum MUST be kept in sync with the `typedef enum spv_target_env` in
/// `spirv-tools-sys/spirv-tools/include/spirv-tools/libspirv.h`, it is being
/// sent across the ffi boundary.
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
Expand Down Expand Up @@ -58,8 +49,8 @@ pub enum TargetEnv {
Universal_1_3,
/// Vulkan 1.1 latest revision.
Vulkan_1_1,
/// Work in progress WebGPU 1.0.
WebGPU_0,
/// DEPRECATED, may be removed in the future.
WebGPU_0_DEPRECATED,
/// SPIR-V 1.4 latest revision, no other restrictions.
Universal_1_4,
/// Vulkan 1.1 with `VK_KHR_spirv_1_4`, i.e. SPIR-V 1.4 binary.
Expand Down Expand Up @@ -109,11 +100,12 @@ impl TargetEnv {

TargetEnv::Vulkan_1_0 => (1, 0),
TargetEnv::Vulkan_1_1 => (1, 3),
TargetEnv::WebGPU_0 => (1, 3),
TargetEnv::Vulkan_1_1_Spirv_1_4 => (1, 4),
TargetEnv::Vulkan_1_2 => (1, 5),
TargetEnv::Vulkan_1_3 => (1, 6),
TargetEnv::Vulkan_1_4 => (1, 6),

TargetEnv::WebGPU_0_DEPRECATED => (1, 3),
}
}
}
Expand Down Expand Up @@ -156,7 +148,7 @@ impl std::str::FromStr for TargetEnv {
"opengl4.2" => Self::OpenGL_4_2,
"opengl4.3" => Self::OpenGL_4_3,
"opengl4.5" => Self::OpenGL_4_5,
"webgpu0" => Self::WebGPU_0,
"webgpu0_DEPRECATED" => Self::WebGPU_0_DEPRECATED,
_ => return Err(SpirvResult::InvalidValue),
})
}
Expand Down Expand Up @@ -191,7 +183,7 @@ impl fmt::Display for TargetEnv {
Self::OpenGL_4_2 => "opengl4.2",
Self::OpenGL_4_3 => "opengl4.3",
Self::OpenGL_4_5 => "opengl4.5",
Self::WebGPU_0 => "webgpu0",
Self::WebGPU_0_DEPRECATED => "webgpu0_DEPRECATED",
})
}
}
Expand Down Expand Up @@ -271,7 +263,7 @@ pub struct ToolContext {
_unused: [u8; 0],
}

extern "C" {
unsafe extern "C" {
/// Creates a context object for most of the SPIRV-Tools API.
/// Returns null if env is invalid.
///
Expand Down
2 changes: 1 addition & 1 deletion spirv-tools-sys/src/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum ValidatorLimits {
IdBound,
}

extern "C" {
unsafe extern "C" {
/// Validates a SPIR-V binary for correctness. Any errors will be written into
/// *diagnostic if diagnostic is non-null, otherwise the context's message
/// consumer will be used.
Expand Down
10 changes: 5 additions & 5 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ pub fn exec(
let mut messages = Vec::new();

for line in split(&output.stdout, b'\n') {
if let Ok(s) = std::str::from_utf8(line) {
if let Some(msg) = crate::error::Message::parse(s) {
messages.push(msg);
continue;
}
if let Ok(s) = std::str::from_utf8(line)
&& let Some(msg) = crate::error::Message::parse(s)
{
messages.push(msg);
continue;
}

break;
Expand Down
Loading