Skip to content

Commit 25dd495

Browse files
committed
cli: allow raw-id for spirv output
1 parent 29312ce commit 25dd495

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

librashader-cli/src/cli/main.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ enum Commands {
182182
/// For MSL, this is the shader language version as an integer in format
183183
/// <MMmmpp>(30100), or a version in the format MAJ_MIN (3_1), or MAJ.MIN (3.1).
184184
///
185+
/// For SPIR-V, if this is the string "raw-id", then shows raw ID values instead of friendly names.
185186
#[arg(short, long)]
186187
version: Option<String>,
187188
},
@@ -500,9 +501,10 @@ pub fn main() -> Result<(), anyhow::Error> {
500501
compilation.validate()?;
501502
let output = compilation.compile(None)?;
502503

504+
let raw = version.is_some_and(|s| s == "raw-id");
503505
TranspileOutput {
504-
vertex: spirv_to_dis(output.vertex)?,
505-
fragment: spirv_to_dis(output.fragment)?,
506+
vertex: spirv_to_dis(output.vertex, raw)?,
507+
fragment: spirv_to_dis(output.fragment, raw)?,
506508
}
507509
}
508510
};
@@ -649,13 +651,13 @@ fn set_params(
649651
});
650652
}
651653

652-
fn spirv_to_dis(spirv: Vec<u32>) -> anyhow::Result<String> {
654+
fn spirv_to_dis(spirv: Vec<u32>, raw: bool) -> anyhow::Result<String> {
653655
let binary = spq_spvasm::SpirvBinary::from(spirv);
654656
spq_spvasm::Disassembler::new()
655657
.print_header(true)
656-
.name_ids(true)
657-
.name_type_ids(true)
658-
.name_const_ids(true)
658+
.name_ids(!raw)
659+
.name_type_ids(!raw)
660+
.name_const_ids(!raw)
659661
.indent(true)
660662
.disassemble(&binary)
661663
}

0 commit comments

Comments
 (0)