using System; using System.Diagnostics.CodeAnalysis; namespace ComputeSharp.D2D1; /// /// An attribute that indicates that a given D2D1 shader should be precompiled at build time and embedded /// directly into the containing assembly as static bytecode, to be retrieved as a . /// /// This attribute can be used to annotate methods as follows: /// /// [D2DPixelShaderSource(""" /// #define D2D_INPUT_COUNT 1 /// #define D2D_INPUT0_SIMPLE /// /// #include ""d2d1effecthelpers.hlsli"" /// /// D2D_PS_ENTRY(PSMain) /// { /// float4 color = D2DGetInput(0); /// float3 rgb = saturate(1.0 - color.rgb); /// return float4(rgb, 1); /// } /// """")] /// static partial ReadOnlySpan<byte> GetBytecode(); /// /// /// /// /// /// Methods can also be annotated with and /// to further customize the shader profile to use when compiling the HLSL source, and the compile options to use. /// /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public sealed class D2DPixelShaderSourceAttribute : Attribute { /// /// Creates a new instance of the type with the specified arguments. /// /// The number of texture inputs for the shader. public D2DPixelShaderSourceAttribute([StringSyntax("Hlsl")] string hlslSource) { HlslSource = hlslSource; } /// /// Gets the number of texture inputs for the shader. /// public string HlslSource { get; } }