reflect: allow specifying output toolchain

This commit is contained in:
chyyran 2024-02-10 20:46:35 -05:00 committed by Ronny Chan
parent 252f685967
commit b98d86a940
15 changed files with 148 additions and 100 deletions

View file

@ -66,11 +66,14 @@ where
}
#[cfg(all(target_os = "windows", feature = "d3d"))]
impl FromCompilation<CachedCompilation<SpirvCompilation>> for DXIL {
type Target = <DXIL as FromCompilation<SpirvCompilation>>::Target;
type Options = <DXIL as FromCompilation<SpirvCompilation>>::Options;
type Context = <DXIL as FromCompilation<SpirvCompilation>>::Context;
type Output = <DXIL as FromCompilation<SpirvCompilation>>::Output;
impl<T> FromCompilation<CachedCompilation<SpirvCompilation>, T> for DXIL
where
DXIL: FromCompilation<SpirvCompilation, T>,
{
type Target = <DXIL as FromCompilation<SpirvCompilation, T>>::Target;
type Options = <DXIL as FromCompilation<SpirvCompilation, T>>::Options;
type Context = <DXIL as FromCompilation<SpirvCompilation, T>>::Context;
type Output = <DXIL as FromCompilation<SpirvCompilation, T>>::Output;
fn from_compilation(
compile: CachedCompilation<SpirvCompilation>,
@ -79,11 +82,14 @@ impl FromCompilation<CachedCompilation<SpirvCompilation>> for DXIL {
}
}
impl FromCompilation<CachedCompilation<SpirvCompilation>> for HLSL {
type Target = <HLSL as FromCompilation<SpirvCompilation>>::Target;
type Options = <HLSL as FromCompilation<SpirvCompilation>>::Options;
type Context = <HLSL as FromCompilation<SpirvCompilation>>::Context;
type Output = <HLSL as FromCompilation<SpirvCompilation>>::Output;
impl<T> FromCompilation<CachedCompilation<SpirvCompilation>, T> for HLSL
where
HLSL: FromCompilation<SpirvCompilation, T>,
{
type Target = <HLSL as FromCompilation<SpirvCompilation, T>>::Target;
type Options = <HLSL as FromCompilation<SpirvCompilation, T>>::Options;
type Context = <HLSL as FromCompilation<SpirvCompilation, T>>::Context;
type Output = <HLSL as FromCompilation<SpirvCompilation, T>>::Output;
fn from_compilation(
compile: CachedCompilation<SpirvCompilation>,
@ -92,11 +98,14 @@ impl FromCompilation<CachedCompilation<SpirvCompilation>> for HLSL {
}
}
impl FromCompilation<CachedCompilation<SpirvCompilation>> for GLSL {
type Target = <GLSL as FromCompilation<SpirvCompilation>>::Target;
type Options = <GLSL as FromCompilation<SpirvCompilation>>::Options;
type Context = <GLSL as FromCompilation<SpirvCompilation>>::Context;
type Output = <GLSL as FromCompilation<SpirvCompilation>>::Output;
impl<T> FromCompilation<CachedCompilation<SpirvCompilation>, T> for GLSL
where
GLSL: FromCompilation<SpirvCompilation, T>,
{
type Target = <GLSL as FromCompilation<SpirvCompilation, T>>::Target;
type Options = <GLSL as FromCompilation<SpirvCompilation, T>>::Options;
type Context = <GLSL as FromCompilation<SpirvCompilation, T>>::Context;
type Output = <GLSL as FromCompilation<SpirvCompilation, T>>::Output;
fn from_compilation(
compile: CachedCompilation<SpirvCompilation>,
@ -105,11 +114,14 @@ impl FromCompilation<CachedCompilation<SpirvCompilation>> for GLSL {
}
}
impl FromCompilation<CachedCompilation<SpirvCompilation>> for SPIRV {
type Target = <SPIRV as FromCompilation<SpirvCompilation>>::Target;
type Options = <SPIRV as FromCompilation<SpirvCompilation>>::Options;
type Context = <SPIRV as FromCompilation<SpirvCompilation>>::Context;
type Output = <SPIRV as FromCompilation<SpirvCompilation>>::Output;
impl<T> FromCompilation<CachedCompilation<SpirvCompilation>, T> for SPIRV
where
SPIRV: FromCompilation<SpirvCompilation, T>,
{
type Target = <SPIRV as FromCompilation<SpirvCompilation, T>>::Target;
type Options = <SPIRV as FromCompilation<SpirvCompilation, T>>::Options;
type Context = <SPIRV as FromCompilation<SpirvCompilation, T>>::Context;
type Output = <SPIRV as FromCompilation<SpirvCompilation, T>>::Output;
fn from_compilation(
compile: CachedCompilation<SpirvCompilation>,

View file

@ -2,7 +2,7 @@ use crate::back::targets::{GLSL, HLSL};
use crate::back::{CompileShader, CompilerBackend, FromCompilation};
use crate::error::ShaderReflectError;
use crate::front::SpirvCompilation;
use crate::reflect::cross::{CompiledProgram, GlslReflect, HlslReflect, SpirvCross};
use crate::reflect::cross::{CompiledProgram, SpirvCross};
use crate::reflect::{ReflectShader, ShaderOutputCompiler};
/// The GLSL version to target.
@ -19,7 +19,7 @@ pub struct CrossGlslContext {
pub artifact: CompiledProgram<spirv_cross::glsl::Target>,
}
impl FromCompilation<SpirvCompilation> for GLSL {
impl FromCompilation<SpirvCompilation, SpirvCross<GLSL>> for GLSL {
type Target = GLSL;
type Options = GlslVersion;
type Context = CrossGlslContext;
@ -30,9 +30,7 @@ impl FromCompilation<SpirvCompilation> for GLSL {
compile: SpirvCompilation,
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
let backend = SpirvCross::<GLSL>::create_reflection(compile)?;
Ok(CompilerBackend {
backend,
})
Ok(CompilerBackend { backend })
}
}
@ -42,7 +40,7 @@ pub struct CrossHlslContext {
pub artifact: CompiledProgram<spirv_cross::hlsl::Target>,
}
impl FromCompilation<SpirvCompilation> for HLSL {
impl FromCompilation<SpirvCompilation, SpirvCross<HLSL>> for HLSL {
type Target = HLSL;
type Options = Option<HlslShaderModel>;
type Context = CrossHlslContext;

View file

@ -9,14 +9,14 @@ use spirv_to_dxil::{
use crate::back::targets::{OutputTarget, DXIL};
use crate::error::{ShaderCompileError, ShaderReflectError};
use crate::front::SpirvCompilation;
use crate::reflect::cross::GlslReflect;
use crate::reflect::{ReflectShader, ShaderOutputCompiler};
use crate::reflect::cross::{GlslReflect, SpirvCross};
use crate::reflect::ReflectShader;
impl OutputTarget for DXIL {
type Output = DxilObject;
}
impl FromCompilation<SpirvCompilation> for DXIL {
impl FromCompilation<SpirvCompilation, SpirvCross<DXIL>> for DXIL {
type Target = DXIL;
type Options = Option<ShaderModel>;
type Context = ();
@ -26,7 +26,7 @@ impl FromCompilation<SpirvCompilation> for DXIL {
fn from_compilation(
compile: SpirvCompilation,
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
let reflect = GlslReflect::new().create_reflection(compile)?;
let reflect = GlslReflect::try_from(&compile)?;
let vertex = compile.vertex;
let fragment = compile.fragment;
Ok(CompilerBackend {

View file

@ -42,26 +42,26 @@ pub trait CompileShader<T: OutputTarget> {
///
/// This trait is automatically implemented for reflected outputs that have [`FromCompilation`](crate::back::FromCompilation) implement
/// for a given target that also implement [`CompileShader`](crate::back::CompileShader) for that target.
pub trait CompileReflectShader<T: OutputTarget, C>:
pub trait CompileReflectShader<T: OutputTarget, C, O>:
CompileShader<
T,
Options = <T as FromCompilation<C>>::Options,
Context = <T as FromCompilation<C>>::Context,
Options = <T as FromCompilation<C, O>>::Options,
Context = <T as FromCompilation<C, O>>::Context,
> + ReflectShader
where
T: FromCompilation<C>,
T: FromCompilation<C, O>,
{
}
impl<T, C, O> CompileReflectShader<T, C> for O
impl<T, C, O, R> CompileReflectShader<T, C, R> for O
where
T: OutputTarget,
T: FromCompilation<C>,
T: FromCompilation<C, R>,
O: ReflectShader,
O: CompileShader<
T,
Options = <T as FromCompilation<C>>::Options,
Context = <T as FromCompilation<C>>::Context,
Options = <T as FromCompilation<C, R>>::Options,
Context = <T as FromCompilation<C, R>>::Context,
>,
{
}
@ -83,7 +83,7 @@ where
}
/// A trait for reflectable compilations that can be transformed into an object ready for reflection or compilation.
pub trait FromCompilation<T> {
pub trait FromCompilation<T, R> {
/// The target that the transformed object is expected to compile for.
type Target: OutputTarget;
/// Options provided to the compiler.

View file

@ -2,7 +2,7 @@ use crate::back::targets::SPIRV;
use crate::back::{CompileShader, CompilerBackend, FromCompilation, ShaderCompilerOutput};
use crate::error::{ShaderCompileError, ShaderReflectError};
use crate::front::SpirvCompilation;
use crate::reflect::cross::GlslReflect;
use crate::reflect::cross::{GlslReflect, SpirvCross};
use crate::reflect::semantics::ShaderSemantics;
use crate::reflect::{ReflectShader, ShaderReflection};
@ -13,7 +13,7 @@ pub(crate) struct WriteSpirV {
pub(crate) fragment: Vec<u32>,
}
impl FromCompilation<SpirvCompilation> for SPIRV {
impl FromCompilation<SpirvCompilation, SpirvCross<SPIRV>> for SPIRV {
type Target = SPIRV;
type Options = Option<()>;
type Context = ();

View file

@ -22,7 +22,7 @@ pub struct WgslCompileOptions {
pub sampler_bind_group: u32,
}
impl FromCompilation<SpirvCompilation> for WGSL {
impl FromCompilation<SpirvCompilation, Naga> for WGSL {
type Target = WGSL;
type Options = WgslCompileOptions;
type Context = NagaWgslContext;

View file

@ -1,5 +1,3 @@
use std::borrow::Borrow;
use std::marker::PhantomData;
use crate::error::{SemanticsErrorKind, ShaderCompileError, ShaderReflectError};
use crate::front::SpirvCompilation;
use crate::reflect::semantics::{
@ -9,18 +7,19 @@ use crate::reflect::semantics::{
MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE,
};
use crate::reflect::{align_uniform_size, ReflectShader, ShaderOutputCompiler};
use std::borrow::Borrow;
use std::marker::PhantomData;
use std::ops::Deref;
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
use spirv_cross::{glsl, hlsl, ErrorCode};
use crate::back::cross::{CrossGlslContext, CrossHlslContext, HlslShaderModel};
use crate::back::targets::{GLSL, HLSL, OutputTarget};
use crate::back::targets::{OutputTarget, DXIL, GLSL, HLSL, SPIRV};
use crate::back::{CompileShader, ShaderCompilerOutput};
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
pub trait SpirvCrossTarget {
trait SpirvCrossTarget {
type CrossTarget: spirv_cross::spirv::Target;
}
@ -28,30 +27,43 @@ impl SpirvCrossTarget for HLSL {
type CrossTarget = spirv_cross::hlsl::Target;
}
impl SpirvCrossTarget for SPIRV {
type CrossTarget = spirv_cross::glsl::Target;
}
impl SpirvCrossTarget for GLSL {
type CrossTarget = spirv_cross::glsl::Target;
}
impl SpirvCrossTarget for DXIL {
type CrossTarget = spirv_cross::glsl::Target;
}
#[allow(private_bounds)]
pub struct SpirvCross<T: OutputTarget + SpirvCrossTarget>(PhantomData<T>);
pub(crate) type HlslReflect = CrossReflect<hlsl::Target>;
pub(crate) type GlslReflect = CrossReflect<glsl::Target>;
impl<T: OutputTarget + SpirvCrossTarget, Opt, Ctx>
ShaderOutputCompiler<SpirvCompilation, T, Opt, Ctx> for SpirvCross<T>
ShaderOutputCompiler<SpirvCompilation, T, Opt, Ctx> for SpirvCross<T>
// where Spv: spirv_cross::spirv::Target,
// Ast<Spv>: spirv_cross::spirv::Compile<Spv>,
// Ast<Spv>: spirv_cross::spirv::Parse<Spv>,
where CrossReflect<<T as SpirvCrossTarget>::CrossTarget>
: CompileShader<T, Options = Opt, Context=Ctx>,
where
CrossReflect<<T as SpirvCrossTarget>::CrossTarget>:
CompileShader<T, Options = Opt, Context = Ctx>,
<T as SpirvCrossTarget>::CrossTarget: spirv_cross::spirv::Target,
Ast<<T as SpirvCrossTarget>::CrossTarget>: spirv_cross::spirv::Compile<<T as SpirvCrossTarget>::CrossTarget>,
Ast<<T as SpirvCrossTarget>::CrossTarget>: spirv_cross::spirv::Parse<<T as SpirvCrossTarget>::CrossTarget>,
Ast<<T as SpirvCrossTarget>::CrossTarget>:
spirv_cross::spirv::Compile<<T as SpirvCrossTarget>::CrossTarget>,
Ast<<T as SpirvCrossTarget>::CrossTarget>:
spirv_cross::spirv::Parse<<T as SpirvCrossTarget>::CrossTarget>,
{
fn create_reflection(compiled: SpirvCompilation)
-> Result<impl ReflectShader + CompileShader<T, Options = Opt, Context = Ctx>,
ShaderReflectError> {
fn create_reflection(
compiled: SpirvCompilation,
) -> Result<
impl ReflectShader + CompileShader<T, Options = Opt, Context = Ctx>,
ShaderReflectError,
> {
let compiled = compiled.borrow();
let vertex_module = Module::from_words(&compiled.vertex);
let fragment_module = Module::from_words(&compiled.fragment);
@ -65,9 +77,11 @@ where CrossReflect<<T as SpirvCrossTarget>::CrossTarget>
// This is "probably" OK.
unsafe impl<T: Send + spirv_cross::spirv::Target> Send for CrossReflect<T>
where Ast<T>: spirv_cross::spirv::Compile<T>,
where
Ast<T>: spirv_cross::spirv::Compile<T>,
Ast<T>: spirv_cross::spirv::Parse<T>,
{}
{
}
pub(crate) struct CrossReflect<T>
where
@ -100,8 +114,6 @@ where
pub fragment: CompiledAst<T>,
}
impl ValidateTypeSemantics<Type> for UniqueSemantics {
fn validate_type(&self, ty: &Type) -> Option<TypeInfo> {
let (Type::Float {

View file

@ -1,4 +1,3 @@
use std::borrow::Borrow;
use crate::error::ShaderReflectError;
use semantics::ShaderSemantics;

View file

@ -1,7 +1,7 @@
mod lower_samplers;
use std::borrow::Borrow;
use crate::error::{SemanticsErrorKind, ShaderReflectError};
use std::borrow::Borrow;
use crate::back::targets::OutputTarget;
use crate::back::CompileShader;
@ -36,7 +36,7 @@ where
compile: SpirvCompilation,
) -> Result<
impl ReflectShader + CompileShader<T, Options = Opt, Context = Ctx>,
ShaderReflectError
ShaderReflectError,
> {
fn lower_fragment_shader(words: &[u32]) -> Vec<u32> {
let mut loader = rspirv::dr::Loader::new();

View file

@ -18,11 +18,12 @@ use rustc_hash::FxHashMap;
/// ```rust
/// #![feature(type_alias_impl_trait)]
/// use librashader_reflect::back::CompileReflectShader;
/// use librashader_reflect::back::targets::SPIRV;
/// use librashader_reflect::back::targets::{GLSL, SPIRV};
/// use librashader_reflect::front::SpirvCompilation;
/// use librashader_reflect::reflect::cross::SpirvCross;
/// use librashader_reflect::reflect::presets::ShaderPassArtifact;
///
/// type VulkanPassMeta = ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation>>;
/// type VulkanPassMeta = ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross<GLSL>>>;
/// ```
///
/// This allows a runtime to not name the backing type of the compiled artifact if not necessary.
@ -35,12 +36,12 @@ impl<T: OutputTarget> 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<C, I, E>(
fn compile_preset_passes<C, I, R, E>(
passes: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
) -> Result<
(
Vec<ShaderPassArtifact<<Self as FromCompilation<I>>::Output>>,
Vec<ShaderPassArtifact<<Self as FromCompilation<I, R>>::Output>>,
ShaderSemantics,
),
E,
@ -48,24 +49,24 @@ pub trait CompilePresetTarget: OutputTarget {
where
I: ShaderReflectObject,
Self: Sized,
Self: FromCompilation<I>,
Self: FromCompilation<I, R>,
C: ShaderInputCompiler<I>,
E: From<PreprocessError>,
E: From<ShaderReflectError>,
E: From<ShaderCompileError>,
{
compile_preset_passes::<Self, C, I, E>(passes, textures)
compile_preset_passes::<Self, C, I, R, E>(passes, textures)
}
}
/// Compile passes of a shader preset given the applicable
/// shader output target, compilation type, and resulting error.
fn compile_preset_passes<T, C, I, E>(
fn compile_preset_passes<T, C, I, R, E>(
passes: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
) -> Result<
(
Vec<ShaderPassArtifact<<T as FromCompilation<I>>::Output>>,
Vec<ShaderPassArtifact<<T as FromCompilation<I, R>>::Output>>,
ShaderSemantics,
),
E,
@ -73,7 +74,7 @@ fn compile_preset_passes<T, C, I, E>(
where
I: ShaderReflectObject,
T: OutputTarget,
T: FromCompilation<I>,
T: FromCompilation<I, R>,
C: ShaderInputCompiler<I>,
E: From<PreprocessError>,
E: From<ShaderReflectError>,

View file

@ -25,6 +25,7 @@ use crate::{error, util, D3D11OutputView};
use librashader_cache::cache_shader_object;
use librashader_cache::CachedCompilation;
use librashader_presets::context::VideoDriver;
use librashader_reflect::reflect::cross::SpirvCross;
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
use librashader_runtime::binding::{BindingUtil, TextureInput};
use librashader_runtime::framebuffer::FramebufferInit;
@ -73,18 +74,22 @@ pub(crate) struct FilterCommon {
pub(crate) draw_quad: DrawQuad,
}
type ShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation> + Send>;
type ShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross<HLSL>> + Send>;
fn compile_passes(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
HLSL::compile_preset_passes::<Glslang, CachedCompilation<SpirvCompilation>, FilterChainError>(
shaders, &textures,
)?
HLSL::compile_preset_passes::<
Glslang,
CachedCompilation<SpirvCompilation>,
SpirvCross<HLSL>,
FilterChainError,
>(shaders, &textures)?
} else {
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<HLSL>, FilterChainError>(
shaders, &textures,
)?
};

View file

@ -48,6 +48,7 @@ use windows::Win32::System::Threading::{CreateEventA, WaitForSingleObject, INFIN
use librashader_cache::CachedCompilation;
use librashader_presets::context::VideoDriver;
use librashader_reflect::reflect::cross::SpirvCross;
use librashader_runtime::framebuffer::FramebufferInit;
use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::scaling::ScaleFramebuffer;
@ -145,18 +146,21 @@ impl Drop for FrameResiduals {
}
type DxilShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation> + Send>;
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross<DXIL>> + Send>;
fn compile_passes_dxil(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
disable_cache: bool,
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
DXIL::compile_preset_passes::<Glslang, CachedCompilation<SpirvCompilation>, FilterChainError>(
shaders, &textures,
)?
DXIL::compile_preset_passes::<
Glslang,
CachedCompilation<SpirvCompilation>,
SpirvCross<DXIL>,
FilterChainError,
>(shaders, &textures)?
} else {
DXIL::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
DXIL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<DXIL>, FilterChainError>(
shaders, &textures,
)?
};
@ -164,18 +168,21 @@ fn compile_passes_dxil(
Ok((passes, semantics))
}
type HlslShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation> + Send>;
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross<HLSL>> + Send>;
fn compile_passes_hlsl(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
disable_cache: bool,
) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
HLSL::compile_preset_passes::<Glslang, CachedCompilation<SpirvCompilation>, FilterChainError>(
shaders, &textures,
)?
HLSL::compile_preset_passes::<
Glslang,
CachedCompilation<SpirvCompilation>,
SpirvCross<HLSL>,
FilterChainError,
>(shaders, &textures)?
} else {
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<HLSL>, FilterChainError>(
shaders, &textures,
)?
};

View file

@ -20,6 +20,7 @@ use librashader_reflect::front::{Glslang, SpirvCompilation};
use librashader_reflect::reflect::semantics::{ShaderSemantics, UniformMeta};
use librashader_cache::CachedCompilation;
use librashader_reflect::reflect::cross::SpirvCross;
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
use librashader_reflect::reflect::ReflectShader;
use librashader_runtime::binding::BindingUtil;
@ -97,18 +98,22 @@ impl<T: GLInterface> FilterChainImpl<T> {
}
}
type ShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation>>;
type ShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross<GLSL>>>;
fn compile_passes(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
GLSL::compile_preset_passes::<Glslang, CachedCompilation<SpirvCompilation>, FilterChainError>(
shaders, &textures,
)?
GLSL::compile_preset_passes::<
Glslang,
CachedCompilation<SpirvCompilation>,
SpirvCross<GLSL>,
FilterChainError,
>(shaders, &textures)?
} else {
GLSL::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
GLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<GLSL>, FilterChainError>(
shaders, &textures,
)?
};

View file

@ -34,6 +34,7 @@ use std::sync::Arc;
use librashader_cache::CachedCompilation;
use librashader_presets::context::VideoDriver;
use librashader_reflect::reflect::cross::SpirvCross;
use librashader_runtime::framebuffer::FramebufferInit;
use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::scaling::ScaleFramebuffer;
@ -207,7 +208,9 @@ impl Drop for FrameResiduals {
}
}
type ShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation> + Send>;
type ShaderPassMeta = ShaderPassArtifact<
impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross<SPIRV>> + Send,
>;
fn compile_passes(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
@ -217,12 +220,16 @@ fn compile_passes(
SPIRV::compile_preset_passes::<
Glslang,
CachedCompilation<SpirvCompilation>,
SpirvCross<SPIRV>,
FilterChainError,
>(shaders, &textures)?
} else {
SPIRV::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
shaders, &textures,
)?
SPIRV::compile_preset_passes::<
Glslang,
SpirvCompilation,
SpirvCross<SPIRV>,
FilterChainError,
>(shaders, &textures)?
};
Ok((passes, semantics))

View file

@ -21,6 +21,7 @@ use crate::buffer::WgpuStagedBuffer;
use crate::draw_quad::DrawQuad;
use librashader_common::{FilterMode, ImageFormat, Size, Viewport, WrapMode};
use librashader_reflect::back::wgsl::WgslCompileOptions;
use librashader_reflect::reflect::naga::Naga;
use librashader_runtime::framebuffer::FramebufferInit;
use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::scaling::ScaleFramebuffer;
@ -37,13 +38,14 @@ use crate::options::{FilterChainOptionsWgpu, FrameOptionsWgpu};
use crate::samplers::SamplerSet;
use crate::texture::{InputImage, OwnedImage};
type ShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<WGSL, SpirvCompilation> + Send>;
type ShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>;
fn compile_passes(
shaders: Vec<ShaderPassConfig>,
textures: &[TextureConfig],
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) =
WGSL::compile_preset_passes::<Glslang, SpirvCompilation, FilterChainError>(
WGSL::compile_preset_passes::<Glslang, SpirvCompilation, Naga, FilterChainError>(
shaders, &textures,
)?;
Ok((passes, semantics))