reflect: remove ShaderOutputCompiler and just delegate to FromCompilation
This commit is contained in:
parent
b98d86a940
commit
e1f62fc984
|
@ -2,8 +2,8 @@ use crate::back::targets::{GLSL, HLSL};
|
||||||
use crate::back::{CompileShader, CompilerBackend, FromCompilation};
|
use crate::back::{CompileShader, CompilerBackend, FromCompilation};
|
||||||
use crate::error::ShaderReflectError;
|
use crate::error::ShaderReflectError;
|
||||||
use crate::front::SpirvCompilation;
|
use crate::front::SpirvCompilation;
|
||||||
use crate::reflect::cross::{CompiledProgram, SpirvCross};
|
use crate::reflect::cross::{CompiledProgram, GlslReflect, HlslReflect, SpirvCross};
|
||||||
use crate::reflect::{ReflectShader, ShaderOutputCompiler};
|
use crate::reflect::ReflectShader;
|
||||||
|
|
||||||
/// The GLSL version to target.
|
/// The GLSL version to target.
|
||||||
pub use spirv_cross::glsl::Version as GlslVersion;
|
pub use spirv_cross::glsl::Version as GlslVersion;
|
||||||
|
@ -19,7 +19,7 @@ pub struct CrossGlslContext {
|
||||||
pub artifact: CompiledProgram<spirv_cross::glsl::Target>,
|
pub artifact: CompiledProgram<spirv_cross::glsl::Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromCompilation<SpirvCompilation, SpirvCross<GLSL>> for GLSL {
|
impl FromCompilation<SpirvCompilation, SpirvCross> for GLSL {
|
||||||
type Target = GLSL;
|
type Target = GLSL;
|
||||||
type Options = GlslVersion;
|
type Options = GlslVersion;
|
||||||
type Context = CrossGlslContext;
|
type Context = CrossGlslContext;
|
||||||
|
@ -29,8 +29,9 @@ impl FromCompilation<SpirvCompilation, SpirvCross<GLSL>> for GLSL {
|
||||||
fn from_compilation(
|
fn from_compilation(
|
||||||
compile: SpirvCompilation,
|
compile: SpirvCompilation,
|
||||||
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
||||||
let backend = SpirvCross::<GLSL>::create_reflection(compile)?;
|
Ok(CompilerBackend {
|
||||||
Ok(CompilerBackend { backend })
|
backend: GlslReflect::try_from(&compile)?,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ pub struct CrossHlslContext {
|
||||||
pub artifact: CompiledProgram<spirv_cross::hlsl::Target>,
|
pub artifact: CompiledProgram<spirv_cross::hlsl::Target>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromCompilation<SpirvCompilation, SpirvCross<HLSL>> for HLSL {
|
impl FromCompilation<SpirvCompilation, SpirvCross> for HLSL {
|
||||||
type Target = HLSL;
|
type Target = HLSL;
|
||||||
type Options = Option<HlslShaderModel>;
|
type Options = Option<HlslShaderModel>;
|
||||||
type Context = CrossHlslContext;
|
type Context = CrossHlslContext;
|
||||||
|
@ -51,7 +52,7 @@ impl FromCompilation<SpirvCompilation, SpirvCross<HLSL>> for HLSL {
|
||||||
compile: SpirvCompilation,
|
compile: SpirvCompilation,
|
||||||
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
||||||
Ok(CompilerBackend {
|
Ok(CompilerBackend {
|
||||||
backend: SpirvCross::<HLSL>::create_reflection(compile)?,
|
backend: HlslReflect::try_from(&compile)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ impl OutputTarget for DXIL {
|
||||||
type Output = DxilObject;
|
type Output = DxilObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromCompilation<SpirvCompilation, SpirvCross<DXIL>> for DXIL {
|
impl FromCompilation<SpirvCompilation, SpirvCross> for DXIL {
|
||||||
type Target = DXIL;
|
type Target = DXIL;
|
||||||
type Options = Option<ShaderModel>;
|
type Options = Option<ShaderModel>;
|
||||||
type Context = ();
|
type Context = ();
|
||||||
|
|
|
@ -42,26 +42,26 @@ pub trait CompileShader<T: OutputTarget> {
|
||||||
///
|
///
|
||||||
/// This trait is automatically implemented for reflected outputs that have [`FromCompilation`](crate::back::FromCompilation) implement
|
/// 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.
|
/// for a given target that also implement [`CompileShader`](crate::back::CompileShader) for that target.
|
||||||
pub trait CompileReflectShader<T: OutputTarget, C, O>:
|
pub trait CompileReflectShader<T: OutputTarget, C, S>:
|
||||||
CompileShader<
|
CompileShader<
|
||||||
T,
|
T,
|
||||||
Options = <T as FromCompilation<C, O>>::Options,
|
Options = <T as FromCompilation<C, S>>::Options,
|
||||||
Context = <T as FromCompilation<C, O>>::Context,
|
Context = <T as FromCompilation<C, S>>::Context,
|
||||||
> + ReflectShader
|
> + ReflectShader
|
||||||
where
|
where
|
||||||
T: FromCompilation<C, O>,
|
T: FromCompilation<C, S>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, C, O, R> CompileReflectShader<T, C, R> for O
|
impl<T, C, O, S> CompileReflectShader<T, C, S> for O
|
||||||
where
|
where
|
||||||
T: OutputTarget,
|
T: OutputTarget,
|
||||||
T: FromCompilation<C, R>,
|
T: FromCompilation<C, S>,
|
||||||
O: ReflectShader,
|
O: ReflectShader,
|
||||||
O: CompileShader<
|
O: CompileShader<
|
||||||
T,
|
T,
|
||||||
Options = <T as FromCompilation<C, R>>::Options,
|
Options = <T as FromCompilation<C, S>>::Options,
|
||||||
Context = <T as FromCompilation<C, R>>::Context,
|
Context = <T as FromCompilation<C, S>>::Context,
|
||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait for reflectable compilations that can be transformed into an object ready for reflection or compilation.
|
/// A trait for reflectable compilations that can be transformed
|
||||||
pub trait FromCompilation<T, R> {
|
/// into an object ready for reflection or compilation.
|
||||||
|
///
|
||||||
|
/// `T` is the compiled reflectable form of the shader.
|
||||||
|
/// `S` is the semantics under which the shader is reflected.
|
||||||
|
///
|
||||||
|
/// librashader currently supports two semantics, [`SpirvCross`](crate::reflect::cross::SpirvCross)
|
||||||
|
pub trait FromCompilation<T, S> {
|
||||||
/// The target that the transformed object is expected to compile for.
|
/// The target that the transformed object is expected to compile for.
|
||||||
type Target: OutputTarget;
|
type Target: OutputTarget;
|
||||||
/// Options provided to the compiler.
|
/// Options provided to the compiler.
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub(crate) struct WriteSpirV {
|
||||||
pub(crate) fragment: Vec<u32>,
|
pub(crate) fragment: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromCompilation<SpirvCompilation, SpirvCross<SPIRV>> for SPIRV {
|
impl FromCompilation<SpirvCompilation, SpirvCross> for SPIRV {
|
||||||
type Target = SPIRV;
|
type Target = SPIRV;
|
||||||
type Options = Option<()>;
|
type Options = Option<()>;
|
||||||
type Context = ();
|
type Context = ();
|
||||||
|
|
|
@ -3,11 +3,10 @@ use crate::back::{CompileShader, CompilerBackend, FromCompilation, ShaderCompile
|
||||||
use crate::error::{ShaderCompileError, ShaderReflectError};
|
use crate::error::{ShaderCompileError, ShaderReflectError};
|
||||||
use crate::front::SpirvCompilation;
|
use crate::front::SpirvCompilation;
|
||||||
use crate::reflect::naga::{Naga, NagaReflect};
|
use crate::reflect::naga::{Naga, NagaReflect};
|
||||||
use crate::reflect::{ReflectShader, ShaderOutputCompiler};
|
use crate::reflect::ReflectShader;
|
||||||
use naga::back::wgsl::WriterFlags;
|
use naga::back::wgsl::WriterFlags;
|
||||||
use naga::valid::{Capabilities, ValidationFlags};
|
use naga::valid::{Capabilities, ValidationFlags};
|
||||||
use naga::{AddressSpace, Module};
|
use naga::{AddressSpace, Module};
|
||||||
use rspirv::binary::Assemble;
|
|
||||||
|
|
||||||
/// The context for a WGSL compilation via Naga
|
/// The context for a WGSL compilation via Naga
|
||||||
pub struct NagaWgslContext {
|
pub struct NagaWgslContext {
|
||||||
|
@ -33,7 +32,7 @@ impl FromCompilation<SpirvCompilation, Naga> for WGSL {
|
||||||
compile: SpirvCompilation,
|
compile: SpirvCompilation,
|
||||||
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
) -> Result<CompilerBackend<Self::Output>, ShaderReflectError> {
|
||||||
Ok(CompilerBackend {
|
Ok(CompilerBackend {
|
||||||
backend: Naga::create_reflection(compile)?,
|
backend: NagaReflect::create_reflection(&compile)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -111,7 +111,7 @@ pub enum ShaderReflectError {
|
||||||
#[error("the binding is already in use")]
|
#[error("the binding is already in use")]
|
||||||
BindingInUse(u32),
|
BindingInUse(u32),
|
||||||
/// Error when transpiling from naga
|
/// Error when transpiling from naga
|
||||||
#[cfg(feature = "wgsl")]
|
#[cfg(feature = "naga")]
|
||||||
#[error("naga-spv")]
|
#[error("naga-spv")]
|
||||||
NagaInputError(#[from] naga::front::spv::Error),
|
NagaInputError(#[from] naga::front::spv::Error),
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod glslang;
|
||||||
|
|
||||||
pub trait ShaderReflectObject: Sized {}
|
pub trait ShaderReflectObject: Sized {}
|
||||||
|
|
||||||
pub use glslang::Glslang;
|
pub use crate::front::glslang::Glslang;
|
||||||
|
|
||||||
/// 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 ShaderInputCompiler<O: ShaderReflectObject>: Sized {
|
pub trait ShaderInputCompiler<O: ShaderReflectObject>: Sized {
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
//! use librashader_reflect::back::{CompileReflectShader, FromCompilation};
|
//! use librashader_reflect::back::{CompileReflectShader, FromCompilation};
|
||||||
//! use librashader_reflect::back::targets::SPIRV;
|
//! use librashader_reflect::back::targets::SPIRV;
|
||||||
//! use librashader_reflect::front::{Glslang, ShaderInputCompiler, SpirvCompilation};
|
//! use librashader_reflect::front::{Glslang, ShaderInputCompiler, SpirvCompilation};
|
||||||
|
//! use librashader_reflect::reflect::cross::SpirvCross;
|
||||||
//! use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
//! use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||||
//! use librashader_reflect::reflect::semantics::ShaderSemantics;
|
//! use librashader_reflect::reflect::semantics::ShaderSemantics;
|
||||||
//! type Artifact = impl CompileReflectShader<SPIRV, SpirvCompilation>;
|
//! type Artifact = impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross>;
|
||||||
//! type ShaderPassMeta = ShaderPassArtifact<Artifact>;
|
//! type ShaderPassMeta = ShaderPassArtifact<Artifact>;
|
||||||
//!
|
//!
|
||||||
//! // Compile single shader
|
//! // Compile single shader
|
||||||
|
|
|
@ -6,75 +6,23 @@ use crate::reflect::semantics::{
|
||||||
UniformMemberBlock, UniqueSemanticMap, UniqueSemantics, ValidateTypeSemantics, VariableMeta,
|
UniformMemberBlock, UniqueSemanticMap, UniqueSemantics, ValidateTypeSemantics, VariableMeta,
|
||||||
MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE,
|
MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE,
|
||||||
};
|
};
|
||||||
use crate::reflect::{align_uniform_size, ReflectShader, ShaderOutputCompiler};
|
use crate::reflect::{align_uniform_size, ReflectShader};
|
||||||
use std::borrow::Borrow;
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
||||||
use spirv_cross::{glsl, hlsl, ErrorCode};
|
use spirv_cross::{glsl, hlsl, ErrorCode};
|
||||||
|
|
||||||
use crate::back::cross::{CrossGlslContext, CrossHlslContext, HlslShaderModel};
|
use crate::back::cross::{CrossGlslContext, CrossHlslContext, HlslShaderModel};
|
||||||
use crate::back::targets::{OutputTarget, DXIL, GLSL, HLSL, SPIRV};
|
use crate::back::targets::{GLSL, HLSL};
|
||||||
use crate::back::{CompileShader, ShaderCompilerOutput};
|
use crate::back::{CompileShader, ShaderCompilerOutput};
|
||||||
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
|
use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData};
|
||||||
|
|
||||||
trait SpirvCrossTarget {
|
/// Reflect shaders under SPIRV-Cross semantics.
|
||||||
type CrossTarget: spirv_cross::spirv::Target;
|
pub struct SpirvCross;
|
||||||
}
|
|
||||||
|
|
||||||
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>;
|
pub(crate) type GlslReflect = CrossReflect<glsl::Target>;
|
||||||
|
|
||||||
impl<T: OutputTarget + SpirvCrossTarget, Opt, Ctx>
|
|
||||||
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>,
|
|
||||||
<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>,
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
let vertex = Ast::<T::CrossTarget>::parse(&vertex_module)?;
|
|
||||||
let fragment = Ast::<T::CrossTarget>::parse(&fragment_module)?;
|
|
||||||
|
|
||||||
Ok(CrossReflect { vertex, fragment })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is "probably" OK.
|
// This is "probably" OK.
|
||||||
unsafe impl<T: Send + spirv_cross::spirv::Target> Send for CrossReflect<T>
|
unsafe impl<T: Send + spirv_cross::spirv::Target> Send for CrossReflect<T>
|
||||||
where
|
where
|
||||||
|
|
|
@ -15,16 +15,6 @@ mod helper;
|
||||||
#[cfg(feature = "naga")]
|
#[cfg(feature = "naga")]
|
||||||
pub mod naga;
|
pub mod naga;
|
||||||
|
|
||||||
pub trait ShaderOutputCompiler<O: ShaderReflectObject, T: OutputTarget, Opt, Ctx> {
|
|
||||||
/// Create the reflection object
|
|
||||||
fn create_reflection(
|
|
||||||
compiled: O,
|
|
||||||
) -> Result<
|
|
||||||
impl ReflectShader + CompileShader<T, Options = Opt, Context = Ctx>,
|
|
||||||
ShaderReflectError,
|
|
||||||
>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A trait for compilation outputs that can provide reflection information.
|
/// A trait for compilation outputs that can provide reflection information.
|
||||||
pub trait ReflectShader {
|
pub trait ReflectShader {
|
||||||
/// Reflect the shader as the given pass within the shader preset, against the provided
|
/// Reflect the shader as the given pass within the shader preset, against the provided
|
||||||
|
@ -36,9 +26,6 @@ pub trait ReflectShader {
|
||||||
) -> Result<ShaderReflection, ShaderReflectError>;
|
) -> Result<ShaderReflection, ShaderReflectError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::back::targets::OutputTarget;
|
|
||||||
use crate::back::CompileShader;
|
|
||||||
use crate::front::ShaderReflectObject;
|
|
||||||
pub use semantics::ShaderReflection;
|
pub use semantics::ShaderReflection;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
mod lower_samplers;
|
mod lower_samplers;
|
||||||
|
|
||||||
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
||||||
use std::borrow::Borrow;
|
|
||||||
|
|
||||||
use crate::back::targets::OutputTarget;
|
use crate::error;
|
||||||
use crate::back::CompileShader;
|
|
||||||
use crate::front::SpirvCompilation;
|
use crate::front::SpirvCompilation;
|
||||||
use naga::{
|
use naga::{
|
||||||
AddressSpace, Binding, GlobalVariable, Handle, ImageClass, Module, ResourceBinding, Scalar,
|
AddressSpace, Binding, GlobalVariable, Handle, ImageClass, Module, ResourceBinding, Scalar,
|
||||||
|
@ -20,24 +18,24 @@ use crate::reflect::semantics::{
|
||||||
UniqueSemanticMap, UniqueSemantics, ValidateTypeSemantics, VariableMeta, MAX_BINDINGS_COUNT,
|
UniqueSemanticMap, UniqueSemantics, ValidateTypeSemantics, VariableMeta, MAX_BINDINGS_COUNT,
|
||||||
MAX_PUSH_BUFFER_SIZE,
|
MAX_PUSH_BUFFER_SIZE,
|
||||||
};
|
};
|
||||||
use crate::reflect::{align_uniform_size, ReflectShader, ShaderOutputCompiler, ShaderReflection};
|
use crate::reflect::{align_uniform_size, ReflectShader, ShaderReflection};
|
||||||
|
|
||||||
/// Represents the naga output compiler.
|
/// Reflect under Naga semantics
|
||||||
///
|
///
|
||||||
/// The Naga reflector will lower combined image samplers to split,
|
/// The Naga reflector will lower combined image samplers to split,
|
||||||
/// with the same bind point on descriptor group 1.
|
/// with the same bind point on descriptor group 1.
|
||||||
pub struct Naga;
|
pub struct Naga;
|
||||||
|
|
||||||
impl<T: OutputTarget, Opt, Ctx> ShaderOutputCompiler<SpirvCompilation, T, Opt, Ctx> for Naga
|
#[derive(Debug)]
|
||||||
where
|
pub(crate) struct NagaReflect {
|
||||||
NagaReflect: CompileShader<T, Options = Opt, Context = Ctx>,
|
pub(crate) vertex: Module,
|
||||||
{
|
pub(crate) fragment: Module,
|
||||||
fn create_reflection(
|
}
|
||||||
compile: SpirvCompilation,
|
|
||||||
) -> Result<
|
impl NagaReflect {
|
||||||
impl ReflectShader + CompileShader<T, Options = Opt, Context = Ctx>,
|
pub(crate) fn create_reflection(
|
||||||
ShaderReflectError,
|
compile: &SpirvCompilation,
|
||||||
> {
|
) -> Result<Self, error::ShaderReflectError> {
|
||||||
fn lower_fragment_shader(words: &[u32]) -> Vec<u32> {
|
fn lower_fragment_shader(words: &[u32]) -> Vec<u32> {
|
||||||
let mut loader = rspirv::dr::Loader::new();
|
let mut loader = rspirv::dr::Loader::new();
|
||||||
rspirv::binary::parse_words(words, &mut loader).unwrap();
|
rspirv::binary::parse_words(words, &mut loader).unwrap();
|
||||||
|
@ -54,8 +52,6 @@ where
|
||||||
module.assemble()
|
module.assemble()
|
||||||
}
|
}
|
||||||
|
|
||||||
let compile = compile.borrow();
|
|
||||||
|
|
||||||
let options = naga::front::spv::Options {
|
let options = naga::front::spv::Options {
|
||||||
adjust_coordinate_space: true,
|
adjust_coordinate_space: true,
|
||||||
strict_capabilities: false,
|
strict_capabilities: false,
|
||||||
|
@ -71,13 +67,6 @@ where
|
||||||
Ok(NagaReflect { vertex, fragment })
|
Ok(NagaReflect { vertex, fragment })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub(crate) struct NagaReflect {
|
|
||||||
pub(crate) vertex: Module,
|
|
||||||
pub(crate) fragment: Module,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ValidateTypeSemantics<&TypeInner> for UniqueSemantics {
|
impl ValidateTypeSemantics<&TypeInner> for UniqueSemantics {
|
||||||
fn validate_type(&self, ty: &&TypeInner) -> Option<TypeInfo> {
|
fn validate_type(&self, ty: &&TypeInner) -> Option<TypeInfo> {
|
||||||
let (TypeInner::Vector { .. } | TypeInner::Scalar { .. } | TypeInner::Matrix { .. }) = *ty
|
let (TypeInner::Vector { .. } | TypeInner::Scalar { .. } | TypeInner::Matrix { .. }) = *ty
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub(crate) struct FilterCommon {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShaderPassMeta =
|
type ShaderPassMeta =
|
||||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross<HLSL>> + Send>;
|
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||||
fn compile_passes(
|
fn compile_passes(
|
||||||
shaders: Vec<ShaderPassConfig>,
|
shaders: Vec<ShaderPassConfig>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
|
@ -85,11 +85,11 @@ fn compile_passes(
|
||||||
HLSL::compile_preset_passes::<
|
HLSL::compile_preset_passes::<
|
||||||
Glslang,
|
Glslang,
|
||||||
CachedCompilation<SpirvCompilation>,
|
CachedCompilation<SpirvCompilation>,
|
||||||
SpirvCross<HLSL>,
|
SpirvCross,
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(shaders, &textures)?
|
>(shaders, &textures)?
|
||||||
} else {
|
} else {
|
||||||
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<HLSL>, FilterChainError>(
|
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross, FilterChainError>(
|
||||||
shaders, &textures,
|
shaders, &textures,
|
||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl Drop for FrameResiduals {
|
||||||
}
|
}
|
||||||
|
|
||||||
type DxilShaderPassMeta =
|
type DxilShaderPassMeta =
|
||||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross<DXIL>> + Send>;
|
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross> + Send>;
|
||||||
fn compile_passes_dxil(
|
fn compile_passes_dxil(
|
||||||
shaders: Vec<ShaderPassConfig>,
|
shaders: Vec<ShaderPassConfig>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
|
@ -156,11 +156,11 @@ fn compile_passes_dxil(
|
||||||
DXIL::compile_preset_passes::<
|
DXIL::compile_preset_passes::<
|
||||||
Glslang,
|
Glslang,
|
||||||
CachedCompilation<SpirvCompilation>,
|
CachedCompilation<SpirvCompilation>,
|
||||||
SpirvCross<DXIL>,
|
SpirvCross,
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(shaders, &textures)?
|
>(shaders, &textures)?
|
||||||
} else {
|
} else {
|
||||||
DXIL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<DXIL>, FilterChainError>(
|
DXIL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross, FilterChainError>(
|
||||||
shaders, &textures,
|
shaders, &textures,
|
||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
@ -168,7 +168,7 @@ fn compile_passes_dxil(
|
||||||
Ok((passes, semantics))
|
Ok((passes, semantics))
|
||||||
}
|
}
|
||||||
type HlslShaderPassMeta =
|
type HlslShaderPassMeta =
|
||||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross<HLSL>> + Send>;
|
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||||
fn compile_passes_hlsl(
|
fn compile_passes_hlsl(
|
||||||
shaders: Vec<ShaderPassConfig>,
|
shaders: Vec<ShaderPassConfig>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
|
@ -178,11 +178,11 @@ fn compile_passes_hlsl(
|
||||||
HLSL::compile_preset_passes::<
|
HLSL::compile_preset_passes::<
|
||||||
Glslang,
|
Glslang,
|
||||||
CachedCompilation<SpirvCompilation>,
|
CachedCompilation<SpirvCompilation>,
|
||||||
SpirvCross<HLSL>,
|
SpirvCross,
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(shaders, &textures)?
|
>(shaders, &textures)?
|
||||||
} else {
|
} else {
|
||||||
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<HLSL>, FilterChainError>(
|
HLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross, FilterChainError>(
|
||||||
shaders, &textures,
|
shaders, &textures,
|
||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShaderPassMeta =
|
type ShaderPassMeta =
|
||||||
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross<GLSL>>>;
|
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross>>;
|
||||||
fn compile_passes(
|
fn compile_passes(
|
||||||
shaders: Vec<ShaderPassConfig>,
|
shaders: Vec<ShaderPassConfig>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
|
@ -109,11 +109,11 @@ fn compile_passes(
|
||||||
GLSL::compile_preset_passes::<
|
GLSL::compile_preset_passes::<
|
||||||
Glslang,
|
Glslang,
|
||||||
CachedCompilation<SpirvCompilation>,
|
CachedCompilation<SpirvCompilation>,
|
||||||
SpirvCross<GLSL>,
|
SpirvCross,
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(shaders, &textures)?
|
>(shaders, &textures)?
|
||||||
} else {
|
} else {
|
||||||
GLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross<GLSL>, FilterChainError>(
|
GLSL::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross, FilterChainError>(
|
||||||
shaders, &textures,
|
shaders, &textures,
|
||||||
)?
|
)?
|
||||||
};
|
};
|
||||||
|
|
|
@ -208,9 +208,8 @@ impl Drop for FrameResiduals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ShaderPassMeta = ShaderPassArtifact<
|
type ShaderPassMeta =
|
||||||
impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross<SPIRV>> + Send,
|
ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross> + Send>;
|
||||||
>;
|
|
||||||
fn compile_passes(
|
fn compile_passes(
|
||||||
shaders: Vec<ShaderPassConfig>,
|
shaders: Vec<ShaderPassConfig>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
|
@ -220,16 +219,13 @@ fn compile_passes(
|
||||||
SPIRV::compile_preset_passes::<
|
SPIRV::compile_preset_passes::<
|
||||||
Glslang,
|
Glslang,
|
||||||
CachedCompilation<SpirvCompilation>,
|
CachedCompilation<SpirvCompilation>,
|
||||||
SpirvCross<SPIRV>,
|
SpirvCross,
|
||||||
FilterChainError,
|
FilterChainError,
|
||||||
>(shaders, &textures)?
|
>(shaders, &textures)?
|
||||||
} else {
|
} else {
|
||||||
SPIRV::compile_preset_passes::<
|
SPIRV::compile_preset_passes::<Glslang, SpirvCompilation, SpirvCross, FilterChainError>(
|
||||||
Glslang,
|
shaders, &textures,
|
||||||
SpirvCompilation,
|
)?
|
||||||
SpirvCross<SPIRV>,
|
|
||||||
FilterChainError,
|
|
||||||
>(shaders, &textures)?
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((passes, semantics))
|
Ok((passes, semantics))
|
||||||
|
|
Loading…
Reference in a new issue