dep: remove shaderc dependency
This commit is contained in:
parent
47f6e0f10e
commit
2b208f1848
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -404,9 +404,9 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.14.1"
|
version = "1.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9"
|
checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck_derive",
|
"bytemuck_derive",
|
||||||
]
|
]
|
||||||
|
@ -1341,6 +1341,27 @@ dependencies = [
|
||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glslang"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ffa3b9c49e9b4270061e25e7e3946d979a9394a21ac51edcb72e7c17874d3a54"
|
||||||
|
dependencies = [
|
||||||
|
"glslang-sys",
|
||||||
|
"once_cell",
|
||||||
|
"rustc-hash",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glslang-sys"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d82a4e43102eb601efd17b0c3d10596132405c5eb3268a91a6f2ccc9a04c0ce"
|
||||||
|
dependencies = [
|
||||||
|
"cmake",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin_wgl_sys"
|
name = "glutin_wgl_sys"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
@ -1823,6 +1844,7 @@ version = "0.2.0-beta.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
"glslang",
|
||||||
"indexmap 2.2.2",
|
"indexmap 2.2.2",
|
||||||
"librashader-common 0.2.0-beta.6",
|
"librashader-common 0.2.0-beta.6",
|
||||||
"librashader-preprocess",
|
"librashader-preprocess",
|
||||||
|
@ -1833,7 +1855,6 @@ dependencies = [
|
||||||
"rspirv",
|
"rspirv",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
"shaderc",
|
|
||||||
"spirv",
|
"spirv",
|
||||||
"spirv-to-dxil",
|
"spirv-to-dxil",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -2314,19 +2335,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.46"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-iter"
|
name = "num-iter"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
|
checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
|
@ -2347,9 +2367,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.17"
|
version = "0.2.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
@ -2843,15 +2863,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "roxmltree"
|
|
||||||
version = "0.14.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "921904a62e410e37e215c40381b7117f830d9d89ba60ab5236170541dd25646b"
|
|
||||||
dependencies = [
|
|
||||||
"xmlparser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rspirv"
|
name = "rspirv"
|
||||||
version = "0.12.0+sdk-1.3.268.0"
|
version = "0.12.0+sdk-1.3.268.0"
|
||||||
|
@ -3035,27 +3046,6 @@ dependencies = [
|
||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shaderc"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "27e07913ada18607bb60d12431cbe3358d3bbebbe95948e1618851dc01e63b7b"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"shaderc-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shaderc-sys"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "73120d240fe22196300f39ca8547ca2d014960f27b19b47b21288b396272f7f7"
|
|
||||||
dependencies = [
|
|
||||||
"cmake",
|
|
||||||
"libc",
|
|
||||||
"roxmltree",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simd-adler32"
|
name = "simd-adler32"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
|
@ -3159,9 +3149,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spirv-to-dxil"
|
name = "spirv-to-dxil"
|
||||||
version = "0.4.1"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ce8b35efd4e676abda599d43a3ddf8771bd77364631745a7254079021d55895"
|
checksum = "9aa1b4b592a3c01a5a443b0d80200f1ae0cf4706928e3d61e03ae570e4085d06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"spirv-to-dxil-sys",
|
"spirv-to-dxil-sys",
|
||||||
|
@ -3170,9 +3160,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spirv-to-dxil-sys"
|
name = "spirv-to-dxil-sys"
|
||||||
version = "0.4.5"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "159f154ac0277748c193b397a72d27ee664446547dfa9a2589cf7a7bd9a01e5e"
|
checksum = "84697ae60e0a247c15d86651fca5b1af43bf7bceeed3746532255fa2f7416ee5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-target",
|
"build-target",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
@ -3418,9 +3408,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-segmentation"
|
name = "unicode-segmentation"
|
||||||
version = "1.10.1"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
|
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
|
@ -4337,12 +4327,6 @@ version = "0.8.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
|
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xmlparser"
|
|
||||||
version = "0.13.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yaml-rust"
|
name = "yaml-rust"
|
||||||
version = "0.4.5"
|
version = "0.4.5"
|
||||||
|
|
|
@ -12,7 +12,7 @@ keywords = ["shader", "retroarch", "SPIR-V"]
|
||||||
description = "RetroArch shaders for all."
|
description = "RetroArch shaders for all."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
shaderc = { version = "0.8.3", features = [] }
|
glslang = "0.2"
|
||||||
bytemuck = "1.13.0"
|
bytemuck = "1.13.0"
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
@ -40,7 +40,6 @@ optional = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cross", "wgsl", "serialize"]
|
default = ["cross", "wgsl", "serialize"]
|
||||||
standalone = ["shaderc/build-from-source", "shaderc/prefer-static-linking"]
|
|
||||||
dxil = ["cross", "spirv-to-dxil"]
|
dxil = ["cross", "spirv-to-dxil"]
|
||||||
wgsl = ["cross", "naga", "spirv", "rspirv"]
|
wgsl = ["cross", "naga", "spirv", "rspirv"]
|
||||||
cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl" ]
|
cross = [ "spirv_cross", "spirv_cross/glsl", "spirv_cross/hlsl" ]
|
||||||
|
|
|
@ -10,13 +10,13 @@ pub enum ShaderCompileError {
|
||||||
#[error("shader")]
|
#[error("shader")]
|
||||||
NagaCompileError(Vec<naga::front::glsl::Error>),
|
NagaCompileError(Vec<naga::front::glsl::Error>),
|
||||||
|
|
||||||
/// Compilation error from shaderc (glslang).
|
/// Compilation error from glslang.
|
||||||
#[error("shaderc")]
|
#[error("glslang")]
|
||||||
ShaderCCompileError(#[from] shaderc::Error),
|
GlslangError(#[from] glslang::error::GlslangError),
|
||||||
|
|
||||||
/// Error when initializing the shaderc compiler.
|
/// Error when initializing the glslang compiler.
|
||||||
#[error("shaderc init")]
|
#[error("glslang init")]
|
||||||
ShaderCInitError,
|
CompilerInitError,
|
||||||
|
|
||||||
/// Error when transpiling from spirv-cross.
|
/// Error when transpiling from spirv-cross.
|
||||||
#[error("cross")]
|
#[error("cross")]
|
||||||
|
|
76
librashader-reflect/src/front/glslang.rs
Normal file
76
librashader-reflect/src/front/glslang.rs
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
use crate::error::ShaderCompileError;
|
||||||
|
use glslang::input::{CompilerOptions, ShaderInput};
|
||||||
|
use glslang::limits::ResourceLimits;
|
||||||
|
use librashader_preprocess::ShaderSource;
|
||||||
|
|
||||||
|
#[cfg(feature = "serialize")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// A reflectable shader compilation via glslang.
|
||||||
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct GlslangCompilation {
|
||||||
|
pub(crate) vertex: Vec<u32>,
|
||||||
|
pub(crate) fragment: Vec<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GlslangCompilation {
|
||||||
|
/// Tries to compile SPIR-V from the provided shader source.
|
||||||
|
pub fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError> {
|
||||||
|
compile_spirv(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&ShaderSource> for GlslangCompilation {
|
||||||
|
type Error = ShaderCompileError;
|
||||||
|
|
||||||
|
/// Tries to compile SPIR-V from the provided shader source.
|
||||||
|
fn try_from(source: &ShaderSource) -> Result<Self, Self::Error> {
|
||||||
|
GlslangCompilation::compile(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn compile_spirv(
|
||||||
|
source: &ShaderSource,
|
||||||
|
) -> Result<GlslangCompilation, ShaderCompileError> {
|
||||||
|
let compiler = glslang::Compiler::acquire().ok_or(ShaderCompileError::CompilerInitError)?;
|
||||||
|
|
||||||
|
let limits = ResourceLimits::default();
|
||||||
|
let options = CompilerOptions::default();
|
||||||
|
|
||||||
|
let vertex = glslang::input::ShaderSource::from(source.vertex.as_str());
|
||||||
|
let vertex = ShaderInput::new(
|
||||||
|
&vertex,
|
||||||
|
&limits,
|
||||||
|
glslang::ShaderStage::Vertex,
|
||||||
|
&options,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
let vertex = compiler.create_shader(vertex)?;
|
||||||
|
|
||||||
|
let fragment = glslang::input::ShaderSource::from(source.fragment.as_str());
|
||||||
|
let fragment = ShaderInput::new(
|
||||||
|
&fragment,
|
||||||
|
&limits,
|
||||||
|
glslang::ShaderStage::Fragment,
|
||||||
|
&options,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
let fragment = compiler.create_shader(fragment)?;
|
||||||
|
|
||||||
|
let vertex = Vec::from(vertex.compile()?);
|
||||||
|
let fragment = Vec::from(fragment.compile()?);
|
||||||
|
|
||||||
|
Ok(GlslangCompilation { vertex, fragment })
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use crate::front::glslang::compile_spirv;
|
||||||
|
use librashader_preprocess::ShaderSource;
|
||||||
|
#[test]
|
||||||
|
pub fn compile_shader() {
|
||||||
|
let result = ShaderSource::load("../test/basic.slang").unwrap();
|
||||||
|
let _spirv = compile_spirv(&result).unwrap();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::error::ShaderCompileError;
|
use crate::error::ShaderCompileError;
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
|
|
||||||
mod shaderc;
|
mod glslang;
|
||||||
|
|
||||||
pub use crate::front::shaderc::GlslangCompilation;
|
pub use crate::front::glslang::GlslangCompilation;
|
||||||
|
|
||||||
/// Trait for types that can compile shader sources into a compilation unit.
|
/// Trait for types that can compile shader sources into a compilation unit.
|
||||||
pub trait ShaderCompilation: Sized {
|
pub trait ShaderCompilation: Sized {
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
use crate::error::ShaderCompileError;
|
|
||||||
use librashader_preprocess::ShaderSource;
|
|
||||||
use shaderc::{CompileOptions, Limit, ShaderKind};
|
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// A reflectable shader compilation via glslang (shaderc).
|
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct GlslangCompilation {
|
|
||||||
pub(crate) vertex: Vec<u32>,
|
|
||||||
pub(crate) fragment: Vec<u32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GlslangCompilation {
|
|
||||||
/// Tries to compile SPIR-V from the provided shader source.
|
|
||||||
pub fn compile(source: &ShaderSource) -> Result<Self, ShaderCompileError> {
|
|
||||||
compile_spirv(source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<&ShaderSource> for GlslangCompilation {
|
|
||||||
type Error = ShaderCompileError;
|
|
||||||
|
|
||||||
/// Tries to compile SPIR-V from the provided shader source.
|
|
||||||
fn try_from(source: &ShaderSource) -> Result<Self, Self::Error> {
|
|
||||||
GlslangCompilation::compile(source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_shaderc_options() -> Result<CompileOptions<'static>, ShaderCompileError> {
|
|
||||||
let mut options = CompileOptions::new().ok_or(ShaderCompileError::ShaderCInitError)?;
|
|
||||||
options.set_include_callback(|_, _, _, _| {
|
|
||||||
Err("RetroArch shaders must already have includes be preprocessed".into())
|
|
||||||
});
|
|
||||||
options.set_limit(Limit::MaxLights, 32);
|
|
||||||
options.set_limit(Limit::MaxClipPlanes, 6);
|
|
||||||
options.set_limit(Limit::MaxTextureUnits, 32);
|
|
||||||
options.set_limit(Limit::MaxTextureCoords, 32);
|
|
||||||
options.set_limit(Limit::MaxVertexAttribs, 64);
|
|
||||||
options.set_limit(Limit::MaxVertexUniformComponents, 4096);
|
|
||||||
options.set_limit(Limit::MaxVaryingFloats, 64);
|
|
||||||
options.set_limit(Limit::MaxVertexTextureImageUnits, 32);
|
|
||||||
options.set_limit(Limit::MaxCombinedTextureImageUnits, 80);
|
|
||||||
options.set_limit(Limit::MaxTextureImageUnits, 32);
|
|
||||||
options.set_limit(Limit::MaxFragmentUniformComponents, 4096);
|
|
||||||
options.set_limit(Limit::MaxDrawBuffers, 32);
|
|
||||||
options.set_limit(Limit::MaxVertexUniformVectors, 128);
|
|
||||||
options.set_limit(Limit::MaxVaryingVectors, 8);
|
|
||||||
options.set_limit(Limit::MaxFragmentUniformVectors, 16);
|
|
||||||
options.set_limit(Limit::MaxVertexOutputVectors, 16);
|
|
||||||
options.set_limit(Limit::MaxFragmentInputVectors, 15);
|
|
||||||
options.set_limit(Limit::MinProgramTexelOffset, -8);
|
|
||||||
options.set_limit(Limit::MaxProgramTexelOffset, 7);
|
|
||||||
options.set_limit(Limit::MaxClipDistances, 8);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupCountX, 65535);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupCountY, 65535);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupCountZ, 65535);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupSizeX, 1024);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupSizeY, 1024);
|
|
||||||
options.set_limit(Limit::MaxComputeWorkGroupSizeZ, 64);
|
|
||||||
options.set_limit(Limit::MaxComputeUniformComponents, 1024);
|
|
||||||
options.set_limit(Limit::MaxComputeTextureImageUnits, 16);
|
|
||||||
options.set_limit(Limit::MaxComputeImageUniforms, 8);
|
|
||||||
options.set_limit(Limit::MaxComputeAtomicCounters, 8);
|
|
||||||
options.set_limit(Limit::MaxComputeAtomicCounterBuffers, 1);
|
|
||||||
options.set_limit(Limit::MaxVaryingComponents, 60);
|
|
||||||
options.set_limit(Limit::MaxVertexOutputComponents, 64);
|
|
||||||
options.set_limit(Limit::MaxGeometryInputComponents, 64);
|
|
||||||
options.set_limit(Limit::MaxGeometryOutputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxFragmentInputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxImageUnits, 8);
|
|
||||||
options.set_limit(Limit::MaxCombinedImageUnitsAndFragmentOutputs, 8);
|
|
||||||
options.set_limit(Limit::MaxCombinedShaderOutputResources, 8);
|
|
||||||
options.set_limit(Limit::MaxImageSamples, 0);
|
|
||||||
options.set_limit(Limit::MaxVertexImageUniforms, 0);
|
|
||||||
options.set_limit(Limit::MaxTessControlImageUniforms, 0);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationImageUniforms, 0);
|
|
||||||
options.set_limit(Limit::MaxGeometryImageUniforms, 0);
|
|
||||||
options.set_limit(Limit::MaxFragmentImageUniforms, 8);
|
|
||||||
options.set_limit(Limit::MaxCombinedImageUniforms, 8);
|
|
||||||
options.set_limit(Limit::MaxGeometryTextureImageUnits, 16);
|
|
||||||
options.set_limit(Limit::MaxGeometryOutputVertices, 256);
|
|
||||||
options.set_limit(Limit::MaxGeometryTotalOutputComponents, 1024);
|
|
||||||
options.set_limit(Limit::MaxGeometryUniformComponents, 1024);
|
|
||||||
options.set_limit(Limit::MaxGeometryVaryingComponents, 64);
|
|
||||||
options.set_limit(Limit::MaxTessControlInputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxTessControlOutputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxTessControlTextureImageUnits, 16);
|
|
||||||
options.set_limit(Limit::MaxTessControlUniformComponents, 1024);
|
|
||||||
options.set_limit(Limit::MaxTessControlTotalOutputComponents, 4096);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationInputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationOutputComponents, 128);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationTextureImageUnits, 16);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationUniformComponents, 1024);
|
|
||||||
options.set_limit(Limit::MaxTessPatchComponents, 120);
|
|
||||||
options.set_limit(Limit::MaxPatchVertices, 32);
|
|
||||||
options.set_limit(Limit::MaxTessGenLevel, 64);
|
|
||||||
options.set_limit(Limit::MaxViewports, 16);
|
|
||||||
options.set_limit(Limit::MaxVertexAtomicCounters, 0);
|
|
||||||
options.set_limit(Limit::MaxTessControlAtomicCounters, 0);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationAtomicCounters, 0);
|
|
||||||
options.set_limit(Limit::MaxGeometryAtomicCounters, 0);
|
|
||||||
options.set_limit(Limit::MaxFragmentAtomicCounters, 8);
|
|
||||||
options.set_limit(Limit::MaxCombinedAtomicCounters, 8);
|
|
||||||
options.set_limit(Limit::MaxAtomicCounterBindings, 1);
|
|
||||||
options.set_limit(Limit::MaxVertexAtomicCounterBuffers, 0);
|
|
||||||
options.set_limit(Limit::MaxTessControlAtomicCounterBuffers, 0);
|
|
||||||
options.set_limit(Limit::MaxTessEvaluationAtomicCounterBuffers, 0);
|
|
||||||
options.set_limit(Limit::MaxGeometryAtomicCounterBuffers, 0);
|
|
||||||
options.set_limit(Limit::MaxFragmentAtomicCounterBuffers, 1);
|
|
||||||
options.set_limit(Limit::MaxCombinedAtomicCounterBuffers, 1);
|
|
||||||
options.set_limit(Limit::MaxAtomicCounterBufferSize, 16384);
|
|
||||||
options.set_limit(Limit::MaxTransformFeedbackBuffers, 4);
|
|
||||||
options.set_limit(Limit::MaxTransformFeedbackInterleavedComponents, 64);
|
|
||||||
options.set_limit(Limit::MaxCullDistances, 8);
|
|
||||||
options.set_limit(Limit::MaxCombinedClipAndCullDistances, 8);
|
|
||||||
options.set_limit(Limit::MaxSamples, 4);
|
|
||||||
|
|
||||||
Ok(options)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn compile_spirv(
|
|
||||||
source: &ShaderSource,
|
|
||||||
) -> Result<GlslangCompilation, ShaderCompileError> {
|
|
||||||
let compiler = shaderc::Compiler::new().ok_or(ShaderCompileError::ShaderCInitError)?;
|
|
||||||
let name = source.name.as_deref().unwrap_or("shader.slang");
|
|
||||||
let options = get_shaderc_options()?;
|
|
||||||
|
|
||||||
let vertex = compiler.compile_into_spirv(
|
|
||||||
&source.vertex,
|
|
||||||
ShaderKind::Vertex,
|
|
||||||
name,
|
|
||||||
"main",
|
|
||||||
Some(&options),
|
|
||||||
)?;
|
|
||||||
let fragment = compiler.compile_into_spirv(
|
|
||||||
&source.fragment,
|
|
||||||
ShaderKind::Fragment,
|
|
||||||
name,
|
|
||||||
"main",
|
|
||||||
Some(&options),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// shaderc has a GIL so Send is unsafe.
|
|
||||||
let vertex = Vec::from(vertex.as_binary());
|
|
||||||
let fragment = Vec::from(fragment.as_binary());
|
|
||||||
|
|
||||||
Ok(GlslangCompilation { vertex, fragment })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use crate::front::shaderc::compile_spirv;
|
|
||||||
use librashader_preprocess::ShaderSource;
|
|
||||||
#[test]
|
|
||||||
pub fn compile_shader() {
|
|
||||||
let result = ShaderSource::load("../test/basic.slang").unwrap();
|
|
||||||
let _spirv = compile_spirv(&result).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,7 +44,7 @@
|
||||||
//! matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
|
//! matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
|
||||||
//!
|
//!
|
||||||
//! In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::front::GlslangCompilation),
|
//! In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::front::GlslangCompilation),
|
||||||
//! which does transpilation via [shaderc](https://github.com/google/shaderc) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
|
//! which does transpilation via [glslang](https://github.com/KhronosGroup/glslang) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
#![feature(impl_trait_in_assoc_type)]
|
#![feature(impl_trait_in_assoc_type)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
|
|
|
@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.2.0-beta.6" }
|
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.2.0-beta.6" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = ["standalone"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6"}
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
||||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" }
|
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6", features = ["d3d"] }
|
||||||
|
|
|
@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.2.0-beta.6" }
|
librashader-common = { path = "../librashader-common", features = ["d3d12"], version = "0.2.0-beta.6" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = ["dxil", "standalone"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = ["dxil"] }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6", features = ["d3d"] }
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.2.0-beta.6" }
|
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.2.0-beta.6" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = ["standalone"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.6" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.6" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6" }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6" }
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.2.0-beta.6" }
|
librashader-common = { path = "../librashader-common", features = ["vulkan"], version = "0.2.0-beta.6" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = [] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.6" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.6" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6" }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-beta.6" }
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn triangle_vk() {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let filter = FilterChainVulkan::load_from_path(
|
let filter = FilterChainVulkan::load_from_path(
|
||||||
"../test/slang-shaders/crt/crt-royale.slangp",
|
"../test/shaders_slang/crt/crt-royale.slangp",
|
||||||
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",
|
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",
|
||||||
&base,
|
&base,
|
||||||
// "../test/slang-shaders/test/feedback.slancargogp",
|
// "../test/slang-shaders/test/feedback.slancargogp",
|
||||||
|
@ -20,7 +20,7 @@ fn triangle_vk() {
|
||||||
frames_in_flight: 3,
|
frames_in_flight: 3,
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
use_render_pass: true,
|
use_render_pass: true,
|
||||||
disable_cache: false,
|
disable_cache: true,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -12,7 +12,6 @@ URL: https://github.com/SnowflakePowered/%{name}
|
||||||
%undefine _disable_source_fetch
|
%undefine _disable_source_fetch
|
||||||
Source: {{{ git_dir_pack }}}
|
Source: {{{ git_dir_pack }}}
|
||||||
BuildRequires: pkgconfig(vulkan)
|
BuildRequires: pkgconfig(vulkan)
|
||||||
BuildRequires: pkgconfig(shaderc)
|
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: git
|
BuildRequires: git
|
||||||
|
|
|
@ -16,7 +16,7 @@ description = "RetroArch shaders for all."
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.0-beta.6" }
|
librashader-common = { path = "../librashader-common", version = "0.2.0-beta.6" }
|
||||||
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.6" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.6" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6", features = ["standalone"] }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.6" }
|
||||||
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-beta.6" }
|
||||||
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.0-beta.6", optional = true }
|
librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.0-beta.6", optional = true }
|
||||||
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.0-beta.6", optional = true }
|
librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.0-beta.6", optional = true }
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub mod preprocess {
|
||||||
/// matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
|
/// matured enough to support [the features librashader needs](https://github.com/gfx-rs/naga/issues/1012).
|
||||||
///
|
///
|
||||||
/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::reflect::cross::GlslangCompilation),
|
/// In the meanwhile, the only supported compilation type is [GlslangCompilation](crate::reflect::cross::GlslangCompilation),
|
||||||
/// which does transpilation via [shaderc](https://github.com/google/shaderc) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
|
/// which does transpilation via [glslang](https://github.com/KhronosGroup/glslang/) and [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross).
|
||||||
pub mod reflect {
|
pub mod reflect {
|
||||||
/// Supported shader compiler targets.
|
/// Supported shader compiler targets.
|
||||||
pub mod targets {
|
pub mod targets {
|
||||||
|
|
|
@ -12,7 +12,6 @@ URL: https://github.com/SnowflakePowered/%{name}
|
||||||
%undefine _disable_source_fetch
|
%undefine _disable_source_fetch
|
||||||
Source: https://github.com/SnowflakePowered/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
|
Source: https://github.com/SnowflakePowered/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
|
||||||
BuildRequires: pkgconfig(vulkan)
|
BuildRequires: pkgconfig(vulkan)
|
||||||
BuildRequires: pkgconfig(shaderc)
|
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: g++
|
BuildRequires: g++
|
||||||
|
|
|
@ -6,7 +6,7 @@ arch=('x86_64' 'aarch64')
|
||||||
url="https://github.com/SnowflakePowered/librashader"
|
url="https://github.com/SnowflakePowered/librashader"
|
||||||
license=('MPL-2.0')
|
license=('MPL-2.0')
|
||||||
groups=('')
|
groups=('')
|
||||||
depends=('vulkan-icd-loader' 'shaderc' 'cmake' 'gcc' 'rust' 'patchelf' 'ninja')
|
depends=('vulkan-icd-loader' 'cmake' 'gcc' 'rust' 'patchelf' 'ninja')
|
||||||
provides=("$pkgname=$pkgver" 'librashader.so')
|
provides=("$pkgname=$pkgver" 'librashader.so')
|
||||||
backup=('')
|
backup=('')
|
||||||
source=("$pkgname-$pkgver.tar.xz" 'vendor.tar.xz' 'cargo_config')
|
source=("$pkgname-$pkgver.tar.xz" 'vendor.tar.xz' 'cargo_config')
|
||||||
|
|
|
@ -10,7 +10,6 @@ Source0: librashader-%{version}.tar.xz
|
||||||
Source1: vendor.tar.xz
|
Source1: vendor.tar.xz
|
||||||
Source2: cargo_config
|
Source2: cargo_config
|
||||||
BuildRequires: pkgconfig(vulkan)
|
BuildRequires: pkgconfig(vulkan)
|
||||||
BuildRequires: pkgconfig(shaderc)
|
|
||||||
BuildRequires: ninja-build
|
BuildRequires: ninja-build
|
||||||
BuildRequires: patchelf
|
BuildRequires: patchelf
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
|
|
Loading…
Reference in a new issue