Implemented shared buffer shader generation

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-12 16:22:38 +01:00
1 親 67d1d92cae
コミット a0265d9f93
3ファイル変更
+31 -6

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

+16
ファイルの表示
@@ -114,6 +114,22 @@ namespace ComputeSharp.Shaders.Renderer
}
}
// Shared buffers
foreach (var buffer in info.SharedBuffers)
{
builder.AppendLine();
builder.Append("groupshared ");
builder.Append(buffer.Value.Type);
builder.Append(' ');
builder.Append(buffer.Key);
builder.Append('[');
if (buffer.Value.Count is int count) builder.Append(count.ToString());
else builder.Append((threadsX * threadsY * threadsZ).ToString());
builder.AppendLine("];");
}
// Captured methods
foreach (var function in info.MethodsInfo)
{
+11 -6
ファイルの表示
@@ -11,31 +11,36 @@ namespace ComputeSharp.Shaders.Translation
/// <summary>
/// Gets the generated source code for the method in the current shader.
/// </summary>
public string EntryPoint { get; }
string EntryPoint { get; }
/// <summary>
/// Gets the collection of <see cref="Renderer.Models.HlslResourceInfo"/> items for the shader fields.
/// </summary>
public IReadOnlyList<HlslResourceInfo> HlslResourceInfo { get; }
IReadOnlyList<HlslResourceInfo> HlslResourceInfo { get; }
/// <summary>
/// Gets the collection of <see cref="CapturedFieldInfo"/> items for the shader fields.
/// </summary>
public IReadOnlyList<CapturedFieldInfo> FieldsInfo { get; }
IReadOnlyList<CapturedFieldInfo> FieldsInfo { get; }
/// <summary>
/// Gets the collection of methods to be used in the shader.
/// </summary>
public IReadOnlyCollection<string> MethodsInfo { get; }
IReadOnlyCollection<string> MethodsInfo { get; }
/// <summary>
/// Gets the collection of constants to be declared in the shader.
/// </summary>
public IReadOnlyDictionary<string, string> ConstantsInfo { get; }
IReadOnlyDictionary<string, string> ConstantsInfo { get; }
/// <summary>
/// Gets the collection of declared types for the shader.
/// </summary>
public IReadOnlyCollection<string> DeclaredTypes { get; }
IReadOnlyCollection<string> DeclaredTypes { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; }
}
}
+4
ファイルの表示
@@ -104,6 +104,9 @@ namespace ComputeSharp.Shaders.Translation
/// <inheritdoc/>
public IReadOnlyCollection<string> DeclaredTypes => this.declaredTypes;
/// <inheritdoc/>
public IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; private set; }
/// <summary>
/// Loads and processes an input<typeparamref name="T"/> shadeer.
/// </summary>
@@ -131,6 +134,7 @@ namespace ComputeSharp.Shaders.Translation
private void LoadMethodMetadata()
{
EntryPoint = Attribute.ExecuteMethod;
SharedBuffers = Attribute.SharedBuffers;
this.declaredTypes.AddRange(Attribute.Types);
this.methodsInfo.AddRange(Attribute.Methods);