Added support for readonly buffers
このコミットが含まれているのは:
1 親
ee96c29f83
コミット
17e0be458f
2ファイル変更
+23
検索条件に一致するファイルはありません
@@ -62,6 +62,15 @@ namespace ComputeSharp.Shaders.Mappings
|
||||
public static bool IsReadWriteBufferType(Type type) => type.IsGenericType &&
|
||||
type.GetGenericTypeDefinition() == typeof(ReadWriteBuffer<>);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not the input type is a <see cref="ReadOnlyBuffer{T}"/> value
|
||||
/// </summary>
|
||||
/// <param name="type">The input <see cref="Type"/> instance to check</param>
|
||||
/// <returns>A <see langword="bool"/> indicating whether the input <see cref="Type"/> is in fact a <see cref="ReadOnlyBuffer{T}"/> instance</returns>
|
||||
[Pure]
|
||||
public static bool IsReadOnlyBufferType(Type type) => type.IsGenericType &&
|
||||
type.GetGenericTypeDefinition() == typeof(ReadOnlyBuffer<>);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not a given <see cref="Type"/> is an HLSL known type
|
||||
/// </summary>
|
||||
|
||||
@@ -107,7 +107,9 @@ namespace ComputeSharp.Shaders.Translation
|
||||
|
||||
List<DescriptorRange> descriptorRanges = new List<DescriptorRange>();
|
||||
List<GraphicsResource> readWriteBuffers = new List<GraphicsResource>();
|
||||
List<GraphicsResource> readOnlyBuffers = new List<GraphicsResource>();
|
||||
int readWriteBuffersCount = 0;
|
||||
int readOnlyBuffersCount = 0;
|
||||
|
||||
foreach (FieldInfo fieldInfo in ShaderFields)
|
||||
{
|
||||
@@ -129,6 +131,18 @@ namespace ComputeSharp.Shaders.Translation
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType);
|
||||
processedFieldInfo = new ReadWriteBufferFieldInfo(typeName, fieldName, readWriteBuffersCount++);
|
||||
}
|
||||
else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType))
|
||||
{
|
||||
// Read only buffer
|
||||
DescriptorRange range = new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, readOnlyBuffersCount);
|
||||
descriptorRanges.Add(range);
|
||||
|
||||
// Reference to the underlying buffer
|
||||
readOnlyBuffers.Add((GraphicsResource)fieldValue);
|
||||
|
||||
string typeName = HlslKnownTypes.GetMappedName(fieldType.GenericTypeArguments[0]);
|
||||
processedFieldInfo = new ConstantBufferFieldInfo(typeName, fieldName, readOnlyBuffersCount++, true);
|
||||
}
|
||||
else if (HlslKnownTypes.IsKnownScalarType(fieldType))
|
||||
{
|
||||
// Static scalar field
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする