Enabled loading/dispatch with texture resources

このコミットが含まれているのは:
Sergio Pedri committed 2020-12-03 18:47:36 +01:00
1 親 ca16a746b9
コミット 71e5c80d84
12ファイル変更
+69 -48

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

+2 -2
ファイルの表示
@@ -14,9 +14,9 @@ namespace ComputeSharp.Shaders.Translation
public string EntryPoint { get; }
/// <summary>
/// Gets the collection of <see cref="HlslBufferInfo"/> items for the shader fields.
/// Gets the collection of <see cref="Renderer.Models.HlslResourceInfo"/> items for the shader fields.
/// </summary>
public IReadOnlyList<HlslBufferInfo> HslsBuffersInfo { get; }
public IReadOnlyList<HlslResourceInfo> HlslResourceInfo { get; }
/// <summary>
/// Gets the collection of <see cref="CapturedFieldInfo"/> items for the shader fields.
+2 -2
ファイルの表示
@@ -114,14 +114,14 @@ namespace ComputeSharp.Shaders.Translation
nameof(NativeObject.ThrowIfDisposed),
BindingFlags.Instance | BindingFlags.NonPublic)!, null);
// Call Buffer<T>.ThrowIfDeviceMismatch(GraphicsDevice)
// Call ThrowIfDeviceMismatch(GraphicsDevice)
il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Ldarg_1);
il.EmitCall(OpCodes.Callvirt, fieldInfo.FieldType.GetMethod(
nameof(Buffer<byte>.ThrowIfDeviceMismatch),
BindingFlags.Instance | BindingFlags.NonPublic)!, null);
// Access Buffer<T>.D3D12GpuDescriptorHandle
// Access D3D12GpuDescriptorHandle
il.EmitReadMember(fieldInfo.FieldType.GetField(
nameof(Buffer<byte>.D3D12GpuDescriptorHandle),
BindingFlags.Instance | BindingFlags.NonPublic)!);
+8 -11
ファイルの表示
@@ -47,9 +47,9 @@ namespace ComputeSharp.Shaders.Translation
private readonly List<D3D12_DESCRIPTOR_RANGE1> d3D12DescriptorRanges1 = new();
/// <summary>
/// The <see cref="List{T}"/> with the <see cref="HlslBufferInfo"/> items for the shader fields.
/// The <see cref="List{T}"/> with the <see cref="Renderer.Models.HlslResourceInfo"/> items for the shader fields.
/// </summary>
private readonly List<HlslBufferInfo> hlslBuffersInfo = new();
private readonly List<HlslResourceInfo> hlslResourceInfo = new();
/// <summary>
/// The <see cref="List{T}"/> with the <see cref="CapturedFieldInfo"/> items for the shader fields.
@@ -85,7 +85,7 @@ namespace ComputeSharp.Shaders.Translation
public string EntryPoint { get; private set; }
/// <inheritdoc/>
public IReadOnlyList<HlslBufferInfo> HslsBuffersInfo => this.hlslBuffersInfo;
public IReadOnlyList<HlslResourceInfo> HlslResourceInfo => this.hlslResourceInfo;
/// <inheritdoc/>
public IReadOnlyList<CapturedFieldInfo> FieldsInfo => this.fieldsInfo;
@@ -156,32 +156,29 @@ namespace ComputeSharp.Shaders.Translation
Type fieldType = fieldInfo.FieldType;
(string hlslName, string hlslType) = Attribute.Fields[fieldInfo.Name];
// Constant buffer
if (HlslKnownTypes.IsConstantBufferType(fieldType))
{
D3D12_DESCRIPTOR_RANGE1 d3D12DescriptorRange1 = new(D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, this.constantBuffersCount);
this.d3D12DescriptorRanges1.Add(d3D12DescriptorRange1);
this.capturedFields.Add(fieldInfo);
this.hlslBuffersInfo.Add(new HlslBufferInfo.Constant(hlslType, hlslName, (int)this.constantBuffersCount++));
this.hlslResourceInfo.Add(new HlslResourceInfo.Constant(hlslType, hlslName, (int)this.constantBuffersCount++));
}
else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType))
else if (HlslKnownTypes.IsReadOnlyResourceType(fieldType))
{
// Root parameter for a readonly buffer
D3D12_DESCRIPTOR_RANGE1 d3D12DescriptorRange1 = new(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, this.readOnlyBuffersCount);
this.d3D12DescriptorRanges1.Add(d3D12DescriptorRange1);
this.capturedFields.Add(fieldInfo);
this.hlslBuffersInfo.Add(new HlslBufferInfo.ReadOnly(hlslType, hlslName, (int)this.readOnlyBuffersCount++));
this.hlslResourceInfo.Add(new HlslResourceInfo.ReadOnly(hlslType, hlslName, (int)this.readOnlyBuffersCount++));
}
else if (HlslKnownTypes.IsReadWriteBufferType(fieldType))
else if (HlslKnownTypes.IsReadWriteResourceType(fieldType))
{
// Root parameter for a read write buffer
D3D12_DESCRIPTOR_RANGE1 d3D12DescriptorRange1 = new(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, this.readWriteBuffersCount);
this.d3D12DescriptorRanges1.Add(d3D12DescriptorRange1);
this.capturedFields.Add(fieldInfo);
this.hlslBuffersInfo.Add(new HlslBufferInfo.ReadWrite(hlslType, hlslName, (int)this.readWriteBuffersCount++));
this.hlslResourceInfo.Add(new HlslResourceInfo.ReadWrite(hlslType, hlslName, (int)this.readWriteBuffersCount++));
}
else if (HlslKnownTypes.IsKnownScalarType(fieldType) || HlslKnownTypes.IsKnownVectorType(fieldType))
{