Editor/Prism/Compiler/Backends/BackendEmitOptions.cs

Defines HlslDialect enum for two HLSL output flavors and a BackendEmitOptions record that holds compile options for the Prism backend (mode, dialect, debug symbols, comment emission, entry point prefix) plus several init-only properties and a Default instance.

namespace Editor.Prism.Compiler.Backends;

/// <summary>
/// Which flavour of HLSL the s&amp;box backend writes.
/// </summary>
public enum HlslDialect
{
	/// <summary>
	/// The default. The engine compiles through Slang internally and its own shipped headers already
	/// use <c>[mutating]</c>, struct inheritance and static struct methods, so the "HLSL" we emit may
	/// legitimately use those where they make the output cleaner.
	/// </summary>
	SboxSlang,

	/// <summary>
	/// Plain HLSL 2021. Struct methods lower to free functions and no Slang extension is used, so the
	/// generated <c>.shader</c> stays portable to a bare DXC pipeline.
	/// </summary>
	StrictHlsl2021
}

/// <summary>Everything a backend needs to know beyond the module itself.</summary>
public sealed record BackendEmitOptions(
	CompileMode Mode,
	HlslDialect Dialect,
	bool DebugSymbols,
	bool EmitComments,
	string EntryPointPrefix )
{
	/// <summary>Base name for the emitted artifact, without an extension.</summary>
	public string OutputName { get; init; } = "prism_shader";

	/// <summary>Indent string. Generated code uses hard tabs, like everything else in this project.</summary>
	public string Indent { get; init; } = "\t";

	/// <summary>Line ending used by the emitted text.</summary>
	public string NewLine { get; init; } = "\r\n";

	/// <summary>Emit a source map alongside the text. Required for click-the-error-select-the-node.</summary>
	public bool EmitSourceMap { get; init; } = true;

	/// <summary>Sensible defaults for a final s&amp;box build.</summary>
	public static BackendEmitOptions Default { get; } =
		new( CompileMode.Final, HlslDialect.SboxSlang, false, true, string.Empty );
}