diff --git a/src/ComputeSharp.Core/Attributes/IComputeShaderSource.cs b/src/ComputeSharp.Core/Attributes/IComputeShaderSource.cs
index 7d172755..0e7a9ce8 100644
--- a/src/ComputeSharp.Core/Attributes/IComputeShaderSource.cs
+++ b/src/ComputeSharp.Core/Attributes/IComputeShaderSource.cs
@@ -20,13 +20,15 @@ namespace ComputeSharp
/// Creates a new instance with the specified parameters.
///
/// The fully qualified name of the shader type.
- /// The name of the current method.
- /// The source code of the target method.
- public IComputeShaderSourceAttribute(string shaderTypeName, object[] args, object[] methods)
+ /// The mapped collection of shader fields.
+ /// The mapped collection of shader methods.
+ /// The collection of custom types.
+ public IComputeShaderSourceAttribute(string shaderTypeName, object[] args, object[] methods, string[] types)
{
ShaderTypeName = shaderTypeName;
Fields = args.Cast().ToDictionary(static arg => arg[0], static arg => arg[1]);
Methods = methods.Cast().ToDictionary(static method => method[0], static method => method[1]);
+ Types = types;
}
///
@@ -44,6 +46,11 @@ namespace ComputeSharp
///
internal IReadOnlyDictionary Methods { get; }
+ ///
+ /// Gets the collection of processed custom types.
+ ///
+ internal IReadOnlyCollection Types { get; }
+
///
/// Gets the associated instance for a specified type.
///
diff --git a/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs b/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs
index 7c3be112..3f95cc37 100644
--- a/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs
+++ b/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs
@@ -27,10 +27,17 @@ namespace ComputeSharp.Shaders.Renderer
builder.AppendLine("// AUTO GENERATED");
builder.AppendLine("// ================================================");
builder.AppendLine("// This shader was created by ComputeSharp.");
- builder.AppendLine("// See: https://github.com/Sergio0694/ComputeSharp.");
- builder.AppendLine();
+ builder.AppendLine("// See: https://github.com/Sergio0694/ComputeSharp.");
+
+ // Declared types
+ foreach (var type in info.DeclaredTypes)
+ {
+ builder.AppendLine();
+ builder.AppendLine(type);
+ }
// Captured variables
+ builder.AppendLine();
builder.AppendLine("cbuffer _ : register(b0)");
builder.AppendLine('{');
builder.AppendLine(" uint __x;");
diff --git a/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs
index 07e3bbb2..3ae877df 100644
--- a/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs
+++ b/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs
@@ -47,11 +47,16 @@ namespace ComputeSharp.Shaders.Renderer.Models
///
/// Gets or sets the list of static functions used by the shader.
///
- public IReadOnlyList