From a7ca391ef62f94eebb1334146ace61616171dc93 Mon Sep 17 00:00:00 2001 From: chyyran Date: Sat, 10 Feb 2024 17:47:05 -0500 Subject: [PATCH] reflect: abstract away input compiler from compilation --- librashader-cache/src/compilation.rs | 64 ++++++++++--------- librashader-reflect/src/back/cross.rs | 10 +-- librashader-reflect/src/back/dxil.rs | 6 +- librashader-reflect/src/back/mod.rs | 6 +- librashader-reflect/src/back/msl.rs | 0 librashader-reflect/src/back/spirv.rs | 6 +- librashader-reflect/src/back/targets.rs | 7 +- librashader-reflect/src/back/wgsl/mod.rs | 8 +-- librashader-reflect/src/front/glslang.rs | 28 ++------ librashader-reflect/src/front/mod.rs | 38 +++++++++-- librashader-reflect/src/lib.rs | 10 +-- librashader-reflect/src/reflect/cross.rs | 10 +-- librashader-reflect/src/reflect/presets.rs | 26 ++++---- librashader-runtime-d3d11/src/filter_chain.rs | 8 +-- librashader-runtime-d3d12/src/filter_chain.rs | 14 ++-- .../src/filter_chain/filter_impl.rs | 8 +-- librashader-runtime-vk/src/filter_chain.rs | 8 +-- librashader-runtime-wgpu/src/filter_chain.rs | 6 +- librashader/src/lib.rs | 4 +- 19 files changed, 145 insertions(+), 122 deletions(-) create mode 100644 librashader-reflect/src/back/msl.rs diff --git a/librashader-cache/src/compilation.rs b/librashader-cache/src/compilation.rs index b0bddb1..b4b1200 100644 --- a/librashader-cache/src/compilation.rs +++ b/librashader-cache/src/compilation.rs @@ -6,21 +6,25 @@ use librashader_reflect::back::targets::{GLSL, HLSL, SPIRV}; use librashader_reflect::back::{CompilerBackend, FromCompilation}; use librashader_reflect::error::{ShaderCompileError, ShaderReflectError}; -use librashader_reflect::front::{GlslangCompilation, ShaderCompilation}; +use librashader_reflect::front::{Glslang, ShaderInputCompiler, ShaderReflectObject, SpirvCompilation}; pub struct CachedCompilation { compilation: T, } -impl serde::Deserialize<'de> + serde::Serialize + Clone> - ShaderCompilation for CachedCompilation +impl ShaderReflectObject for CachedCompilation { + +} + +impl serde::Deserialize<'de> + serde::Serialize + Clone> +ShaderInputCompiler> for Glslang where Glslang: ShaderInputCompiler { - fn compile(source: &ShaderSource) -> Result { + fn compile(source: &ShaderSource) -> Result, ShaderCompileError> { let cache = crate::cache::internal::get_cache(); let Ok(cache) = cache else { return Ok(CachedCompilation { - compilation: T::compile(source)?, + compilation: Glslang::compile(source)?, }); }; @@ -45,7 +49,7 @@ impl serde::Deserialize<'de> + serde::Serialize } CachedCompilation { - compilation: T::compile(source)?, + compilation: Glslang::compile(source)?, } }; @@ -60,53 +64,53 @@ impl serde::Deserialize<'de> + serde::Serialize } #[cfg(all(target_os = "windows", feature = "d3d"))] -impl FromCompilation> for DXIL { - type Target = >::Target; - type Options = >::Options; - type Context = >::Context; - type Output = >::Output; +impl FromCompilation> for DXIL { + type Target = >::Target; + type Options = >::Options; + type Context = >::Context; + type Output = >::Output; fn from_compilation( - compile: CachedCompilation, + compile: CachedCompilation, ) -> Result, ShaderReflectError> { DXIL::from_compilation(compile.compilation) } } -impl FromCompilation> for HLSL { - type Target = >::Target; - type Options = >::Options; - type Context = >::Context; - type Output = >::Output; +impl FromCompilation> for HLSL { + type Target = >::Target; + type Options = >::Options; + type Context = >::Context; + type Output = >::Output; fn from_compilation( - compile: CachedCompilation, + compile: CachedCompilation, ) -> Result, ShaderReflectError> { HLSL::from_compilation(compile.compilation) } } -impl FromCompilation> for GLSL { - type Target = >::Target; - type Options = >::Options; - type Context = >::Context; - type Output = >::Output; +impl FromCompilation> for GLSL { + type Target = >::Target; + type Options = >::Options; + type Context = >::Context; + type Output = >::Output; fn from_compilation( - compile: CachedCompilation, + compile: CachedCompilation, ) -> Result, ShaderReflectError> { GLSL::from_compilation(compile.compilation) } } -impl FromCompilation> for SPIRV { - type Target = >::Target; - type Options = >::Options; - type Context = >::Context; - type Output = >::Output; +impl FromCompilation> for SPIRV { + type Target = >::Target; + type Options = >::Options; + type Context = >::Context; + type Output = >::Output; fn from_compilation( - compile: CachedCompilation, + compile: CachedCompilation, ) -> Result, ShaderReflectError> { SPIRV::from_compilation(compile.compilation) } diff --git a/librashader-reflect/src/back/cross.rs b/librashader-reflect/src/back/cross.rs index 7f67cfc..a69ae9d 100644 --- a/librashader-reflect/src/back/cross.rs +++ b/librashader-reflect/src/back/cross.rs @@ -1,7 +1,7 @@ use crate::back::targets::{GLSL, HLSL}; use crate::back::{CompileShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; -use crate::front::GlslangCompilation; +use crate::front::SpirvCompilation; use crate::reflect::cross::{CompiledProgram, GlslReflect, HlslReflect}; use crate::reflect::ReflectShader; @@ -19,7 +19,7 @@ pub struct CrossGlslContext { pub artifact: CompiledProgram, } -impl FromCompilation for GLSL { +impl FromCompilation for GLSL { type Target = GLSL; type Options = GlslVersion; type Context = CrossGlslContext; @@ -27,7 +27,7 @@ impl FromCompilation for GLSL { + ReflectShader; fn from_compilation( - compile: GlslangCompilation, + compile: SpirvCompilation, ) -> Result, ShaderReflectError> { Ok(CompilerBackend { backend: GlslReflect::try_from(&compile)?, @@ -41,7 +41,7 @@ pub struct CrossHlslContext { pub artifact: CompiledProgram, } -impl FromCompilation for HLSL { +impl FromCompilation for HLSL { type Target = HLSL; type Options = Option; type Context = CrossHlslContext; @@ -49,7 +49,7 @@ impl FromCompilation for HLSL { + ReflectShader; fn from_compilation( - compile: GlslangCompilation, + compile: SpirvCompilation, ) -> Result, ShaderReflectError> { Ok(CompilerBackend { backend: HlslReflect::try_from(&compile)?, diff --git a/librashader-reflect/src/back/dxil.rs b/librashader-reflect/src/back/dxil.rs index c3de3e3..ea988f5 100644 --- a/librashader-reflect/src/back/dxil.rs +++ b/librashader-reflect/src/back/dxil.rs @@ -8,7 +8,7 @@ use spirv_to_dxil::{ use crate::back::targets::{OutputTarget, DXIL}; use crate::error::{ShaderCompileError, ShaderReflectError}; -use crate::front::GlslangCompilation; +use crate::front::SpirvCompilation; use crate::reflect::cross::GlslReflect; use crate::reflect::ReflectShader; @@ -16,7 +16,7 @@ impl OutputTarget for DXIL { type Output = DxilObject; } -impl FromCompilation for DXIL { +impl FromCompilation for DXIL { type Target = DXIL; type Options = Option; type Context = (); @@ -24,7 +24,7 @@ impl FromCompilation for DXIL { + ReflectShader; fn from_compilation( - compile: GlslangCompilation, + compile: SpirvCompilation, ) -> Result, ShaderReflectError> { let reflect = GlslReflect::try_from(&compile)?; let vertex = compile.vertex; diff --git a/librashader-reflect/src/back/mod.rs b/librashader-reflect/src/back/mod.rs index af95e9a..1d361aa 100644 --- a/librashader-reflect/src/back/mod.rs +++ b/librashader-reflect/src/back/mod.rs @@ -4,12 +4,14 @@ pub mod dxil; mod spirv; pub mod targets; pub mod wgsl; +mod msl; use crate::back::targets::OutputTarget; use crate::error::{ShaderCompileError, ShaderReflectError}; use crate::reflect::semantics::ShaderSemantics; use crate::reflect::{ReflectShader, ShaderReflection}; use std::fmt::Debug; +use crate::front::ShaderReflectObject; /// The output of the shader compiler. #[derive(Debug)] @@ -118,11 +120,11 @@ where #[cfg(test)] mod test { - use crate::front::GlslangCompilation; + use crate::front::{Glslang, ShaderInputCompiler, SpirvCompilation}; use librashader_preprocess::ShaderSource; pub fn test() { let result = ShaderSource::load("../test/basic.slang").unwrap(); - let _cross = GlslangCompilation::compile(&result).unwrap(); + let _cross = Glslang::compile(&result).unwrap(); } } diff --git a/librashader-reflect/src/back/msl.rs b/librashader-reflect/src/back/msl.rs new file mode 100644 index 0000000..e69de29 diff --git a/librashader-reflect/src/back/spirv.rs b/librashader-reflect/src/back/spirv.rs index e317499..7a7910e 100644 --- a/librashader-reflect/src/back/spirv.rs +++ b/librashader-reflect/src/back/spirv.rs @@ -1,7 +1,7 @@ use crate::back::targets::SPIRV; use crate::back::{CompileShader, CompilerBackend, FromCompilation, ShaderCompilerOutput}; use crate::error::{ShaderCompileError, ShaderReflectError}; -use crate::front::GlslangCompilation; +use crate::front::SpirvCompilation; use crate::reflect::cross::GlslReflect; use crate::reflect::semantics::ShaderSemantics; use crate::reflect::{ReflectShader, ShaderReflection}; @@ -13,7 +13,7 @@ pub(crate) struct WriteSpirV { pub(crate) fragment: Vec, } -impl FromCompilation for SPIRV { +impl FromCompilation for SPIRV { type Target = SPIRV; type Options = Option<()>; type Context = (); @@ -21,7 +21,7 @@ impl FromCompilation for SPIRV { + ReflectShader; fn from_compilation( - compile: GlslangCompilation, + compile: SpirvCompilation, ) -> Result, ShaderReflectError> { let reflect = GlslReflect::try_from(&compile)?; let vertex = compile.vertex; diff --git a/librashader-reflect/src/back/targets.rs b/librashader-reflect/src/back/targets.rs index 9212f35..ff54100 100644 --- a/librashader-reflect/src/back/targets.rs +++ b/librashader-reflect/src/back/targets.rs @@ -34,6 +34,9 @@ impl OutputTarget for HLSL { impl OutputTarget for WGSL { type Output = String; } +impl OutputTarget for MSL { + type Output = String; +} impl OutputTarget for SPIRV { type Output = Vec; } @@ -42,9 +45,9 @@ impl OutputTarget for SPIRV { mod test { use crate::back::targets::GLSL; use crate::back::FromCompilation; - use crate::front::GlslangCompilation; + use crate::front::SpirvCompilation; #[allow(dead_code)] - pub fn test_compile(value: GlslangCompilation) { + pub fn test_compile(value: SpirvCompilation) { let _x = GLSL::from_compilation(value).unwrap(); } } diff --git a/librashader-reflect/src/back/wgsl/mod.rs b/librashader-reflect/src/back/wgsl/mod.rs index 7f70b3d..b45c003 100644 --- a/librashader-reflect/src/back/wgsl/mod.rs +++ b/librashader-reflect/src/back/wgsl/mod.rs @@ -4,7 +4,7 @@ use crate::back::targets::WGSL; use crate::back::wgsl::lower_samplers::LowerCombinedImageSamplerPass; use crate::back::{CompileShader, CompilerBackend, FromCompilation, ShaderCompilerOutput}; use crate::error::{ShaderCompileError, ShaderReflectError}; -use crate::front::GlslangCompilation; +use crate::front::SpirvCompilation; use crate::reflect::naga::NagaReflect; use crate::reflect::ReflectShader; use naga::back::wgsl::WriterFlags; @@ -26,7 +26,7 @@ pub struct WgslCompileOptions { pub sampler_bind_group: u32, } -impl FromCompilation for WGSL { +impl FromCompilation for WGSL { type Target = WGSL; type Options = WgslCompileOptions; type Context = NagaWgslContext; @@ -34,7 +34,7 @@ impl FromCompilation for WGSL { + ReflectShader; fn from_compilation( - compile: GlslangCompilation, + compile: SpirvCompilation, ) -> Result, ShaderReflectError> { fn lower_fragment_shader(words: &[u32]) -> Vec { let mut loader = rspirv::dr::Loader::new(); @@ -189,7 +189,7 @@ mod test { ); } - let compilation = crate::front::GlslangCompilation::try_from(&result).unwrap(); + let compilation = crate::front::SpirvCompilation::try_from(&result).unwrap(); let mut wgsl = WGSL::from_compilation(compilation).unwrap(); diff --git a/librashader-reflect/src/front/glslang.rs b/librashader-reflect/src/front/glslang.rs index fd3fa90..eb1e290 100644 --- a/librashader-reflect/src/front/glslang.rs +++ b/librashader-reflect/src/front/glslang.rs @@ -4,34 +4,20 @@ use librashader_preprocess::ShaderSource; #[cfg(feature = "serialize")] use serde::{Deserialize, Serialize}; +use crate::front::{ShaderInputCompiler, SpirvCompilation}; -/// A reflectable shader compilation via glslang. -#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] -#[derive(Debug, Clone)] -pub struct GlslangCompilation { - pub(crate) vertex: Vec, - pub(crate) fragment: Vec, -} +/// glslang compiler +pub struct Glslang; -impl GlslangCompilation { - /// Tries to compile SPIR-V from the provided shader source. - pub fn compile(source: &ShaderSource) -> Result { +impl ShaderInputCompiler for Glslang { + fn compile(source: &ShaderSource) -> Result { 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 { - GlslangCompilation::compile(source) - } -} - pub(crate) fn compile_spirv( source: &ShaderSource, -) -> Result { +) -> Result { let compiler = glslang::Compiler::acquire().ok_or(ShaderCompileError::CompilerInitError)?; let options = CompilerOptions { source_language: glslang::SourceLanguage::GLSL, @@ -53,7 +39,7 @@ pub(crate) fn compile_spirv( let vertex = Vec::from(vertex.compile()?); let fragment = Vec::from(fragment.compile()?); - Ok(GlslangCompilation { vertex, fragment }) + Ok(SpirvCompilation { vertex, fragment }) } #[cfg(test)] diff --git a/librashader-reflect/src/front/mod.rs b/librashader-reflect/src/front/mod.rs index d02d6d4..cfb6259 100644 --- a/librashader-reflect/src/front/mod.rs +++ b/librashader-reflect/src/front/mod.rs @@ -1,18 +1,44 @@ use crate::error::ShaderCompileError; use librashader_preprocess::ShaderSource; +use serde::{Deserialize, Serialize}; mod glslang; -pub use crate::front::glslang::GlslangCompilation; + +pub trait ShaderReflectObject : Sized { + +} + +pub use glslang::Glslang; /// Trait for types that can compile shader sources into a compilation unit. -pub trait ShaderCompilation: Sized { +pub trait ShaderInputCompiler: Sized { /// Compile the input shader source file into a compilation unit. - fn compile(source: &ShaderSource) -> Result; + fn compile(source: &ShaderSource) -> Result; } -impl TryFrom<&'a ShaderSource, Error = ShaderCompileError>> ShaderCompilation for T { - fn compile(source: &ShaderSource) -> Result { - source.try_into() +impl ShaderReflectObject for SpirvCompilation { } +/// A reflectable shader compilation via glslang. +#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] +#[derive(Debug, Clone)] +pub struct SpirvCompilation { + pub(crate) vertex: Vec, + pub(crate) fragment: Vec, +} + +impl SpirvCompilation { + /// Tries to compile SPIR-V from the provided shader source. + pub fn compile(source: &ShaderSource) -> Result { + glslang::compile_spirv(source) } } + +impl TryFrom<&ShaderSource> for SpirvCompilation { + type Error = ShaderCompileError; + + /// Tries to compile SPIR-V from the provided shader source. + fn try_from(source: &ShaderSource) -> Result { + Glslang::compile(source) + } +} + diff --git a/librashader-reflect/src/lib.rs b/librashader-reflect/src/lib.rs index 2bea7c2..5d48e73 100644 --- a/librashader-reflect/src/lib.rs +++ b/librashader-reflect/src/lib.rs @@ -13,10 +13,10 @@ //! use librashader_presets::ShaderPreset; //! use librashader_reflect::back::{CompileReflectShader, FromCompilation}; //! use librashader_reflect::back::targets::SPIRV; -//! use librashader_reflect::front::GlslangCompilation; +//! use librashader_reflect::front::{Glslang, ShaderInputCompiler, SpirvCompilation}; //! use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; //! use librashader_reflect::reflect::semantics::ShaderSemantics; -//! type Artifact = impl CompileReflectShader; +//! type Artifact = impl CompileReflectShader; //! type ShaderPassMeta = ShaderPassArtifact; //! //! // Compile single shader @@ -24,7 +24,7 @@ //! source: &ShaderSource, //! ) -> Result> //! { -//! let compilation = GlslangCompilation::compile(&source)?; +//! let artifact = Glslang::compile(&source)?; //! let spirv = SPIRV::from_compilation(artifact)?; //! Ok(spirv) //! } @@ -32,7 +32,7 @@ //! // Compile preset //! pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec, ShaderSemantics), Box> //! { -//! let (passes, semantics) = SPIRV::compile_preset_passes::>( +//! let (passes, semantics) = SPIRV::compile_preset_passes::>( //! preset.shaders, &preset.textures)?; //! Ok((passes, semantics)) //! } @@ -43,7 +43,7 @@ //! [naga](https://docs.rs/naga/latest/naga/index.html), a pure-Rust shader compiler, when it has //! 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::SpirvCompilation), //! 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(impl_trait_in_assoc_type)] diff --git a/librashader-reflect/src/reflect/cross.rs b/librashader-reflect/src/reflect/cross.rs index 51e4a21..93aa8e4 100644 --- a/librashader-reflect/src/reflect/cross.rs +++ b/librashader-reflect/src/reflect/cross.rs @@ -1,5 +1,5 @@ use crate::error::{SemanticsErrorKind, ShaderCompileError, ShaderReflectError}; -use crate::front::GlslangCompilation; +use crate::front::SpirvCompilation; use crate::reflect::semantics::{ BindingMeta, BindingStage, BufferReflection, MemberOffset, ShaderReflection, ShaderSemantics, TextureBinding, TextureSemanticMap, TextureSemantics, TextureSizeMeta, TypeInfo, @@ -134,7 +134,7 @@ impl ValidateTypeSemantics for TextureSemantics { } } -impl TryFrom<&GlslangCompilation> for CrossReflect +impl TryFrom<&SpirvCompilation> for CrossReflect where T: spirv_cross::spirv::Target, Ast: spirv_cross::spirv::Compile, @@ -142,7 +142,7 @@ where { type Error = ShaderReflectError; - fn try_from(value: &GlslangCompilation) -> Result { + fn try_from(value: &SpirvCompilation) -> Result { let vertex_module = Module::from_words(&value.vertex); let fragment_module = Module::from_words(&value.fragment); @@ -890,7 +890,7 @@ mod test { use rustc_hash::FxHashMap; use crate::back::CompileShader; - use crate::front::GlslangCompilation; + use crate::front::{Glslang, ShaderInputCompiler, SpirvCompilation}; use crate::reflect::semantics::{Semantic, ShaderSemantics, UniformSemantic, UniqueSemantics}; use librashader_preprocess::ShaderSource; use spirv_cross::glsl; @@ -910,7 +910,7 @@ mod test { }), ); } - let spirv = GlslangCompilation::compile(&result).unwrap(); + let spirv = Glslang::compile(&result).unwrap(); let mut reflect = CrossReflect::::try_from(&spirv).unwrap(); let _shader_reflection = reflect .reflect( diff --git a/librashader-reflect/src/reflect/presets.rs b/librashader-reflect/src/reflect/presets.rs index 31c9a60..b0c9a53 100644 --- a/librashader-reflect/src/reflect/presets.rs +++ b/librashader-reflect/src/reflect/presets.rs @@ -1,7 +1,7 @@ use crate::back::targets::OutputTarget; use crate::back::{CompilerBackend, FromCompilation}; use crate::error::{ShaderCompileError, ShaderReflectError}; -use crate::front::ShaderCompilation; +use crate::front::{ShaderInputCompiler, ShaderReflectObject, SpirvCompilation}; use crate::reflect::semantics::{ Semantic, ShaderSemantics, TextureSemantics, UniformSemantic, UniqueSemantics, }; @@ -19,10 +19,10 @@ use rustc_hash::FxHashMap; /// #![feature(type_alias_impl_trait)] /// use librashader_reflect::back::CompileReflectShader; /// use librashader_reflect::back::targets::SPIRV; -/// use librashader_reflect::front::GlslangCompilation; +/// use librashader_reflect::front::SpirvCompilation; /// use librashader_reflect::reflect::presets::ShaderPassArtifact; /// -/// type VulkanPassMeta = ShaderPassArtifact>; +/// type VulkanPassMeta = ShaderPassArtifact>; /// ``` /// /// This allows a runtime to not name the backing type of the compiled artifact if not necessary. @@ -35,44 +35,46 @@ impl CompilePresetTarget for T {} pub trait CompilePresetTarget: OutputTarget { /// Compile passes of a shader preset given the applicable /// shader output target, compilation type, and resulting error. - fn compile_preset_passes( + fn compile_preset_passes( passes: Vec, textures: &[TextureConfig], ) -> Result< ( - Vec>::Output>>, + Vec>::Output>>, ShaderSemantics, ), E, > where + I: ShaderReflectObject, Self: Sized, - Self: FromCompilation, - C: ShaderCompilation, + Self: FromCompilation, + C: ShaderInputCompiler, E: From, E: From, E: From, { - compile_preset_passes::(passes, textures) + compile_preset_passes::(passes, textures) } } /// Compile passes of a shader preset given the applicable /// shader output target, compilation type, and resulting error. -fn compile_preset_passes( +fn compile_preset_passes( passes: Vec, textures: &[TextureConfig], ) -> Result< ( - Vec>::Output>>, + Vec>::Output>>, ShaderSemantics, ), E, > where + I: ShaderReflectObject, T: OutputTarget, - T: FromCompilation, - C: ShaderCompilation, + T: FromCompilation, + C: ShaderInputCompiler, E: From, E: From, E: From, diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index fb3de17..49e7487 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -4,7 +4,7 @@ use librashader_common::{ImageFormat, Size, Viewport}; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::HLSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::GlslangCompilation; +use librashader_reflect::front::{Glslang, SpirvCompilation}; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; use librashader_runtime::image::{Image, ImageError, UVDirection}; @@ -74,18 +74,18 @@ pub(crate) struct FilterCommon { } type ShaderPassMeta = - ShaderPassArtifact + Send>; + ShaderPassArtifact + Send>; fn compile_passes( shaders: Vec, textures: &[TextureConfig], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { - HLSL::compile_preset_passes::, FilterChainError>( + HLSL::compile_preset_passes::, FilterChainError>( shaders, &textures, )? } else { - HLSL::compile_preset_passes::(shaders, &textures)? + HLSL::compile_preset_passes::(shaders, &textures)? }; Ok((passes, semantics)) diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index 820079e..06726ca 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -18,7 +18,7 @@ use librashader_common::{ImageFormat, Size, Viewport}; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::{DXIL, HLSL}; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::GlslangCompilation; +use librashader_reflect::front::{Glslang, SpirvCompilation}; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::{ShaderSemantics, MAX_BINDINGS_COUNT}; use librashader_reflect::reflect::ReflectShader; @@ -145,35 +145,35 @@ impl Drop for FrameResiduals { } type DxilShaderPassMeta = - ShaderPassArtifact + Send>; + ShaderPassArtifact + Send>; fn compile_passes_dxil( shaders: Vec, textures: &[TextureConfig], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { - DXIL::compile_preset_passes::, FilterChainError>( + DXIL::compile_preset_passes::, FilterChainError>( shaders, &textures, )? } else { - DXIL::compile_preset_passes::(shaders, &textures)? + DXIL::compile_preset_passes::(shaders, &textures)? }; Ok((passes, semantics)) } type HlslShaderPassMeta = - ShaderPassArtifact + Send>; + ShaderPassArtifact + Send>; fn compile_passes_hlsl( shaders: Vec, textures: &[TextureConfig], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { - HLSL::compile_preset_passes::, FilterChainError>( + HLSL::compile_preset_passes::, FilterChainError>( shaders, &textures, )? } else { - HLSL::compile_preset_passes::(shaders, &textures)? + HLSL::compile_preset_passes::(shaders, &textures)? }; Ok((passes, semantics)) diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index dee89fd..f6c9801 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -16,7 +16,7 @@ use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::cross::GlslVersion; use librashader_reflect::back::targets::GLSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::GlslangCompilation; +use librashader_reflect::front::{Glslang, SpirvCompilation}; use librashader_reflect::reflect::semantics::{ShaderSemantics, UniformMeta}; use librashader_cache::CachedCompilation; @@ -97,18 +97,18 @@ impl FilterChainImpl { } } -type ShaderPassMeta = ShaderPassArtifact>; +type ShaderPassMeta = ShaderPassArtifact>; fn compile_passes( shaders: Vec, textures: &[TextureConfig], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { - GLSL::compile_preset_passes::, FilterChainError>( + GLSL::compile_preset_passes::, FilterChainError>( shaders, &textures, )? } else { - GLSL::compile_preset_passes::(shaders, &textures)? + GLSL::compile_preset_passes::(shaders, &textures)? }; Ok((passes, semantics)) diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index c6e751a..492cd95 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -17,7 +17,7 @@ use gpu_allocator::vulkan::Allocator; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::SPIRV; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::GlslangCompilation; +use librashader_reflect::front::{Glslang, SpirvCompilation}; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; @@ -208,18 +208,18 @@ impl Drop for FrameResiduals { } type ShaderPassMeta = - ShaderPassArtifact + Send>; + ShaderPassArtifact + Send>; fn compile_passes( shaders: Vec, textures: &[TextureConfig], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { - SPIRV::compile_preset_passes::, FilterChainError>( + SPIRV::compile_preset_passes::, FilterChainError>( shaders, &textures, )? } else { - SPIRV::compile_preset_passes::(shaders, &textures)? + SPIRV::compile_preset_passes::(shaders, &textures)? }; Ok((passes, semantics)) diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 3ec6a8a..45f4b7c 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -1,7 +1,7 @@ use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::WGSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::GlslangCompilation; +use librashader_reflect::front::{Glslang, SpirvCompilation}; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; @@ -38,13 +38,13 @@ use crate::samplers::SamplerSet; use crate::texture::{InputImage, OwnedImage}; type ShaderPassMeta = - ShaderPassArtifact + Send>; + ShaderPassArtifact + Send>; fn compile_passes( shaders: Vec, textures: &[TextureConfig], ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = - WGSL::compile_preset_passes::(shaders, &textures)?; + WGSL::compile_preset_passes::(shaders, &textures)?; Ok((passes, semantics)) } diff --git a/librashader/src/lib.rs b/librashader/src/lib.rs index 431c180..320631b 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -150,7 +150,7 @@ pub mod reflect { FromCompilation, ShaderCompilerOutput, }; - pub use librashader_reflect::front::GlslangCompilation; + pub use librashader_reflect::front::SpirvCompilation; /// Reflection via SPIRV-Cross. #[cfg(feature = "reflect-cross")] @@ -196,7 +196,7 @@ pub mod reflect { pub use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; - pub use librashader_reflect::front::ShaderCompilation; + pub use librashader_reflect::front::ShaderInputCompiler; #[doc(hidden)] #[cfg(feature = "internal")] /// Helper methods for runtimes.