diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs
index 1f8c3160..4dbeeb51 100644
--- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs
+++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs
@@ -12,10 +12,15 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
///
public bool IsConstantBuffer { get; } = true;
+ ///
+ /// Gets whether or not this constant buffer actually contains a single, explicit variable
+ ///
+ public bool IsSingleValue { get; }
+
///
/// Gets the index of the current constant buffer field
///
- public int ConstantBufferIndex { get; set; }
+ public int ConstantBufferIndex { get; }
///
/// Creates a new instance with the specified parameters
@@ -23,9 +28,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// The type of the current field
/// The name of the current field
/// The index of the current constant buffer field
- public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName)
+ /// Whether or not this constant buffer actually contains a single, explicit variable
+ public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex, bool singleValue) : base(fieldType, fieldName)
{
ConstantBufferIndex = bufferIndex;
+ IsSingleValue = singleValue;
}
}
}
diff --git a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
index eee11e3e..70165909 100644
--- a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
+++ b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
@@ -7,7 +7,7 @@ static {{&FieldType}} {{FieldName}} = {{FieldValue}};
{{#IsConstantBuffer}}
cbuffer {{FieldName}}Buffer : register(b{{ConstantBufferIndex}})
{
-{{&FieldType}} {{FieldName}};
+{{&FieldType}} {{FieldName}}{{^IsSingleValue}}[2]{{/IsSingleValue}};
}
{{/IsConstantBuffer}}
{{!Read write buffer}}