Skip to content

Commit c3033cf

Browse files
committed
reflect: port to spirv-cross2
1 parent 820fb69 commit c3033cf

File tree

23 files changed

+546
-434
lines changed

23 files changed

+546
-434
lines changed

Cargo.lock

+45-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ resolver = "2"
2020
[workspace.dependencies]
2121
windows = "0.58.0"
2222
ash = "0.38"
23-
spirv_cross = { package = "librashader-spirv-cross", version = "0.26" }
24-
23+
spirv-cross2 = { version = "0.4", default-features = false }
2524
objc2-metal = { version = "0.2" }
2625
objc2 = { version = "0.5.0" }
2726

librashader-capi/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ rustc-hash = "2.0.0"
4242
sptr = "0.3.2"
4343

4444
ash = { workspace = true, optional = true }
45-
spirv_cross = { workspace = true }
4645

4746
[dependencies.librashader]
4847
path = "../librashader"

librashader-reflect/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ librashader-common = { path = "../librashader-common", version = "0.3.3" }
2222
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.3" }
2323
librashader-presets = { path = "../librashader-presets", version = "0.3.3" }
2424

25-
spirv_cross = { workspace = true, optional = true }
25+
spirv-cross2 = { workspace = true, optional = true }
2626

2727
naga = { version = "22", optional = true }
2828
rspirv = { version = "0.12.0", optional = true }
@@ -40,11 +40,11 @@ optional = true
4040

4141
[features]
4242
default = ["cross", "naga", "serialize", "wgsl", "msl"]
43-
dxil = ["spirv_cross/hlsl", "spirv-to-dxil"]
44-
wgsl = ["cross", "naga/wgsl-out", "spirv", "rspirv"]
45-
cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl", "spirv_cross/msl" ]
46-
naga = [ "rspirv", "spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
47-
serialize = [ "serde" ]
48-
msl = [ "spirv_cross/msl", "naga/msl-out" ]
43+
dxil = ["spirv-cross2/hlsl", "dep:spirv-to-dxil"]
44+
wgsl = ["cross", "naga/wgsl-out", "dep:spirv", "dep:rspirv"]
45+
cross = [ "dep:spirv-cross2", "spirv-cross2/glsl", "spirv-cross2/hlsl", "spirv-cross2/msl" ]
46+
naga = [ "dep:rspirv", "dep:spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
47+
serialize = [ "dep:serde" ]
48+
msl = [ "spirv-cross2/msl", "naga/msl-out" ]
4949

5050
unstable-naga-in = ["naga/glsl-in"]

librashader-reflect/src/back/glsl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::reflect::cross::{CompiledProgram, SpirvCross};
66
use crate::reflect::ReflectShader;
77

88
/// The GLSL version to target.
9-
pub use spirv_cross::glsl::Version as GlslVersion;
9+
pub use spirv_cross2::compile::glsl::GlslVersion;
1010

1111
use crate::reflect::cross::glsl::GlslReflect;
1212

@@ -15,7 +15,7 @@ pub struct CrossGlslContext {
1515
/// A map of bindings of sampler names to binding locations.
1616
pub sampler_bindings: Vec<(String, u32)>,
1717
/// The compiled program artifact after compilation.
18-
pub artifact: CompiledProgram<spirv_cross::glsl::Target>,
18+
pub artifact: CompiledProgram<spirv_cross2::targets::Glsl>,
1919
}
2020

2121
impl FromCompilation<SpirvCompilation, SpirvCross> for GLSL {

librashader-reflect/src/back/hlsl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::reflect::cross::{CompiledProgram, SpirvCross};
77
use crate::reflect::ReflectShader;
88

99
/// The HLSL shader model version to target.
10-
pub use spirv_cross::hlsl::ShaderModel as HlslShaderModel;
10+
pub use spirv_cross2::compile::hlsl::HlslShaderModel;
1111

1212
/// Buffer assignment information
1313
#[derive(Debug, Clone)]
@@ -99,7 +99,7 @@ impl HlslBufferAssignments {
9999
/// The context for a HLSL compilation via spirv-cross.
100100
pub struct CrossHlslContext {
101101
/// The compiled HLSL program.
102-
pub artifact: CompiledProgram<spirv_cross::hlsl::Target>,
102+
pub artifact: CompiledProgram<spirv_cross2::targets::Hlsl>,
103103
pub vertex_buffers: HlslBufferAssignments,
104104
pub fragment_buffers: HlslBufferAssignments,
105105
}

librashader-reflect/src/back/msl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::reflect::ReflectShader;
99
use naga::back::msl::TranslationInfo;
1010
use naga::Module;
1111

12-
/// The HLSL shader model version to target.
13-
pub use spirv_cross::msl::Version as MslVersion;
12+
/// The MSL language version to target.
13+
pub use spirv_cross2::compile::msl::MslVersion;
1414

1515
/// Compiler options for MSL
1616
#[derive(Debug, Default, Clone)]
@@ -22,7 +22,7 @@ pub struct MslNagaCompileOptions {
2222
/// The context for a MSL compilation via spirv-cross.
2323
pub struct CrossMslContext {
2424
/// The compiled HLSL program.
25-
pub artifact: CompiledProgram<spirv_cross::msl::Target>,
25+
pub artifact: CompiledProgram<spirv_cross2::targets::Msl>,
2626
}
2727

2828
impl FromCompilation<SpirvCompilation, SpirvCross> for MSL {

librashader-reflect/src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum ShaderCompileError {
2020

2121
/// Error when transpiling from spirv-cross.
2222
#[error("spirv-cross error: {0:?}")]
23-
SpirvCrossCompileError(#[from] spirv_cross::ErrorCode),
23+
SpirvCrossCompileError(#[from] spirv_cross2::SpirvCrossError),
2424

2525
/// Error when transpiling from spirv-to-dxil
2626
#[cfg(all(target_os = "windows", feature = "dxil"))]
@@ -87,7 +87,7 @@ pub enum SemanticsErrorKind {
8787
pub enum ShaderReflectError {
8888
/// Reflection error from spirv-cross.
8989
#[error("spirv cross error: {0}")]
90-
SpirvCrossError(#[from] spirv_cross::ErrorCode),
90+
SpirvCrossError(#[from] spirv_cross2::SpirvCrossError),
9191
/// Error when validating vertex shader semantics.
9292
#[error("error when verifying vertex semantics: {0:?}")]
9393
VertexSemanticError(SemanticsErrorKind),

0 commit comments

Comments
 (0)