diff --git a/librashader-reflect/src/back/dxil.rs b/librashader-reflect/src/back/dxil.rs index 988dd6f..b35ea46 100644 --- a/librashader-reflect/src/back/dxil.rs +++ b/librashader-reflect/src/back/dxil.rs @@ -1,11 +1,12 @@ use crate::back::spirv::WriteSpirV; use crate::back::targets::{OutputTarget, DXIL}; -use crate::back::{CompileShader, CompilerBackend, FromCompilation, ShaderCompilerOutput}; +use crate::back::{ + CompileReflectShader, CompileShader, CompilerBackend, FromCompilation, ShaderCompilerOutput, +}; use crate::error::{ShaderCompileError, ShaderReflectError}; use crate::front::SpirvCompilation; use crate::reflect::cross::glsl::GlslReflect; use crate::reflect::cross::SpirvCross; -use crate::reflect::ReflectShader; pub use spirv_to_dxil::DxilObject; pub use spirv_to_dxil::ShaderModel; use spirv_to_dxil::{ @@ -20,8 +21,7 @@ impl FromCompilation for DXIL { type Target = DXIL; type Options = Option; type Context = (); - type Output = impl CompileShader - + ReflectShader; + type Output = impl CompileReflectShader; fn from_compilation( compile: SpirvCompilation, @@ -88,4 +88,11 @@ impl CompileShader for WriteSpirV { context: (), }) } + + fn compile_boxed( + self: Box, + options: Self::Options, + ) -> Result, ShaderCompileError> { + >::compile(*self, options) + } } diff --git a/librashader-reflect/src/back/glsl.rs b/librashader-reflect/src/back/glsl.rs index 64d8823..6351c31 100644 --- a/librashader-reflect/src/back/glsl.rs +++ b/librashader-reflect/src/back/glsl.rs @@ -1,9 +1,8 @@ use crate::back::targets::GLSL; -use crate::back::{CompileShader, CompilerBackend, FromCompilation}; +use crate::back::{CompileReflectShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; use crate::front::SpirvCompilation; use crate::reflect::cross::{CompiledProgram, SpirvCross}; -use crate::reflect::ReflectShader; /// The GLSL version to target. pub use spirv_cross2::compile::glsl::GlslVersion; @@ -22,8 +21,7 @@ impl FromCompilation for GLSL { type Target = GLSL; type Options = GlslVersion; type Context = CrossGlslContext; - type Output = impl CompileShader - + ReflectShader; + type Output = impl CompileReflectShader; fn from_compilation( compile: SpirvCompilation, diff --git a/librashader-reflect/src/back/hlsl.rs b/librashader-reflect/src/back/hlsl.rs index 1b4da9b..6417626 100644 --- a/librashader-reflect/src/back/hlsl.rs +++ b/librashader-reflect/src/back/hlsl.rs @@ -1,10 +1,9 @@ use crate::back::targets::HLSL; -use crate::back::{CompileShader, CompilerBackend, FromCompilation}; +use crate::back::{CompileReflectShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; use crate::front::SpirvCompilation; use crate::reflect::cross::hlsl::HlslReflect; use crate::reflect::cross::{CompiledProgram, SpirvCross}; -use crate::reflect::ReflectShader; /// The HLSL shader model version to target. pub use spirv_cross2::compile::hlsl::HlslShaderModel; @@ -108,8 +107,7 @@ impl FromCompilation for HLSL { type Target = HLSL; type Options = Option; type Context = CrossHlslContext; - type Output = impl CompileShader - + ReflectShader; + type Output = impl CompileReflectShader; fn from_compilation( compile: SpirvCompilation, diff --git a/librashader-reflect/src/back/msl.rs b/librashader-reflect/src/back/msl.rs index 1c9a7fa..6fed3b7 100644 --- a/librashader-reflect/src/back/msl.rs +++ b/librashader-reflect/src/back/msl.rs @@ -1,5 +1,5 @@ use crate::back::targets::MSL; -use crate::back::{CompileShader, CompilerBackend, FromCompilation}; +use crate::back::{CompileReflectShader, CompileShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; use crate::front::SpirvCompilation; use crate::reflect::cross::msl::MslReflect; @@ -57,8 +57,7 @@ impl FromCompilation for MSL { type Target = MSL; type Options = Option; type Context = NagaMslContext; - type Output = impl CompileShader - + ReflectShader; + type Output = impl CompileReflectShader; fn from_compilation( compile: SpirvCompilation, diff --git a/librashader-reflect/src/back/spirv.rs b/librashader-reflect/src/back/spirv.rs index 9881bf1..5ed8fe3 100644 --- a/librashader-reflect/src/back/spirv.rs +++ b/librashader-reflect/src/back/spirv.rs @@ -63,6 +63,17 @@ impl CompileShader for WriteSpirV { context: (), }) } + + fn compile_boxed( + self: Box, + _options: Self::Options, + ) -> Result, Self::Context>, ShaderCompileError> { + Ok(ShaderCompilerOutput { + vertex: self.vertex, + fragment: self.fragment, + context: (), + }) + } } /// The context for a SPIRV compilation via Naga diff --git a/librashader-reflect/src/back/wgsl.rs b/librashader-reflect/src/back/wgsl.rs index 00d5227..286f13f 100644 --- a/librashader-reflect/src/back/wgsl.rs +++ b/librashader-reflect/src/back/wgsl.rs @@ -1,9 +1,8 @@ use crate::back::targets::WGSL; -use crate::back::{CompileShader, CompilerBackend, FromCompilation}; +use crate::back::{CompileReflectShader, CompilerBackend, FromCompilation}; use crate::error::ShaderReflectError; use crate::front::SpirvCompilation; use crate::reflect::naga::{Naga, NagaLoweringOptions, NagaReflect}; -use crate::reflect::ReflectShader; use naga::Module; /// The context for a WGSL compilation via Naga @@ -16,8 +15,7 @@ impl FromCompilation for WGSL { type Target = WGSL; type Options = NagaLoweringOptions; type Context = NagaWgslContext; - type Output = impl CompileShader - + ReflectShader; + type Output = impl CompileReflectShader; fn from_compilation( compile: SpirvCompilation, diff --git a/librashader-reflect/src/reflect/cross/msl.rs b/librashader-reflect/src/reflect/cross/msl.rs index 131f3a2..4479a7f 100644 --- a/librashader-reflect/src/reflect/cross/msl.rs +++ b/librashader-reflect/src/reflect/cross/msl.rs @@ -101,6 +101,13 @@ impl CompileShader for CrossReflect { }, }) } + + fn compile_boxed( + self: Box, + options: Self::Options, + ) -> Result, ShaderCompileError> { + as CompileShader>::compile(*self, options) + } } #[cfg(test)]