Code refactoring in the field info models

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-15 18:38:26 +02:00
1 親 98e5fe86d2
コミット a2e8eef126
9ファイル変更
+48 -45

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

@@ -3,7 +3,7 @@
/// <summary>
/// A <see langword="class"/> that contains info on a shader field
/// </summary>
internal abstract class FieldInfoBase
internal abstract class FieldInfo
{
/// <summary>
/// Gets or sets the type of the current field
@@ -16,11 +16,11 @@
public string FieldName { get; set; }
/// <summary>
/// Creates a new <see cref="FieldInfoBase"/> instance with the specified parameters
/// Creates a new <see cref="FieldInfo"/> 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>
protected FieldInfoBase(string fieldType, string fieldName)
protected FieldInfo(string fieldType, string fieldName)
{
FieldType = fieldType;
FieldName = fieldName;
+24
ファイルの表示
@@ -0,0 +1,24 @@
namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract
{
/// <summary>
/// A <see langword="class"/> that contains info on a shader buffer field
/// </summary>
internal abstract class HlslBufferInfo : FieldInfo
{
/// <summary>
/// Gets or sets the index of the current buffer, relative to its own type
/// </summary>
public int BufferIndex { get; set; }
/// <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="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)
{
BufferIndex = bufferIndex;
}
}
}
+3 -9
ファイルの表示
@@ -5,10 +5,10 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// <summary>
/// A <see langword="class"/> that contains info on a constant buffer field
/// </summary>
internal sealed class ConstantBufferFieldInfo : FieldInfoBase
internal sealed class ConstantBufferFieldInfo : HlslBufferInfo
{
/// <summary>
/// Gets whether or not the current <see cref="FieldInfoBase"/> instance represents a constant buffer (always <see langword="true"/>)
/// Gets whether or not the current <see cref="FieldInfo"/> instance represents a constant buffer (always <see langword="true"/>)
/// </summary>
public bool IsConstantBuffer { get; } = true;
@@ -17,11 +17,6 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// </summary>
public bool IsSingleValue { get; }
/// <summary>
/// Gets the index of the current constant buffer field
/// </summary>
public int ConstantBufferIndex { get; }
/// <summary>
/// Creates a new <see cref="ConstantBufferFieldInfo"/> instance with the specified parameters
/// </summary>
@@ -29,9 +24,8 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// <param name="fieldName">The name of the current field</param>
/// <param name="bufferIndex">The index of the current constant buffer field</param>
/// <param name="singleValue">Whether or not this constant buffer actually contains a single, explicit variable</param>
public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex, bool singleValue) : base(fieldType, fieldName)
public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex, bool singleValue) : base(fieldType, fieldName, bufferIndex)
{
ConstantBufferIndex = bufferIndex;
IsSingleValue = singleValue;
}
}
+3 -11
ファイルの表示
@@ -5,27 +5,19 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// <summary>
/// A <see langword="class"/> that contains info on a readonly buffer field
/// </summary>
internal sealed class ReadOnlyBufferFieldInfo : FieldInfoBase
internal sealed class ReadOnlyBufferFieldInfo : HlslBufferInfo
{
/// <summary>
/// Gets whether or not the current <see cref="FieldInfoBase"/> instance represents a readonly buffer (always <see langword="true"/>)
/// Gets whether or not the current <see cref="FieldInfo"/> instance represents a readonly buffer (always <see langword="true"/>)
/// </summary>
public bool IsReadOnlyBuffer { get; } = true;
/// <summary>
/// Gets the index of the current constant buffer field
/// </summary>
public int ReadOnlyBufferIndex { get; }
/// <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="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)
{
ReadOnlyBufferIndex = bufferIndex;
}
public ReadOnlyBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName, bufferIndex) { }
}
}
+3 -11
ファイルの表示
@@ -5,27 +5,19 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// <summary>
/// A <see langword="class"/> that contains info on a read write buffer field
/// </summary>
internal sealed class ReadWriteBufferFieldInfo : FieldInfoBase
internal sealed class ReadWriteBufferFieldInfo : HlslBufferInfo
{
/// <summary>
/// Gets whether or not the current <see cref="FieldInfoBase"/> instance represents a read write buffer (always <see langword="true"/>)
/// Gets whether or not the current <see cref="FieldInfo"/> instance represents a read write buffer (always <see langword="true"/>)
/// </summary>
public bool IsReadWriteBuffer { get; } = true;
/// <summary>
/// Gets the index of the current read write buffer field
/// </summary>
public int ReadWriteBufferIndex { get; set; }
/// <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="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)
{
ReadWriteBufferIndex = bufferIndex;
}
public ReadWriteBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName, bufferIndex) { }
}
}
+2 -2
ファイルの表示
@@ -5,10 +5,10 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields
/// <summary>
/// A <see langword="class"/> that contains info on a static scalar field
/// </summary>
internal sealed class StaticScalarFieldInfo : FieldInfoBase
internal sealed class StaticScalarFieldInfo : FieldInfo
{
/// <summary>
/// Gets whether or not the current <see cref="FieldInfoBase"/> instance represents a static scalar value (always <see langword="true"/>)
/// Gets whether or not the current <see cref="FieldInfo"/> instance represents a static scalar value (always <see langword="true"/>)
/// </summary>
public bool IsStaticScalarField { get; } = true;
+1 -1
ファイルの表示
@@ -13,7 +13,7 @@ namespace ComputeSharp.Shaders.Renderer.Models
/// <summary>
/// Gets the list of fields being present in the current shader
/// </summary>
public IReadOnlyList<FieldInfoBase> FieldsList { get; set; }
public IReadOnlyList<FieldInfo> FieldsList { get; set; }
/// <summary>
/// Gets or sets the total number of threads to run on the X axis
+2 -2
ファイルの表示
@@ -5,14 +5,14 @@ static {{&FieldType}} {{FieldName}} = {{FieldValue}};
{{/IsStaticScalarField}}
{{!Constant buffer}}
{{#IsConstantBuffer}}
cbuffer {{FieldName}}Buffer : register(b{{ConstantBufferIndex}})
cbuffer {{FieldName}}Buffer : register(b{{BufferIndex}})
{
{{&FieldType}} {{FieldName}}{{^IsSingleValue}}[2]{{/IsSingleValue}};
}
{{/IsConstantBuffer}}
{{!Read write buffer}}
{{#IsReadWriteBuffer}}
{{&FieldType}} {{FieldName}} : SV_DispatchThreadId : register(u{{ReadWriteBufferIndex}});
{{&FieldType}} {{FieldName}} : SV_DispatchThreadId : register(u{{BufferIndex}});
{{/IsReadWriteBuffer}}
{{/FieldsList}}