using System; namespace Veldrid.SPIRV { /// /// An object used to control the parameters of shader translation from SPIR-V to some target language. /// public class CrossCompileOptions { /// /// Indicates whether or not the compiled shader output should include a clip-space Z-range fixup at the end of the /// vertex shader. /// If true, then the shader will include code that assumes the clip space needs to be corrected from the /// "wrong" range into the "right" range for the particular type of shader. For example, if an OpenGL shader is being /// generated, then the vertex shader will include a fixup that converts the depth range from [0, 1] to [-1, 1]. /// If a Direct3D shader is being generated, then the vertex shader will include a fixup that converts the depth range /// from [-1, 1] to [0, 1]. /// public bool FixClipSpaceZ { get; set; } /// /// Indicates whether or not the compiled shader output should include a fixup at the end of the vertex shader which /// inverts the clip-space Y value. /// public bool InvertVertexOutputY { get; set; } /// /// Indicates whether all resource names should be forced into a normalized form. This has functional impact /// on compilation targets where resource names are meaningful, like GLSL. /// public bool NormalizeResourceNames { get; set; } /// /// An array of which will be substituted into the shader as new constants. Each /// element in the array will be matched by ID with the SPIR-V specialization constants defined in the shader. /// public SpecializationConstant[] Specializations { get; set; } /// /// Constructs a new with default values. /// public CrossCompileOptions() { Specializations = Array.Empty(); } /// /// Constructs a new , used to control the parameters of shader translation. /// /// Indicates whether or not the compiled shader output should include a clip-space Z-range /// fixup at the end of the vertex shader. /// Indicates whether or not the compiled shader output should include a fixup at the /// end of the vertex shader which inverts the clip-space Y value. public CrossCompileOptions(bool fixClipSpaceZ, bool invertVertexOutputY) : this(fixClipSpaceZ, invertVertexOutputY, Array.Empty()) { } /// /// Constructs a new , used to control the parameters of shader translation. /// /// Indicates whether or not the compiled shader output should include a clip-space Z-range /// fixup at the end of the vertex shader. /// Indicates whether or not the compiled shader output should include a fixup at the /// end of the vertex shader which inverts the clip-space Y value. /// Indicates whether all resource names should be forced into a normalized form. /// This has functional impact on compilation targets where resource names are meaningful, like GLSL. public CrossCompileOptions(bool fixClipSpaceZ, bool invertVertexOutputY, bool normalizeResourceNames) : this(fixClipSpaceZ, invertVertexOutputY, normalizeResourceNames, Array.Empty()) { } /// /// Constructs a new , used to control the parameters of shader translation. /// /// Indicates whether or not the compiled shader output should include a clip-space Z-range /// fixup at the end of the vertex shader. /// Indicates whether or not the compiled shader output should include a fixup at the /// end of the vertex shader which inverts the clip-space Y value. /// An array of which will be substituted into the /// shader as new constants. public CrossCompileOptions(bool fixClipSpaceZ, bool invertVertexOutputY, params SpecializationConstant[] specializations) { FixClipSpaceZ = fixClipSpaceZ; InvertVertexOutputY = invertVertexOutputY; Specializations = specializations; } /// /// Constructs a new , used to control the parameters of shader translation. /// /// Indicates whether or not the compiled shader output should include a clip-space Z-range /// fixup at the end of the vertex shader. /// Indicates whether or not the compiled shader output should include a fixup at the /// end of the vertex shader which inverts the clip-space Y value. /// Indicates whether all resource names should be forced into a normalized form. /// This has functional impact on compilation targets where resource names are meaningful, like GLSL. /// An array of which will be substituted into the /// shader as new constants. public CrossCompileOptions( bool fixClipSpaceZ, bool invertVertexOutputY, bool normalizeResourceNames, params SpecializationConstant[] specializations) { FixClipSpaceZ = fixClipSpaceZ; InvertVertexOutputY = invertVertexOutputY; NormalizeResourceNames = normalizeResourceNames; Specializations = specializations; } } }