-
Since I can't get the API working, is it possible to just emit the D3D11 HLSL for a given shader? |
Beta Was this translation helpful? Give feedback.
Answered by
chyyran
Oct 2, 2024
Replies: 2 comments
-
You'll need to use the Rust API for that functionality, it isn't exposed in the C headers. #![feature(type_alias_impl_trait)]
use std::error::Error;
use librashader::preprocess::ShaderSource;
use librashader::presets::ShaderPreset;
use librashader::reflect::{CompileReflectShader, FromCompilation, CompilePresetTarget, ShaderPassArtifact};
use librashader::reflect::targets::HLSL;
use librashader::reflect::cross::GlslangCompilation;
use librashader::reflect::semantics::ShaderSemantics;
type Artifact = impl CompileReflectShader<HLSL, GlslangCompilation>;
type ShaderPassMeta = ShaderPassArtifact<Artifact>;
// Compile single shader
pub fn compile_hlsl(
source: &ShaderSource,
) -> Result<(String, String)>
{
let artifact = GlslangCompilation::compile(&source)?;
let (_, _, compiler) = HLSL::from_compilation(artifact)?;
let hlsl = compiler.compile(None)?;
Ok((hlsl.vertex, hlsl.fragment))
} Otherwise there are command-line tools to go from Vulkan GLSL to SPIR-V to HLSL. You can just use SPIRV-Cross directly. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Much belated update but
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
chyyran
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Much belated update but
librashader-cli
provides this functionality now.