Rename package to ComputeSharp.D2D1

Also rename D2D1 to D2D for consistency with HLSL, and tweak namespaces
このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:04:30 +02:00
1 親 d4501323d7
コミット 5390d8b27c
104ファイル変更
+274 -273

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

+36
ファイルの表示
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A model representing gathered info on a shader dispatch data.
/// </summary>
/// <param name="FieldInfos">The description on shader instance fields.</param>
/// <param name="Root32BitConstantCount">The size of the shader root signature, in 32 bit constants.</param>
internal sealed record DispatchDataInfo(ImmutableArray<FieldInfo> FieldInfos, int Root32BitConstantCount)
{
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchDataInfo"/>.
/// </summary>
public sealed class Comparer : Comparer<DispatchDataInfo, Comparer>
{
/// <inheritdoc/>
protected override void AddToHashCode(ref HashCode hashCode, DispatchDataInfo obj)
{
hashCode.AddRange(obj.FieldInfos, FieldInfo.Comparer.Default);
hashCode.Add(obj.Root32BitConstantCount);
}
/// <inheritdoc/>
protected override bool AreEqual(DispatchDataInfo x, DispatchDataInfo y)
{
return
x.FieldInfos.SequenceEqual(y.FieldInfos, FieldInfo.Comparer.Default) &&
x.Root32BitConstantCount == y.Root32BitConstantCount;
}
}
}
+42
ファイルの表示
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A model representing a shared and its compiled bytecode, if available.
/// </summary>
/// <param name="HlslSource">The HLSL source for the shader.</param>
/// <param name="ShaderProfile">The shader profile to use to compile the shader, if requested.</param>
/// <param name="IsLinkingSupported">Whether linking is supported for the current shader.</param>
/// <param name="Bytecode">The compiled shader bytecode, if available.</param>
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, bool IsLinkingSupported, ImmutableArray<byte> Bytecode)
{
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="EmbeddedBytecodeInfo"/>.
/// </summary>
public sealed class Comparer : Comparer<EmbeddedBytecodeInfo, Comparer>
{
/// <inheritdoc/>
protected override void AddToHashCode(ref HashCode hashCode, EmbeddedBytecodeInfo obj)
{
hashCode.Add(obj.HlslSource);
hashCode.Add(obj.ShaderProfile);
hashCode.Add(obj.IsLinkingSupported);
hashCode.AddBytes(obj.Bytecode.AsSpan());
}
/// <inheritdoc/>
protected override bool AreEqual(EmbeddedBytecodeInfo x, EmbeddedBytecodeInfo y)
{
return
x.HlslSource == y.HlslSource &&
x.ShaderProfile == y.ShaderProfile &&
x.IsLinkingSupported == y.IsLinkingSupported &&
x.Bytecode.SequenceEqual(y.Bytecode);
}
}
}
+91
ファイルの表示
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A base type for a model describing a given captured field in a shader.
/// </summary>
internal abstract record FieldInfo
{
/// <summary>
/// A captured primitive value (either a scalar, a vector, or a linear matrix).
/// </summary>
/// <param name="FieldPath">The path of the field with respect to the shader instance.</param>
/// <param name="TypeName">The full metadata name for the primitive type.</param>
/// <param name="Offset">The byte offset of the value within the root signature.</param>
public sealed record Primitive(ImmutableArray<string> FieldPath, string TypeName, int Offset) : FieldInfo;
/// <summary>
/// A captured non linear matrix value.
/// </summary>
/// <param name="FieldPath">The path of the field with respect to the shader instance.</param>
/// <param name="TypeName">The full metadata name for the matrix type.</param>
/// <param name="ElementName">The name of each element in the matrix type.</param>
/// <param name="Rows">The number of rows in the matrix.</param>
/// <param name="Columns">The number of columns in the matrix.</param>
/// <param name="Offsets">The sequence of byte offsets for each row within the root signature.</param>
public sealed record NonLinearMatrix(
ImmutableArray<string> FieldPath,
string TypeName,
string ElementName,
int Rows,
int Columns,
ImmutableArray<int> Offsets) : FieldInfo;
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="FieldInfo"/>.
/// </summary>
public sealed class Comparer : Comparer<FieldInfo, Comparer>
{
/// <inheritdoc/>
protected override void AddToHashCode(ref HashCode hashCode, FieldInfo obj)
{
switch (obj)
{
case Primitive primitive:
hashCode.AddRange(primitive.FieldPath);
hashCode.Add(primitive.TypeName);
hashCode.Add(primitive.Offset);
break;
case NonLinearMatrix matrix:
hashCode.AddRange(matrix.FieldPath);
hashCode.Add(matrix.TypeName);
hashCode.Add(matrix.ElementName);
hashCode.Add(matrix.Rows);
hashCode.Add(matrix.Columns);
hashCode.AddRange(matrix.Offsets);
break;
default:
break;
}
}
/// <inheritdoc/>
protected override bool AreEqual(FieldInfo x, FieldInfo y)
{
if (x is Primitive primitiveX && y is Primitive primitiveY)
{
return
primitiveX.FieldPath.SequenceEqual(primitiveY.FieldPath) &&
primitiveX.TypeName == primitiveY.TypeName &&
primitiveX.Offset == primitiveY.Offset;
}
else if (x is NonLinearMatrix matrixX && y is NonLinearMatrix matrixY)
{
return
matrixX.FieldPath.SequenceEqual(matrixY.FieldPath) &&
matrixX.TypeName == matrixY.TypeName &&
matrixX.ElementName == matrixY.ElementName &&
matrixX.Rows == matrixY.Rows &&
matrixY.Columns == matrixY.Columns &&
matrixX.Offsets.SequenceEqual(matrixY.Offsets);
}
return false;
}
}
}
+9
ファイルの表示
@@ -0,0 +1,9 @@
namespace ComputeSharp.D2D1.SourceGenerators.Models;
/// <summary>
/// A model for extracted info on a processed HLSL shader.
/// </summary>
/// <param name="HlslSource">The HLSL source.</param>
/// <param name="ShaderProfile">The shader profile to use to compile the shader, if requested.</param>
/// <param name="IsLinkingSupported">Whether the shader supports linking.</param>
internal sealed record HlslShaderSourceInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, bool IsLinkingSupported);