Skip to content

Commit

Permalink
reflect: port to spirv-cross2
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Sep 7, 2024
1 parent 820fb69 commit c3033cf
Show file tree
Hide file tree
Showing 23 changed files with 546 additions and 434 deletions.
64 changes: 45 additions & 19 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ resolver = "2"
[workspace.dependencies]
windows = "0.58.0"
ash = "0.38"
spirv_cross = { package = "librashader-spirv-cross", version = "0.26" }

spirv-cross2 = { version = "0.4", default-features = false }
objc2-metal = { version = "0.2" }
objc2 = { version = "0.5.0" }

Expand Down
1 change: 0 additions & 1 deletion librashader-capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ rustc-hash = "2.0.0"
sptr = "0.3.2"

ash = { workspace = true, optional = true }
spirv_cross = { workspace = true }

[dependencies.librashader]
path = "../librashader"
Expand Down
14 changes: 7 additions & 7 deletions librashader-reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ librashader-common = { path = "../librashader-common", version = "0.3.3" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.3.3" }
librashader-presets = { path = "../librashader-presets", version = "0.3.3" }

spirv_cross = { workspace = true, optional = true }
spirv-cross2 = { workspace = true, optional = true }

naga = { version = "22", optional = true }
rspirv = { version = "0.12.0", optional = true }
Expand All @@ -40,11 +40,11 @@ optional = true

[features]
default = ["cross", "naga", "serialize", "wgsl", "msl"]
dxil = ["spirv_cross/hlsl", "spirv-to-dxil"]
wgsl = ["cross", "naga/wgsl-out", "spirv", "rspirv"]
cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl", "spirv_cross/msl" ]
naga = [ "rspirv", "spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
serialize = [ "serde" ]
msl = [ "spirv_cross/msl", "naga/msl-out" ]
dxil = ["spirv-cross2/hlsl", "dep:spirv-to-dxil"]
wgsl = ["cross", "naga/wgsl-out", "dep:spirv", "dep:rspirv"]
cross = [ "dep:spirv-cross2", "spirv-cross2/glsl", "spirv-cross2/hlsl", "spirv-cross2/msl" ]
naga = [ "dep:rspirv", "dep:spirv", "naga/spv-in", "naga/spv-out", "naga/wgsl-out", "naga/msl-out" ]
serialize = [ "dep:serde" ]
msl = [ "spirv-cross2/msl", "naga/msl-out" ]

unstable-naga-in = ["naga/glsl-in"]
4 changes: 2 additions & 2 deletions librashader-reflect/src/back/glsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::reflect::cross::{CompiledProgram, SpirvCross};
use crate::reflect::ReflectShader;

/// The GLSL version to target.
pub use spirv_cross::glsl::Version as GlslVersion;
pub use spirv_cross2::compile::glsl::GlslVersion;

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

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

impl FromCompilation<SpirvCompilation, SpirvCross> for GLSL {
Expand Down
4 changes: 2 additions & 2 deletions librashader-reflect/src/back/hlsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::reflect::cross::{CompiledProgram, SpirvCross};
use crate::reflect::ReflectShader;

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

/// Buffer assignment information
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -99,7 +99,7 @@ impl HlslBufferAssignments {
/// The context for a HLSL compilation via spirv-cross.
pub struct CrossHlslContext {
/// The compiled HLSL program.
pub artifact: CompiledProgram<spirv_cross::hlsl::Target>,
pub artifact: CompiledProgram<spirv_cross2::targets::Hlsl>,
pub vertex_buffers: HlslBufferAssignments,
pub fragment_buffers: HlslBufferAssignments,
}
Expand Down
6 changes: 3 additions & 3 deletions librashader-reflect/src/back/msl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::reflect::ReflectShader;
use naga::back::msl::TranslationInfo;
use naga::Module;

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

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

impl FromCompilation<SpirvCompilation, SpirvCross> for MSL {
Expand Down
4 changes: 2 additions & 2 deletions librashader-reflect/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum ShaderCompileError {

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

/// Error when transpiling from spirv-to-dxil
#[cfg(all(target_os = "windows", feature = "dxil"))]
Expand Down Expand Up @@ -87,7 +87,7 @@ pub enum SemanticsErrorKind {
pub enum ShaderReflectError {
/// Reflection error from spirv-cross.
#[error("spirv cross error: {0}")]
SpirvCrossError(#[from] spirv_cross::ErrorCode),
SpirvCrossError(#[from] spirv_cross2::SpirvCrossError),
/// Error when validating vertex shader semantics.
#[error("error when verifying vertex semantics: {0:?}")]
VertexSemanticError(SemanticsErrorKind),
Expand Down
Loading

0 comments on commit c3033cf

Please sign in to comment.