Skip to content
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

V0.4.0 #3

Merged
merged 13 commits into from
Sep 6, 2024
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
14 changes: 12 additions & 2 deletions Cargo.lock

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

30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,37 @@ Safe and sound Rust bindings to [SPIRV-Cross](https://github.com/KhronosGroup/SP
}
```

## Features
By default, the `glsl`, `hlsl`, and `msl` features are enabled by default. The `cpp` and `json` targets can be enabled
in Cargo.toml

```toml
[dependencies]
spirv-cross2 = { features = ["cpp", "json"] }
```

SPIRV-Cross will only be built with support for enabled targets. If you want to only perform reflection and shrink the binary size,
you can disable all but the `None` target.

```toml
[dependencies]
spirv-cross2 = { default-features = false }
```

To enable all features, including `f16` and vector constant support, use the `full` feature.

```toml
[dependencies]
spirv-cross2 = { features = ["full"] }
```

### `f16` and vector specialization constants support
When querying specialization constants, spirv-cross2 includes optional support for `f16` via [half](https://crates.io/crates/half) and `Vec2`, `Vec3`, `Vec4`, and `Mat4` types
via [gfx-maths](https://crates.io/crates/gfx-maths). This is included by default, but can be disabled by disabling default features.
via [gfx-maths](https://crates.io/crates/gfx-maths).

```toml
[dependencies]
spirv-cross2 = { default-features = false }
[dependencies]
spirv-cross2 = { features = ["f16", "half"] }
```

## License
Expand Down
6 changes: 3 additions & 3 deletions bindings_generator/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ impl ParseCallbacks for SpirvCrossCallbacks {
original_variant_name: &str,
_variant_value: EnumVariantValue,
) -> Option<EnumVariantCustomBehavior> {
if original_variant_name.starts_with("Spv") {
return None;
};
if original_variant_name.ends_with("_MAX") {
return Some(EnumVariantCustomBehavior::Hide);
};
Expand Down Expand Up @@ -176,9 +179,6 @@ impl ParseCallbacks for SpirvCrossCallbacks {
return vec![String::from("#[non_exhaustive]")];
};

if info.kind == TypeKind::Enum && info.name.starts_with("Spv") {
return vec![String::from("#[non_exhaustive]")];
}
vec![]
}
}
70 changes: 18 additions & 52 deletions bindings_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,25 @@ fn main() {
.header("spirv-cross-sys/native/wrapper.h")
.parse_callbacks(Box::new(SpirvCrossCallbacks))
.allowlist_type("spvc_.*")
.allowlist_type("Spv.*")
.allowlist_type("SpvBuiltIn_")
.allowlist_type("SpvCapability_")
.allowlist_type("SpvDecoration_")
.allowlist_type("SpvDim_")
.allowlist_type("SpvExecutionMode_")
.allowlist_type("SpvExecutionModel_")
.allowlist_type("SpvFPRoundingMode_")
.allowlist_type("SpvImageFormat_")
.allowlist_type("SpvStorageClass_")
.newtype_enum("SpvBuiltIn_")
.newtype_enum("SpvCapability_")
.newtype_enum("SpvDecoration_")
.newtype_enum("SpvDim_")
.newtype_enum("SpvExecutionMode_")
.newtype_enum("SpvExecutionModel_")
.newtype_enum("SpvFPRoundingMode_")
.newtype_enum("SpvImageFormat_")
.newtype_enum("SpvStorageClass_")
.allowlist_function("spvc.*")
.rustified_enum("SpvSourceLanguage_")
.rustified_enum("SpvExecutionModel_")
.rustified_enum("SpvAddressingModel_")
.rustified_enum("SpvMemoryModel_")
.rustified_enum("SpvExecutionMode_")
.rustified_enum("SpvStorageClass_")
.rustified_enum("SpvDim_")
.rustified_enum("SpvSamplerAddressingMode_")
.rustified_enum("SpvSamplerFilterMode_")
.rustified_enum("SpvImageFormat_")
.rustified_enum("SpvImageChannelOrder_")
.rustified_enum("SpvImageChannelDataType_")
.rustified_enum("SpvImageOperandsShift_")
.rustified_enum("SpvImageOperandsMask_")
.rustified_enum("SpvFPFastMathModeShift_")
.rustified_enum("SpvFPFastMathModeMask_")
.rustified_enum("SpvFPRoundingMode_")
.rustified_enum("SpvLinkageType_")
.rustified_enum("SpvAccessQualifier_")
.rustified_enum("SpvFunctionParameterAttribute_")
.rustified_enum("SpvDecoration_")
.rustified_enum("SpvBuiltIn_")
.rustified_enum("SpvSelectionControlShift_")
.rustified_enum("SpvSelectionControlMask_")
.rustified_enum("SpvLoopControlShift_")
.rustified_enum("SpvLoopControlMask_")
.rustified_enum("SpvFunctionControlShift_")
.rustified_enum("SpvFunctionControlMask_")
.rustified_enum("SpvMemorySemanticsShift_")
.rustified_enum("SpvMemorySemanticsMask_")
.rustified_enum("SpvMemoryAccessShift_")
.rustified_enum("SpvMemoryAccessMask_")
.rustified_enum("SpvScope_")
.rustified_enum("SpvGroupOperation_")
.rustified_enum("SpvKernelEnqueueFlags_")
.rustified_enum("SpvKernelProfilingInfoShift_")
.rustified_enum("SpvKernelProfilingInfoMask_")
.rustified_enum("SpvCapability_")
.rustified_enum("SpvRayFlagsShift_")
.rustified_enum("SpvRayFlagsMask_")
.rustified_enum("SpvRayQueryIntersection_")
.rustified_enum("SpvRayQueryCommittedIntersectionType_")
.rustified_enum("SpvRayQueryCandidateIntersectionType_")
.rustified_enum("SpvFragmentShadingRateShift_")
.rustified_enum("SpvFragmentShadingRateMask_")
.rustified_enum("SpvFPDenormMode_")
.rustified_enum("SpvFPOperationMode_")
.rustified_enum("SpvQuantizationModes_")
.rustified_enum("SpvOverflowModes_")
.rustified_enum("SpvPackedVectorFormat_")
.rustified_enum("SpvOp_")
.rustified_enum("spvc_backend")
.rustified_enum("spvc_capture_mode")
.rustified_enum("spvc_result")
Expand Down
10 changes: 9 additions & 1 deletion spirv-cross-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spirv-cross-sys"
version = "0.3.0"
version = "0.4.0"
edition = "2021"


Expand All @@ -17,6 +17,14 @@ bytemuck = "1.17.1"
num-traits = "0.2"
num-derive = "0.4.2"

[features]
glsl = []
msl = ["glsl"]
hlsl = ["glsl"]
json = ["glsl"]
cpp = ["glsl"]


[build-dependencies]
cc = "1.0"
glob = "0.3"
Expand Down
25 changes: 20 additions & 5 deletions spirv-cross-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ pub fn main() {
.cpp(true)
.std("c++14")
.define("SPIRV_CROSS_CLI", "OFF")
.define("SPIRV_CROSS_C_API_GLSL", "1")
.define("SPIRV_CROSS_C_API_HLSL", "1")
.define("SPIRV_CROSS_C_API_MSL", "1")
.define("SPIRV_CROSS_C_API_CPP", "1")
.define("SPIRV_CROSS_C_API_REFLECT", "1")
.includes(&["native/SPIRV-Cross", "native/SPIRV-CROSS/include"])
.file("native/SPIRV-Cross/spirv_cfg.cpp")
.file("native/SPIRV-Cross/spirv_cpp.cpp")
Expand All @@ -29,6 +24,26 @@ pub fn main() {
.file("native/SPIRV-Cross/spirv_reflect.cpp")
.file("native/spirv_cross_c_ext_rs.cpp");

if cfg!(feature = "glsl") {
spvc_build.define("SPIRV_CROSS_C_API_GLSL", "1");
}

if cfg!(feature = "hlsl") {
spvc_build.define("SPIRV_CROSS_C_API_HLSL", "1");
}

if cfg!(feature = "msl") {
spvc_build.define("SPIRV_CROSS_C_API_MSL", "1");
}

if cfg!(feature = "cpp") {
spvc_build.define("SPIRV_CROSS_C_API_CPP", "1");
}

if cfg!(feature = "json") {
spvc_build.define("SPIRV_CROSS_C_API_JSON", "1");
}

spvc_build.compile("spirv-cross");
println!("cargo:rustc-link-lib=static=spirv-cross");
}
Loading