Added field type to template models

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-17 23:36:12 +02:00
1 親 82a14c2e5c
コミット b7de92c1c0
6ファイル変更
+46 -25

検索条件に一致するファイルはありません

+6 -3
ファイルの表示
@@ -1,4 +1,6 @@
namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
using System;
namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
{
/// <summary>
/// A <see langword="class"/> that contains info on a shader buffer field
@@ -13,10 +15,11 @@
/// <summary>
/// Creates a new <see cref="HlslBufferInfo"/> instance with the specified parameters
/// </summary>
/// <param name="fieldType">The type of the current field</param>
/// <param name="fieldCsharpType">The type of the current field in the C# source</param>
/// <param name="fieldHlslType">The type of the current field in the HLSL shader</param>
/// <param name="fieldName">The name of the current field</param>
/// <param name="bufferIndex">The index of the current buffer field</param>
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;
}
+18 -9
ファイルの表示
@@ -1,4 +1,6 @@
namespace ComputeSharp.Shaders.Renderer.Models.Fields
using System;
namespace ComputeSharp.Shaders.Renderer.Models.Fields
{
/// <summary>
/// A <see langword="class"/> that contains info on a shader field
@@ -6,23 +8,30 @@
internal class CapturedFieldInfo
{
/// <summary>
/// Gets or sets the type of the current field
/// Gets the type of the current field in the C# source
/// </summary>
public string FieldType { get; set; }
public Type FieldCsharpType { get; }
/// <summary>
/// Gets or sets the name to use for the current field
/// Gets the type of the current field in the HLSL shader
/// </summary>
public string FieldName { get; set; }
public string FieldHlslType { get; }
/// <summary>
/// Gets the name to use for the current field
/// </summary>
public string FieldName { get; }
/// <summary>
/// Creates a new <see cref="CapturedFieldInfo"/> instance with the specified parameters
/// </summary>
/// <param name="fieldType">The type of the current field</param>
/// <param name="fieldName">The name of the current field</param>
public CapturedFieldInfo(string fieldType, string fieldName)
/// <param name="fieldCsharpType">The type of the current field in the C# source</param>
/// <param name="fieldHlslType">The type of the current field in the HLSL shader</param>
/// <param name="fieldName">The name to use for the current field</param>
public CapturedFieldInfo(Type fieldCsharpType, string fieldHlslType, string fieldName)
{
FieldType = fieldType;
FieldCsharpType = fieldCsharpType;
FieldHlslType = fieldHlslType;
FieldName = fieldName;
}
}
+6 -3
ファイルの表示
@@ -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
/// <summary>
/// Creates a new <see cref="ConstantBufferFieldInfo"/> instance with the specified parameters
/// </summary>
/// <param name="fieldType">The type of the current field</param>
/// <param name="fieldCsharpType">The type of the current field in the C# source</param>
/// <param name="fieldHlslType">The type of the current field in the HLSL shader</param>
/// <param name="fieldName">The name of the current field</param>
/// <param name="bufferIndex">The index of the current constant buffer field</param>
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) { }
}
}
+6 -3
ファイルの表示
@@ -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
/// <summary>
/// Creates a new <see cref="ReadOnlyBufferFieldInfo"/> instance with the specified parameters
/// </summary>
/// <param name="fieldType">The type of the current field</param>
/// <param name="fieldCsharpType">The type of the current field in the C# source</param>
/// <param name="fieldHlslType">The type of the current field in the HLSL shader</param>
/// <param name="fieldName">The name of the current field</param>
/// <param name="bufferIndex">The index of the current readonly buffer field</param>
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) { }
}
}
+6 -3
ファイルの表示
@@ -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
/// <summary>
/// Creates a new <see cref="ReadWriteBufferFieldInfo"/> instance with the specified parameters
/// </summary>
/// <param name="fieldType">The type of the current field</param>
/// <param name="fieldCsharpType">The type of the current field in the C# source</param>
/// <param name="fieldHlslType">The type of the current field in the HLSL shader</param>
/// <param name="fieldName">The name of the current field</param>
/// <param name="bufferIndex">The index of the current read write buffer field</param>
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) { }
}
}
+4 -4
ファイルの表示
@@ -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}");
}