build: only build dxil on windows

This commit is contained in:
chyyran 2023-11-29 02:06:20 -05:00 committed by Ronny Chan
parent c0a1b56f4e
commit f4bdf160ab
7 changed files with 12 additions and 10 deletions

View file

@ -39,9 +39,6 @@ jobs:
- if: runner.os == 'Windows'
run: pip install meson ninja mako
name: Install Meson for spirv-to-dxil-sys
- if: runner.os == 'Linux'
name: Install Mesa build deps
run: apt-get build-dep mesa
- name: Build dynamic library
run: cargo run -p librashader-build-script -- --profile ${{ matrix.profile }}
- name: Upload build artifacts

View file

@ -12,7 +12,7 @@ description = "RetroArch shaders for all."
[dependencies]
serde = { version = "1.0" }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.4", features = ["serialize", "dxil"] }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.4", features = ["serialize"] }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.4" }
platform-dirs = "0.3.0"
blake3 = { version = "1.3.3" }
@ -32,7 +32,7 @@ features = [
optional = true
[features]
d3d = ["windows"]
d3d = ["windows", "librashader-reflect/dxil"]
# hack to get building on docsrs
docsrs = ["blake3/pure", "rusqlite/in_gecko"]

View file

@ -56,6 +56,7 @@ impl<T: ShaderCompilation + for<'de> serde::Deserialize<'de> + serde::Serialize
}
}
#[cfg(all(target_os = "windows", feature = "d3d"))]
impl FromCompilation<CachedCompilation<GlslangCompilation>> for DXIL {
type Target = <DXIL as FromCompilation<GlslangCompilation>>::Target;
type Options = <DXIL as FromCompilation<GlslangCompilation>>::Options;

View file

@ -24,12 +24,16 @@ librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.4"
librashader-presets = { path = "../librashader-presets", version = "0.1.4" }
spirv_cross = { package = "librashader-spirv-cross", version = "0.23", optional = true }
spirv-to-dxil = { version = "0.4", optional = true }
naga = { version = "0.11.0", features = ["glsl-in", "spv-in", "spv-out", "glsl-out", "wgsl-out"], optional = true }
rspirv = { version = "0.11.0+1.5.4", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
[target.'cfg(windows)'.dependencies.spirv-to-dxil]
version = "0.4"
optional = true
[features]
default = ["cross", "serialize"]
unstable-naga = [ "naga", "rspirv" ]

View file

@ -1,5 +1,5 @@
pub mod cross;
#[cfg(feature = "dxil")]
#[cfg(all(target_os = "windows", feature = "dxil"))]
pub mod dxil;
mod spirv;
pub mod targets;

View file

@ -23,7 +23,7 @@ pub enum ShaderCompileError {
SpirvCrossCompileError(#[from] spirv_cross::ErrorCode),
/// Error when transpiling from spirv-to-dxil
#[cfg(feature = "dxil")]
#[cfg(all(target_os = "windows", feature = "dxil"))]
#[error("spirv-to-dxil")]
SpirvToDxilCompileError(#[from] spirv_to_dxil::SpirvToDxilError),
}

View file

@ -170,8 +170,8 @@ pub mod reflect {
}
/// DXIL reflection via spirv-to-dxil.
#[cfg(feature = "reflect-dxil")]
#[doc(cfg(feature = "reflect-dxil"))]
#[cfg(all(target_os = "windows", feature = "reflect-dxil"))]
#[doc(cfg(all(target_os = "windows", feature = "reflect-dxil")))]
pub mod dxil {
/// The maximum shader model to use when compiling the DXIL blob.
pub use librashader_reflect::back::dxil::ShaderModel;