diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
index ef124a54..e53c3b74 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
@@ -67,8 +67,10 @@
+
+
diff --git a/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs
new file mode 100644
index 00000000..385aacee
--- /dev/null
+++ b/src/ComputeSharp.D2D1/Attributes/D2DCompileOptionsAttribute.cs
@@ -0,0 +1,40 @@
+using System;
+
+namespace ComputeSharp.D2D1;
+
+///
+/// An attribute that indicates the compile options that should be used when compiling a given D2D1 shader.
+/// This applies when the shader is precompiled (through ) as well.
+///
+/// This attribute can be used to annotate shader types as follows:
+///
+/// [D2DCompileOptions(D2D1CompileOptions.IeeeStrictness | D2D1CompileOptions.OptimizationLevel3)]
+/// struct MyShader : ID2D1PixelShader
+/// {
+/// }
+///
+///
+///
+///
+/// Note that the is always enabled automatically and does not need to be
+/// specified. This option is mandatory, as the generated code to load the constant buffer from a shader assumes the layout
+/// for matrix types is row major. For the same reason, using is not
+/// allowed, as it would cause the constant buffer retrieved from a shader to be potentially incorrect.
+///
+[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
+public sealed class D2DCompileOptionsAttribute : Attribute
+{
+ ///
+ /// Creates a new instance with the specified parameters.
+ ///
+ /// The compiler options to use to compile the shader.
+ public D2DCompileOptionsAttribute(D2D1CompileOptions options)
+ {
+ Options = options;
+ }
+
+ ///
+ /// Gets the number of threads in each thread group for the X axis
+ ///
+ public D2D1CompileOptions Options { get; }
+}
diff --git a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs b/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs
index 1325ad6c..d3fab2d6 100644
--- a/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs
+++ b/src/ComputeSharp.D2D1/Attributes/D2DEmbeddedBytecodeAttribute.cs
@@ -8,7 +8,6 @@ namespace ComputeSharp.D2D1;
///
/// This attribute can be used to annotate shader types as follows:
///
-/// // A compute shader that is dispatched on a target buffer
/// [D2DEmbeddedBytecode(D2D1ShaderProfile.PixelShader50)]
/// struct MyShader : ID2D1PixelShader
/// {
diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
index 32500128..a0209386 100644
--- a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
+++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
@@ -1,5 +1,7 @@
using System;
+#if !SOURCE_GENERATOR
using ComputeSharp.D2D1.Interop;
+#endif
using TerraFX.Interop.DirectX;
namespace ComputeSharp.D2D1;