[hlsl-out] expose profile string conversions

This commit is contained in:
Dzmitry Malyshau 2021-07-11 23:14:07 -04:00
parent 7532c2abaa
commit 458db0b522
2 changed files with 15 additions and 12 deletions

View File

@ -16,20 +16,22 @@ pub enum ShaderModel {
}
impl ShaderModel {
pub fn to_profile_string(self, stage: crate::ShaderStage) -> String {
let stage_prefix = match stage {
crate::ShaderStage::Vertex => "vs_",
crate::ShaderStage::Fragment => "ps_",
crate::ShaderStage::Compute => "cs_",
};
let version = match self {
pub fn to_str(self) -> &'static str {
match self {
Self::V5_0 => "5_0",
Self::V5_1 => "5_1",
Self::V6_0 => "6_0",
};
}
}
}
format!("{}{}", stage_prefix, version)
impl crate::ShaderStage {
pub fn to_hlsl_str(self) -> &'static str {
match self {
Self::Vertex => "vs",
Self::Fragment => "ps",
Self::Compute => "cs",
}
}
}

View File

@ -291,10 +291,11 @@ fn write_output_hlsl(
naga::ShaderStage::Compute => "compute",
};
config_str = format!(
"{}{}={}\n{}_name={}\n",
"{}{}={}_{}\n{}_name={}\n",
config_str,
stage_str,
options.shader_model.to_profile_string(ep.stage),
ep.stage.to_hlsl_str(),
options.shader_model.to_str(),
stage_str,
&reflection_info.entry_points[index]
);