Use --no-names to leave ID labels (OpName) and struct member labels (OpMemberName) out of the compiled .spv file.
dotnet tool install -g RecursiveAI.OneShader.ToolRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
Run with tint.hlsl (shown below and in the zip):
oneshader -T ps_6_0 tint.hlsl -Fo named.spv oneshader -T ps_6_0 tint.hlsl \ -Fo unnamed.spv --no-names
The \ continues the command in Bash; put the two lines on one line without it in PowerShell. The commands print nothing on success. They write named.spv and unnamed.spv from the same pixel shader.
tint.hlsl
cbuffer Params : register(b0) { float4 tint; }; float4 main() : SV_Target { return tint; }
The full program
To run both compiles without a global tool install:
Unzip the example, then dotnet run.
The zip restores the pinned local tool, runs both compiles and counts the SPIR-V OpName and OpMemberName instructions in each file.
using System.Buffers.Binary; using System.Diagnostics; RunDotnet("tool", "restore"); RunDotnet("oneshader", "-T", "ps_6_0", "tint.hlsl", "-Fo", "named.spv"); RunDotnet("oneshader", "-T", "ps_6_0", "tint.hlsl", "-Fo", "unnamed.spv", "--no-names"); foreach (string path in new[] { "named.spv", "unnamed.spv" }) { byte[] bytes = File.ReadAllBytes(path); int names = 0, memberNames = 0; // Skip the five-word SPIR-V header. for (int offset = 20; offset < bytes.Length;) { uint word = BinaryPrimitives.ReadUInt32LittleEndian( bytes.AsSpan(offset, 4)); int size = (int)(word >> 16) * 4; if (size == 0 || size > bytes.Length - offset) throw new InvalidDataException(path); switch (word & 0xffff) { case 5: names++; break; // OpName case 6: memberNames++; break; // OpMemberName } offset += size; } Console.WriteLine($"{path}: {bytes.Length} bytes, " + $"OpName={names}, OpMemberName={memberNames}"); } static void RunDotnet(params string[] args) { var command = new ProcessStartInfo("dotnet"); foreach (string arg in args) command.ArgumentList.Add(arg); using var process = Process.Start(command)!; process.WaitForExit(); if (process.ExitCode != 0) throw new InvalidOperationException( $"dotnet {args[0]} exited with {process.ExitCode}."); }
After the tool restore messages, it prints:
named.spv: 536 bytes, OpName=4, OpMemberName=1 unnamed.spv: 416 bytes, OpName=0, OpMemberName=0
If compilation fails, check the diagnostic and exit code before comparing the files; a file from a previous run may still be present.
Variations
Keep source-line information but omit the name instructions. Add -Zi when you still need to trace instructions back to HLSL lines:
oneshader -T ps_6_0 tint.hlsl -Fo lines.spv --no-names -ZiRelated recipes
The short answer
Add --no-names to your OneShader compile command. In this example, that takes the SPIR-V from four OpName instructions and one OpMemberName to zero of each. The flag controls the names emitted during compilation; it doesn’t strip an existing .spv file.
What are OpName and OpMemberName in SPIR-V?
In the SPIR-V specification, OpName attaches a readable name to an ID, and OpMemberName attaches one to a structure member. They help when reading a disassembly: a member name such as tint gives you more context than its numeric member index. They aren’t the OpEntryPoint name Vulkan uses to select the shader entry point. The sample still exports main in both binaries.
Does --no-names strip all SPIR-V debug information?
No. Leaving out names doesn’t turn off source-level debug options. The -Zi variation still emits line information and can include HLSL source text, even though it emits no OpName or OpMemberName in this example. If you don’t want source-level debug records, leave -Zi and -fspv-debug off. The debugging guide shows what each option emits.
Optimization is a separate setting: -Od switches it off; --no-names does not. The byte counts above compare the same HLSL and compile options except for --no-names, so the difference isn’t an optimization result.