using System; #if !SOURCE_GENERATOR using ComputeSharp.D2D1.Interop; #endif using TerraFX.Interop.DirectX; namespace ComputeSharp.D2D1; /// /// Flags to control the options that can be used to compile a D2D1 shader. /// /// /// For more info, see For more info, see . /// [Flags] public enum D2D1CompileOptions { /// /// Directs the compiler to insert debug file/line/type/symbol information into the output code. /// /// /// This flag maps to D3DCOMPILE_DEBUG and /Zi. /// Debug = D3DCOMPILE.D3DCOMPILE_DEBUG, /// /// Directs the compiler not to validate the generated code against known capabilities and constraints. /// This option should only be used with shaders that have been successfully compiled in the past. /// DirectX always validates shaders before it sets them to a device. /// /// /// This flag maps to D3DCOMPILE_SKIP_VALIDATION and /Vd. /// SkipValidation = D3DCOMPILE.D3DCOMPILE_SKIP_VALIDATION, /// /// Directs the compiler to skip optimization steps during code generation. /// This option should only be used for debug purposes. /// /// /// This flag maps to D3DCOMPILE_SKIP_OPTIMIZATION and /Od. /// SkipOptimization = D3DCOMPILE.D3DCOMPILE_SKIP_OPTIMIZATION, /// /// Directs the compiler to pack matrices in row-major order on input and output from the shader. /// /// /// This value is needed to have the constant buffer loading from generated shaders map to compiled shaders. /// This flag maps to D3DCOMPILE_PACK_MATRIX_ROW_MAJOR and /Zpr. /// PackMatrixRowMajor = D3DCOMPILE.D3DCOMPILE_PACK_MATRIX_ROW_MAJOR, /// /// Directs the compiler to pack matrices in column-major order on input and output from the shader. /// This type of packing is generally more efficient because a series of dot-products can then /// perform vector-matrix multiplication. /// /// /// Using this flag makes shaders incompatible with the constant buffer loading code produced by ComputeSharp.D2D1. /// That is, trying to load a constant buffer from a shader processed by the source generator is undefined behavior. /// This flag maps to D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR and /Zpc. /// PackMatrixColumnMajor = D3DCOMPILE.D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR, /// /// Directs the compiler to perform all computations with partial precision. /// If this flag is set, the compiled code might run faster on some hardware. /// /// /// This flag maps to D3DCOMPILE_PARTIAL_PRECISION and /Gpp. /// PartialPrecision = D3DCOMPILE.D3DCOMPILE_PARTIAL_PRECISION, /// /// Directs the compiler to not use flow-control constructs where possible. /// /// /// This flag maps to D3DCOMPILE_AVOID_FLOW_CONTROL and /Gfa. /// AvoidFlowControl = D3DCOMPILE.D3DCOMPILE_AVOID_FLOW_CONTROL, /// /// Forces strict compile, which might not allow for legacy syntax. /// By default, the compiler disables strictness on deprecated syntax. /// /// /// This flag maps to D3DCOMPILE_ENABLE_STRICTNESS and /Ges. /// EnableStrictness = D3DCOMPILE.D3DCOMPILE_ENABLE_STRICTNESS, /// /// Forces the IEEE strict compile which avoids optimizations that may break IEEE rules. /// /// /// This flag maps to D3DCOMPILE_IEEE_STRICTNESS and /Gis. /// IeeeStrictness = D3DCOMPILE.D3DCOMPILE_IEEE_STRICTNESS, /// /// Directs the compiler to enable older shaders to compile to 5_0 targets. /// /// /// This flag maps to D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY and /Gec. /// EnableBackwardsCompatibility = D3DCOMPILE.D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY, /// /// Directs the compiler to use the lowest optimization level. If this option is set, the compiler /// might produce slower code but produces the code more quickly. This option should be set when /// shaders are developed iteratively, as it can reduce compilation times. /// /// /// This flag maps to D3DCOMPILE_OPTIMIZATION_LEVEL0 and /O0. /// OptimizationLevel0 = D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL0, /// /// Directs the compiler to use the second lowest optimization level. /// /// /// This flag maps to D3DCOMPILE_OPTIMIZATION_LEVEL1 and /O1. /// OptimizationLevel1 = D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL1, /// /// Directs the compiler to use the second highest optimization level. /// /// /// This flag maps to D3DCOMPILE_OPTIMIZATION_LEVEL2 and /O2. /// OptimizationLevel2 = D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL2, /// /// Directs the compiler to use the highest optimization level. If this option is set, the compiler /// produces the best possible code but might take significantly longer to do so. This option should /// be set for final builds of an application when performance is the most important factor. /// /// /// This flag maps to D3DCOMPILE_OPTIMIZATION_LEVEL3 and /O3. /// OptimizationLevel3 = D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL3, /// /// Directs the compiler to treat all warnings as errors when it compiles the shader code. This /// option is recommended for new shader code, so that warnings can be resolved and the /// number of hard-to-find code defects can be minimized. /// /// /// This flag maps to D3DCOMPILE_WARNINGS_ARE_ERRORS and /WX. /// WarningsAreErrors = D3DCOMPILE.D3DCOMPILE_WARNINGS_ARE_ERRORS, /// /// This flag enables the support for shader linking. Specifically, when set, this flag causes the APIs from /// to compile the input shader twice: once as a full D2D1 shader, and once /// as an export function, which is then set as private blob data into the final bytecode that is returned. /// /// /// For more info, see . /// EnableLinking = 1 << 31, /// /// The default options for shaders compiled by ComputeSharp.D2D1. Specifically, this combination /// of options is the one used by precompiled shaders (ie. when using ), /// and when using or any of the overloads. /// /// /// This option does not include , which is instead automatically enabled by shaders /// compiled using any of the APIs mentioned above. When manually compiling shaders from source using the APIs /// from instance, should be manually used when needed. /// Default = OptimizationLevel3 | WarningsAreErrors | PackMatrixRowMajor }