Implemented external loading for captured values
このコミットが含まれているのは:
1 親
45b991ff59
コミット
72b4a05d27
2ファイル変更
+15
-19
検索条件に一致するファイルはありません
@@ -89,13 +89,13 @@ namespace ComputeSharp.Shaders
|
||||
commandList.SetPipelineState(pipelineState);
|
||||
|
||||
// Load the captured buffers
|
||||
foreach (var buffer in shaderLoader.Buffers)
|
||||
foreach (var buffer in shaderLoader.GetBuffers(action))
|
||||
{
|
||||
commandList.SetComputeRootDescriptorTable(buffer.Index, buffer.Resource);
|
||||
}
|
||||
|
||||
// Initialize the loop targets
|
||||
IReadOnlyList<object> variables = new object[] { (uint)x, (uint)y, (uint)z }.Concat(shaderLoader.FieldValuesList).ToArray();
|
||||
IReadOnlyList<object> variables = new object[] { (uint)x, (uint)y, (uint)z }.Concat(shaderLoader.GetVariables(action)).ToArray();
|
||||
using GraphicsResource variablesBuffer = device.AllocateConstantBufferFromReflectedValues(variables);
|
||||
commandList.SetComputeRootDescriptorTable(0, variablesBuffer);
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// </summary>
|
||||
private readonly Action<ThreadIds> Action;
|
||||
|
||||
/// <summary>
|
||||
/// The closure instance for the <see cref="Action"/> field
|
||||
/// </summary>
|
||||
private readonly object ShaderInstance;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ShaderLoader"/> with the specified parameters
|
||||
/// </summary>
|
||||
@@ -39,7 +34,6 @@ namespace ComputeSharp.Shaders.Translation
|
||||
{
|
||||
Action = action;
|
||||
ShaderType = action.Method.DeclaringType;
|
||||
ShaderInstance = action.Target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +54,19 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// <summary>
|
||||
/// Gets the ordered collection of buffers used as fields in the current shader
|
||||
/// </summary>
|
||||
public IEnumerable<(int Index, GraphicsResource Resource)> Buffers => _BufferFields.Select((field, i) => (i + 1, (GraphicsResource)field.GetValue(ShaderInstance)));
|
||||
/// <param name="action">The <see cref="Action{T}"/> to use to build the shader</param>
|
||||
public IEnumerable<(int Index, GraphicsResource Resource)> GetBuffers(Action<ThreadIds> action) => _BufferFields.Select((field, i) => (i + 1, (GraphicsResource)field.GetValue(action.Target)));
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="List{T}"/> of <see cref="FieldInfo"/> instances mapping the captured scalar/vector variables in the current shader
|
||||
/// </summary>
|
||||
private readonly List<FieldInfo> _VariableFields = new List<FieldInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of values of the captured fields for the current shader
|
||||
/// </summary>
|
||||
/// <param name="action">The <see cref="Action{T}"/> to use to build the shader</param>
|
||||
public IEnumerable<object> GetVariables(Action<ThreadIds> action) => _VariableFields.Select(field => field.GetValue(action.Target));
|
||||
|
||||
private readonly List<HlslBufferInfo> _BuffersList = new List<HlslBufferInfo>();
|
||||
|
||||
@@ -76,16 +82,6 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// </summary>
|
||||
public IReadOnlyList<CapturedFieldInfo> FieldsList => _FieldsList;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="List{T}"/> of <see cref="FieldInfo"/> instances mapping the captured scalar/vector variables in the current shader
|
||||
/// </summary>
|
||||
private readonly List<FieldInfo> _VariableFields = new List<FieldInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of values of the captured fields for the current shader
|
||||
/// </summary>
|
||||
public IEnumerable<object> FieldValuesList => _VariableFields.Select(field => field.GetValue(ShaderInstance));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the <see cref="ThreadIds"/> variable used as input for the shader method
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする