diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj index 254db83b..b68b1087 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj +++ b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj @@ -64,7 +64,7 @@ - + diff --git a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs index ab9ab4c7..1325ad6c 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs @@ -1,7 +1,4 @@ using System; -#if !SOURCE_GENERATOR -using ComputeSharp.D2D1.Helpers; -#endif namespace ComputeSharp.D2D1; @@ -32,17 +29,7 @@ public sealed class D2DEmbeddedBytecodeAttribute : Attribute /// The target shader profile to use to compile the shader. public D2DEmbeddedBytecodeAttribute(D2D1ShaderProfile shaderProfile) { -#if !SOURCE_GENERATOR - ShaderProfile = shaderProfile switch - { - D2D1ShaderProfile.PixelShader40 or - D2D1ShaderProfile.PixelShader40Level91 or - D2D1ShaderProfile.PixelShader40Level93 or - D2D1ShaderProfile.PixelShader41 or - D2D1ShaderProfile.PixelShader50 => shaderProfile, - _ => ThrowHelper.ThrowArgumentException(nameof(shaderProfile), "Invalid shader profile value.") - }; -#endif + ShaderProfile = shaderProfile; } /// diff --git a/src/ComputeSharp.D2D1/Attributes/D2DInputComplexAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DInputComplexAttribute.cs index 59f8188b..c3d5717c 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DInputComplexAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DInputComplexAttribute.cs @@ -8,7 +8,8 @@ namespace ComputeSharp.D2D1; /// /// /// This attribute directly maps to #define D2D_INPUT<N>_COMPLEX. -/// For more info, see . +/// For more info, see . +/// [AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)] public sealed class D2DInputComplexAttribute : Attribute { diff --git a/src/ComputeSharp.D2D1/Attributes/D2DInputCountAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DInputCountAttribute.cs index e578bf23..92e1f84f 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DInputCountAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DInputCountAttribute.cs @@ -8,7 +8,8 @@ namespace ComputeSharp.D2D1; /// /// /// This attribute directly maps to #define D2D_INPUT_COUNT <N>. -/// For more info, see . +/// For more info, see . +/// [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] public sealed class D2DInputCountAttribute : Attribute { diff --git a/src/ComputeSharp.D2D1/Attributes/D2DInputSimpleAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DInputSimpleAttribute.cs index 7a23e2ac..4845e32b 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DInputSimpleAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DInputSimpleAttribute.cs @@ -8,7 +8,8 @@ namespace ComputeSharp.D2D1; /// /// /// This attribute directly maps to #define D2D_INPUT<N>_SIMPLE. -/// For more info, see . +/// For more info, see . +/// [AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)] public sealed class D2DInputSimpleAttribute : Attribute { diff --git a/src/ComputeSharp.D2D1/Attributes/D2DOutputBuffer.cs b/src/ComputeSharp.D2D1/Attributes/D2DOutputBuffer.cs new file mode 100644 index 00000000..615d8a4d --- /dev/null +++ b/src/ComputeSharp.D2D1/Attributes/D2DOutputBuffer.cs @@ -0,0 +1,53 @@ +using System; + +namespace ComputeSharp.D2D1; + +/// +/// An attribute for a D2D1 shader with a description on the resulting output buffer. +/// Using this attribute is optional when defining a D2D1 shader. +/// +/// +/// For more info, see . +/// +[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] +public sealed class D2DOutputBufferAttribute : Attribute +{ + /// + /// Creates a new instance of the type with the specified arguments. + /// + /// The buffer precision for the resulting output buffer. + public D2DOutputBufferAttribute(D2D1BufferPrecision bufferPrecision) + { + BufferPrecision = bufferPrecision; + } + + /// + /// Creates a new instance of the type with the specified arguments. + /// + /// The channel depth for the resulting output buffer. + public D2DOutputBufferAttribute(D2D1ChannelDepth channelDepth) + { + ChannelDepth = channelDepth; + } + + /// + /// Creates a new instance of the type with the specified arguments. + /// + /// The buffer precision for the resulting output buffer. + /// The channel depth for the resulting output buffer. + public D2DOutputBufferAttribute(D2D1BufferPrecision bufferPrecision, D2D1ChannelDepth channelDepth) + { + BufferPrecision = bufferPrecision; + ChannelDepth = channelDepth; + } + + /// + /// Gets the buffer precision for the resulting output buffer. + /// + public D2D1BufferPrecision BufferPrecision { get; } + + /// + /// Gets the channel depth for the resulting output buffer. + /// + public D2D1ChannelDepth ChannelDepth { get; } +} diff --git a/src/ComputeSharp.D2D1/Attributes/D2DRequiresScenePositionAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DRequiresScenePositionAttribute.cs index f61dbc35..f351bb93 100644 --- a/src/ComputeSharp.D2D1/Attributes/D2DRequiresScenePositionAttribute.cs +++ b/src/ComputeSharp.D2D1/Attributes/D2DRequiresScenePositionAttribute.cs @@ -9,7 +9,8 @@ namespace ComputeSharp.D2D1; /// /// /// This attribute directly maps to #define D2D_REQUIRES_SCENE_POSITION. -/// For more info, see . +/// For more info, see . +/// [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] public sealed class D2DRequiresScenePositionAttribute : Attribute { diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1BufferPrecision.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1BufferPrecision.cs new file mode 100644 index 00000000..8b1bc9a8 --- /dev/null +++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1BufferPrecision.cs @@ -0,0 +1,41 @@ +namespace ComputeSharp.D2D1; + +/// +/// Indicates the bit depth to use in the imaging pipeline in Direct2D to produce the result of a D2D1 shader. +/// +/// +/// This type exposes the available values in . +/// For more info, see . +/// +public enum D2D1BufferPrecision +{ + /// + /// The buffer precision is not specified. + /// + Unknown, + + /// + /// The buffer precision uses 8-bit normalized integer values per channel. + /// + Int8Normalized, + + /// + /// The buffer precision uses 8-bit normalized integer values per channel with standard RGB data. + /// + Int8NormalizedSRGB, + + /// + /// The buffer precision uses 16-bit normalized integer values per channel. + /// + Int16Normalized, + + /// + /// The buffer precision uses 16-bit float values per channel. + /// + Float16, + + /// + /// The buffer precision uses 32-bit float values per channel. + /// + Float32 +} diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ChannelDepth.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ChannelDepth.cs new file mode 100644 index 00000000..73abb928 --- /dev/null +++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ChannelDepth.cs @@ -0,0 +1,26 @@ +namespace ComputeSharp.D2D1; + +/// +/// Indicates the channel depth of a stage in a Direct2D rendering pipeline. +/// +/// +/// This type exposes the available values in . +/// For more info, see . +/// +public enum D2D1ChannelDepth +{ + /// + /// The channel depth is the default, and it will be inherited by the inputs. + /// + Default, + + /// + /// The channel depth is 1. + /// + One, + + /// + /// The channel depth is 4. + /// + Four +} diff --git a/src/ComputeSharp.D2D1/Attributes/Profiles/D2D1ShaderProfile.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs similarity index 100% rename from src/ComputeSharp.D2D1/Attributes/Profiles/D2D1ShaderProfile.cs rename to src/ComputeSharp.D2D1/Attributes/Enums/D2D1ShaderProfile.cs