diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/HlslBufferInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/HlslBufferInfo.cs index cc41114a..85eaee9c 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/HlslBufferInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/HlslBufferInfo.cs @@ -1,4 +1,6 @@ -namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract +using System; + +namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract { /// /// A that contains info on a shader buffer field @@ -13,10 +15,11 @@ /// /// Creates a new instance with the specified parameters /// - /// The type of the current field + /// The type of the current field in the C# source + /// The type of the current field in the HLSL shader /// The name of the current field /// The index of the current buffer field - protected HlslBufferInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName) + protected HlslBufferInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex) : base(fieldCsharpType, fieldHlslType, fieldName) { BufferIndex = bufferIndex; } diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/CapturedFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/CapturedFieldInfo.cs index a037c8b4..ba1f4092 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/CapturedFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/CapturedFieldInfo.cs @@ -1,4 +1,6 @@ -namespace ComputeSharp.Shaders.Renderer.Models.Fields +using System; + +namespace ComputeSharp.Shaders.Renderer.Models.Fields { /// /// A that contains info on a shader field @@ -6,23 +8,30 @@ internal class CapturedFieldInfo { /// - /// Gets or sets the type of the current field + /// Gets the type of the current field in the C# source /// - public string FieldType { get; set; } + public Type FieldCsharpType { get; } /// - /// Gets or sets the name to use for the current field + /// Gets the type of the current field in the HLSL shader /// - public string FieldName { get; set; } + public string FieldHlslType { get; } + + /// + /// Gets the name to use for the current field + /// + public string FieldName { get; } /// /// Creates a new instance with the specified parameters /// - /// The type of the current field - /// The name of the current field - public CapturedFieldInfo(string fieldType, string fieldName) + /// The type of the current field in the C# source + /// The type of the current field in the HLSL shader + /// The name to use for the current field + public CapturedFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName) { - FieldType = fieldType; + FieldCsharpType = fieldCsharpType; + FieldHlslType = fieldHlslType; FieldName = fieldName; } } diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs index 5dff2be0..a2554735 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs @@ -1,4 +1,5 @@ -using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; +using System; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; namespace ComputeSharp.Shaders.Renderer.Models.Fields { @@ -15,9 +16,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields /// /// Creates a new instance with the specified parameters /// - /// The type of the current field + /// The type of the current field in the C# source + /// The type of the current field in the HLSL shader /// 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, bufferIndex) { } + public ConstantBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex) + : base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex) { } } } diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadOnlyBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadOnlyBufferFieldInfo.cs index 6bba7e0a..b5ecb59c 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadOnlyBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadOnlyBufferFieldInfo.cs @@ -1,4 +1,5 @@ -using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; +using System; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; namespace ComputeSharp.Shaders.Renderer.Models.Fields { @@ -15,9 +16,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields /// /// Creates a new instance with the specified parameters /// - /// The type of the current field + /// The type of the current field in the C# source + /// The type of the current field in the HLSL shader /// The name of the current field /// The index of the current readonly buffer field - public ReadOnlyBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName, bufferIndex) { } + public ReadOnlyBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex) + : base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex) { } } } diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs index 5dbf8d02..86c04a47 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs @@ -1,4 +1,5 @@ -using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; +using System; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; namespace ComputeSharp.Shaders.Renderer.Models.Fields { @@ -15,9 +16,11 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields /// /// Creates a new instance with the specified parameters /// - /// The type of the current field + /// The type of the current field in the C# source + /// The type of the current field in the HLSL shader /// The name of the current field /// The index of the current read write buffer field - public ReadWriteBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName, bufferIndex) { } + public ReadWriteBufferFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName, int bufferIndex) + : base(fieldCsharpType, fieldHlslType, fieldName, bufferIndex) { } } } diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs index 14c8395a..0d456606 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs @@ -139,7 +139,7 @@ namespace ComputeSharp.Shaders.Translation _BufferFields.Add(fieldInfo); string typeName = HlslKnownTypes.GetMappedName(fieldType.GenericTypeArguments[0]); - _BuffersList.Add(new ConstantBufferFieldInfo(typeName, fieldName, constantBuffersCount++)); + _BuffersList.Add(new ConstantBufferFieldInfo(fieldType, typeName, fieldName, constantBuffersCount++)); } else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType)) { @@ -150,7 +150,7 @@ namespace ComputeSharp.Shaders.Translation _BufferFields.Add(fieldInfo); string typeName = HlslKnownTypes.GetMappedName(fieldType); - _BuffersList.Add(new ReadOnlyBufferFieldInfo(typeName, fieldName, readOnlyBuffersCount++)); + _BuffersList.Add(new ReadOnlyBufferFieldInfo(fieldType, typeName, fieldName, readOnlyBuffersCount++)); } else if (HlslKnownTypes.IsReadWriteBufferType(fieldType)) { @@ -161,14 +161,14 @@ namespace ComputeSharp.Shaders.Translation _BufferFields.Add(fieldInfo); string typeName = HlslKnownTypes.GetMappedName(fieldType); - _BuffersList.Add(new ReadWriteBufferFieldInfo(typeName, fieldName, readWriteBuffersCount++)); + _BuffersList.Add(new ReadWriteBufferFieldInfo(fieldType, typeName, fieldName, readWriteBuffersCount++)); } else if (HlslKnownTypes.IsKnownScalarType(fieldType) || HlslKnownTypes.IsKnownVectorType(fieldType)) { // Register the captured field _VariableFields.Add(fieldInfo); string typeName = HlslKnownTypes.GetMappedName(fieldType); - _FieldsList.Add(new CapturedFieldInfo(typeName, fieldName)); + _FieldsList.Add(new CapturedFieldInfo(fieldType, typeName, fieldName)); } else throw new NotSupportedException($"Unsupported field of type {fieldType.FullName}"); }