From 5d260e77d5ed104bcb177751a5b1d98d08a044b0 Mon Sep 17 00:00:00 2001 From: chyyran Date: Wed, 1 Feb 2023 18:58:21 -0500 Subject: [PATCH] reflect: expose HLSL SM version --- librashader-reflect/src/back/cross.rs | 5 ++++- librashader-reflect/src/reflect/cross.rs | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/librashader-reflect/src/back/cross.rs b/librashader-reflect/src/back/cross.rs index 434b433..e1a944b 100644 --- a/librashader-reflect/src/back/cross.rs +++ b/librashader-reflect/src/back/cross.rs @@ -8,6 +8,9 @@ use crate::reflect::ReflectShader; /// The GLSL version to use. pub type GlslVersion = spirv_cross::glsl::Version; +/// The HLSL shader model version to use +pub type HlslVersion = spirv_cross::hlsl::ShaderModel; + /// The context for a GLSL compilation via spirv-cross. pub struct CrossGlslContext { /// A map of bindings of sampler names to binding locations. @@ -40,7 +43,7 @@ pub struct CrossHlslContext { impl FromCompilation for HLSL { type Target = HLSL; - type Options = Option<()>; + type Options = Option; type Context = CrossHlslContext; type Output = impl CompileShader + ReflectShader; diff --git a/librashader-reflect/src/reflect/cross.rs b/librashader-reflect/src/reflect/cross.rs index 0ad535a..41afa17 100644 --- a/librashader-reflect/src/reflect/cross.rs +++ b/librashader-reflect/src/reflect/cross.rs @@ -13,7 +13,7 @@ use spirv_cross::hlsl::ShaderModel; use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type}; use spirv_cross::{glsl, hlsl, ErrorCode}; -use crate::back::cross::{CrossGlslContext, CrossHlslContext}; +use crate::back::cross::{CrossGlslContext, CrossHlslContext, HlslVersion}; use crate::back::targets::{GLSL, HLSL}; use crate::back::{CompileShader, ShaderCompilerOutput}; use crate::reflect::helper::{SemanticErrorBlame, TextureData, UboData}; @@ -823,15 +823,16 @@ impl CompileShader for CrossReflect { } impl CompileShader for CrossReflect { - type Options = Option<()>; + type Options = Option; type Context = CrossHlslContext; fn compile( mut self, - _options: Self::Options, + options: Self::Options, ) -> Result, ShaderCompileError> { + let sm = options.unwrap_or(ShaderModel::V5_0); let mut options = hlsl::CompilerOptions::default(); - options.shader_model = ShaderModel::V5_0; + options.shader_model = sm; self.vertex.set_compiler_options(&options)?; self.fragment.set_compiler_options(&options)?;