Code refactoring

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-17 13:00:32 +02:00
1 親 e26b74d276
コミット 45b991ff59
1ファイル変更
+3 -8
+3 -8
ファイルの表示
@@ -31,11 +31,6 @@ namespace ComputeSharp.Shaders.Translation
/// </summary>
private readonly object ShaderInstance;
/// <summary>
/// The sequence of fields in the targeted closure
/// </summary>
private readonly IReadOnlyList<FieldInfo> ShaderFields;
/// <summary>
/// Creates a new <see cref="ShaderLoader"/> with the specified parameters
/// </summary>
@@ -45,7 +40,6 @@ namespace ComputeSharp.Shaders.Translation
Action = action;
ShaderType = action.Method.DeclaringType;
ShaderInstance = action.Target;
ShaderFields = ShaderType.GetFields().ToArray();
}
/// <summary>
@@ -123,7 +117,8 @@ namespace ComputeSharp.Shaders.Translation
/// </summary>
private void LoadFieldsInfo()
{
if (ShaderFields.Any(fieldInfo => fieldInfo.IsStatic)) throw new InvalidOperationException("Empty shader body");
IReadOnlyList<FieldInfo> shaderFields = ShaderType.GetFields().ToArray();
if (shaderFields.Any(fieldInfo => fieldInfo.IsStatic)) throw new InvalidOperationException("Empty shader body");
List<DescriptorRange> descriptorRanges = new List<DescriptorRange>();
int constantBuffersCount = 0;
@@ -134,7 +129,7 @@ namespace ComputeSharp.Shaders.Translation
descriptorRanges.Add(new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, constantBuffersCount++));
// Inspect the captured fields
foreach (FieldInfo fieldInfo in ShaderFields)
foreach (FieldInfo fieldInfo in shaderFields)
{
Type fieldType = fieldInfo.FieldType;
string fieldName = fieldInfo.Name;