Skip to content

add targets vulkan1.3, vulkan1.4 and spv1.6 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [
name = "spirv-tools"
description = "Wrapper crate for SPIRV-Tools"
repository = "https://github.com/rust-gpu/spirv-tools-rs"
version = "0.10.0"
version = "0.11.0"
authors = ["Embark <opensource@embark-studios.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -31,7 +31,7 @@ use-installed-tools = [
use-compiled-tools = ["spirv-tools-sys/use-compiled-tools"]

[dependencies]
spirv-tools-sys = { version = "0.8", path = "./spirv-tools-sys", default-features = false }
spirv-tools-sys = { version = "0.9", path = "./spirv-tools-sys", default-features = false }
# Used for parsing output when running binaries
memchr = { version = "2.3", optional = true }
tempfile = { version = "3.1", optional = true }
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 @@ -2,7 +2,7 @@
name = "spirv-tools-sys"
description = "Wrapper crate for SPIRV-Tools"
repository = "https://github.com/rust-gpu/spirv-tools-rs"
version = "0.8.0"
version = "0.9.0"
authors = ["Embark <opensource@embark-studios.com>"]
edition = "2021"
# This is the same license for the underlying SPIRV-Tools code
Expand Down
54 changes: 54 additions & 0 deletions spirv-tools-sys/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,54 @@ pub enum TargetEnv {
Universal_1_5,
/// Vulkan 1.2 latest revision.
Vulkan_1_2,
/// SPIR-V 1.6 latest revision, no other restrictions.
Universal_1_6,
/// Vulkan 1.3 latest revision.
Vulkan_1_3,
/// Vulkan 1.4 latest revision.
Vulkan_1_4,
}

impl TargetEnv {
/// Returns the `(mayor, minor)` version of spv this enum variant must at least support
///
/// The spirv versions for vulkan targets have been pulled from the source of the vulkan spec:
/// <https://github.com/KhronosGroup/Vulkan-Docs/blob/main/appendices/spirvenv.adoc?plain=1#L21>
pub fn spirv_version(&self) -> (u8, u8) {
#[allow(clippy::match_same_arms)]
match self {
TargetEnv::Universal_1_0 => (1, 0),
TargetEnv::Universal_1_1 => (1, 1),
TargetEnv::Universal_1_2 => (1, 2),
TargetEnv::Universal_1_3 => (1, 3),
TargetEnv::Universal_1_4 => (1, 4),
TargetEnv::Universal_1_5 => (1, 5),
TargetEnv::Universal_1_6 => (1, 6),

TargetEnv::OpenGL_4_0 => (1, 0),
TargetEnv::OpenGL_4_1 => (1, 0),
TargetEnv::OpenGL_4_2 => (1, 0),
TargetEnv::OpenGL_4_3 => (1, 0),
TargetEnv::OpenGL_4_5 => (1, 0),

TargetEnv::OpenCL_1_2 => (1, 0),
TargetEnv::OpenCL_2_0 => (1, 0),
TargetEnv::OpenCL_2_1 => (1, 0),
TargetEnv::OpenCL_2_2 => (1, 2),
TargetEnv::OpenCLEmbedded_1_2 => (1, 0),
TargetEnv::OpenCLEmbedded_2_0 => (1, 0),
TargetEnv::OpenCLEmbedded_2_1 => (1, 0),
TargetEnv::OpenCLEmbedded_2_2 => (1, 2),

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),
}
}
}

impl Default for TargetEnv {
Expand All @@ -86,12 +134,15 @@ impl std::str::FromStr for TargetEnv {
"vulkan1.0" => Self::Vulkan_1_0,
"vulkan1.1" => Self::Vulkan_1_1,
"vulkan1.2" => Self::Vulkan_1_2,
"vulkan1.3" => Self::Vulkan_1_3,
"vulkan1.4" => Self::Vulkan_1_4,
"spv1.0" => Self::Universal_1_0,
"spv1.1" => Self::Universal_1_1,
"spv1.2" => Self::Universal_1_2,
"spv1.3" => Self::Universal_1_3,
"spv1.4" => Self::Universal_1_4,
"spv1.5" => Self::Universal_1_5,
"spv1.6" => Self::Universal_1_6,
"opencl1.2embedded" => Self::OpenCLEmbedded_1_2,
"opencl1.2" => Self::OpenCL_1_2,
"opencl2.0embedded" => Self::OpenCLEmbedded_2_0,
Expand All @@ -118,12 +169,15 @@ impl fmt::Display for TargetEnv {
Self::Vulkan_1_0 => "vulkan1.0",
Self::Vulkan_1_1 => "vulkan1.1",
Self::Vulkan_1_2 => "vulkan1.2",
Self::Vulkan_1_3 => "vulkan1.3",
Self::Vulkan_1_4 => "vulkan1.4",
Self::Universal_1_0 => "spv1.0",
Self::Universal_1_1 => "spv1.1",
Self::Universal_1_2 => "spv1.2",
Self::Universal_1_3 => "spv1.3",
Self::Universal_1_4 => "spv1.4",
Self::Universal_1_5 => "spv1.5",
Self::Universal_1_6 => "spv1.6",
Self::OpenCLEmbedded_1_2 => "opencl1.2embedded",
Self::OpenCL_1_2 => "opencl1.2",
Self::OpenCLEmbedded_2_0 => "opencl2.0embedded",
Expand Down