mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
change how to select bevy-glsl-to-spirv or shaderc (#1819)
`cfg` for `bevy-glsl-to-spirv` use now mimics https://github.com/cart/glsl-to-spirv/blob/master/Cargo.toml fixes #898 fixes #1348 fixes #1942 fixes #1078
This commit is contained in:
parent
3eb828f234
commit
f1ddd7a2ad
2 changed files with 54 additions and 15 deletions
|
@ -44,10 +44,10 @@ parking_lot = "0.11.0"
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
spirv-reflect = "0.2.3"
|
spirv-reflect = "0.2.3"
|
||||||
|
|
||||||
[target.'cfg(all(not(target_os = "ios"), not(target_arch = "wasm32"), not(all(target_arch = "aarch64", target_os = "macos"))))'.dependencies]
|
[target.'cfg(any(all(target_arch="x86_64", target_os="linux", target_env="gnu"), all(target_arch="x86_64", target_os="macos"), all(target_arch="aarch64", target_os="android"), all(target_arch="armv7", target_os="androidabi"), all(target_arch="x86_64", target_os="windows", target_env="msvc")))'.dependencies]
|
||||||
bevy-glsl-to-spirv = "0.2.0"
|
bevy-glsl-to-spirv = "0.2.0"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))'.dependencies]
|
[target.'cfg(not(any(target_arch = "wasm32", all(target_arch="x86_64", target_os="linux", target_env="gnu"), all(target_arch="x86_64", target_os="macos"), all(target_arch="aarch64", target_os="android"), all(target_arch="armv7", target_os="androidabi"), all(target_arch="x86_64", target_os="windows", target_env="msvc"))))'.dependencies]
|
||||||
shaderc = "0.7.0"
|
shaderc = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -27,24 +27,47 @@ pub enum ShaderError {
|
||||||
#[error("Shader compilation error:\n{0}")]
|
#[error("Shader compilation error:\n{0}")]
|
||||||
Compilation(String),
|
Compilation(String),
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))]
|
#[cfg(not(any(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
|
)))]
|
||||||
/// shaderc error.
|
/// shaderc error.
|
||||||
#[error("shaderc error: {0}")]
|
#[error("shaderc error: {0}")]
|
||||||
ShaderC(#[from] shaderc::Error),
|
ShaderC(#[from] shaderc::Error),
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))]
|
#[cfg(not(any(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
|
)))]
|
||||||
#[error("Error initializing shaderc Compiler")]
|
#[error("Error initializing shaderc Compiler")]
|
||||||
ErrorInitializingShadercCompiler,
|
ErrorInitializingShadercCompiler,
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))]
|
#[cfg(not(any(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
|
)))]
|
||||||
#[error("Error initializing shaderc CompileOptions")]
|
#[error("Error initializing shaderc CompileOptions")]
|
||||||
ErrorInitializingShadercCompileOptions,
|
ErrorInitializingShadercCompileOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(any(
|
||||||
not(target_os = "ios"),
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
not(target_arch = "wasm32"),
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
not(all(target_arch = "aarch64", target_os = "macos"))
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
))]
|
))]
|
||||||
impl From<ShaderStage> for bevy_glsl_to_spirv::ShaderType {
|
impl From<ShaderStage> for bevy_glsl_to_spirv::ShaderType {
|
||||||
fn from(s: ShaderStage) -> bevy_glsl_to_spirv::ShaderType {
|
fn from(s: ShaderStage) -> bevy_glsl_to_spirv::ShaderType {
|
||||||
|
@ -56,10 +79,12 @@ impl From<ShaderStage> for bevy_glsl_to_spirv::ShaderType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(any(
|
||||||
not(target_os = "ios"),
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
not(target_arch = "wasm32"),
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
not(all(target_arch = "aarch64", target_os = "macos"))
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
))]
|
))]
|
||||||
pub fn glsl_to_spirv(
|
pub fn glsl_to_spirv(
|
||||||
glsl_source: &str,
|
glsl_source: &str,
|
||||||
|
@ -70,7 +95,14 @@ pub fn glsl_to_spirv(
|
||||||
.map_err(ShaderError::Compilation)
|
.map_err(ShaderError::Compilation)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))]
|
#[cfg(not(any(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
|
)))]
|
||||||
impl Into<shaderc::ShaderKind> for ShaderStage {
|
impl Into<shaderc::ShaderKind> for ShaderStage {
|
||||||
fn into(self) -> shaderc::ShaderKind {
|
fn into(self) -> shaderc::ShaderKind {
|
||||||
match self {
|
match self {
|
||||||
|
@ -81,7 +113,14 @@ impl Into<shaderc::ShaderKind> for ShaderStage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "ios", all(target_arch = "aarch64", target_os = "macos")))]
|
#[cfg(not(any(
|
||||||
|
target_arch = "wasm32",
|
||||||
|
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_arch = "x86_64", target_os = "macos"),
|
||||||
|
all(target_arch = "aarch64", target_os = "android"),
|
||||||
|
all(target_arch = "armv7", target_os = "androidabi"),
|
||||||
|
all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"),
|
||||||
|
)))]
|
||||||
pub fn glsl_to_spirv(
|
pub fn glsl_to_spirv(
|
||||||
glsl_source: &str,
|
glsl_source: &str,
|
||||||
stage: ShaderStage,
|
stage: ShaderStage,
|
||||||
|
|
Loading…
Reference in a new issue