Add and integrate IConstantBufferInfo interface
このコミットが含まれているのは:
1 親
832e148b67
コミット
4ee81cabce
5ファイル変更
+35
-8
検索条件に一致するファイルはありません
+8
-6
@@ -78,13 +78,15 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
/// <summary>
|
||||
/// Registers a callback to generate additional types, if needed.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="D2D1ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <typeparam name="TInfo">The type of model providing the necessary info.</typeparam>
|
||||
/// <param name="info">The input <typeparamref name="TInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="callbacks">The registered callbacks to generate additional types.</param>
|
||||
/// <param name="usingDirectives">The using directives needed by the generated code.</param>
|
||||
public static void RegisterAdditionalTypesSyntax(
|
||||
D2D1ShaderInfo info,
|
||||
ImmutableArrayBuilder<IndentedTextWriter.Callback<D2D1ShaderInfo>> callbacks,
|
||||
public static void RegisterAdditionalTypesSyntax<TInfo>(
|
||||
TInfo info,
|
||||
ImmutableArrayBuilder<IndentedTextWriter.Callback<TInfo>> callbacks,
|
||||
ImmutableHashSetBuilder<string> usingDirectives)
|
||||
where TInfo : class, IConstantBufferInfo
|
||||
{
|
||||
// If there are no fields, there is no need for a constant buffer type
|
||||
if (info.Fields.IsEmpty)
|
||||
@@ -99,7 +101,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
_ = usingDirectives.Add("global::System.Runtime.InteropServices");
|
||||
|
||||
// Declare the ConstantBuffer type
|
||||
static void ConstantBufferCallback(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
static void ConstantBufferCallback(TInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
string fullyQualifiedTypeName = info.Hierarchy.GetFullyQualifiedTypeName();
|
||||
|
||||
@@ -155,7 +157,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
}
|
||||
|
||||
// Declare the ConstantBufferMarshaller type
|
||||
static void ConstantBufferMarshallerCallback(D2D1ShaderInfo info, IndentedTextWriter writer)
|
||||
static void ConstantBufferMarshallerCallback(TInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
string fullyQualifiedTypeName = info.Hierarchy.GetFullyQualifiedTypeName();
|
||||
|
||||
|
||||
@@ -40,4 +40,4 @@ internal sealed record D2D1ShaderInfo(
|
||||
D2D1PixelOptions PixelOptions,
|
||||
HlslBytecodeInfoKey HlslInfoKey,
|
||||
HlslBytecodeInfo HlslInfo,
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs);
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs) : IConstantBufferInfo;
|
||||
@@ -26,6 +26,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownTypes.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\FieldInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\HlslBytecodeInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\Interfaces\IConstantBufferInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.Diagnostics.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\ShaderSourceRewriter.cs" />
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.Models;
|
||||
|
||||
/// <summary>
|
||||
/// An interface for a model providing info on constant buffer fields.
|
||||
/// </summary>
|
||||
internal interface IConstantBufferInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The hierarchy info for the shader type.
|
||||
/// </summary>
|
||||
HierarchyInfo Hierarchy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the shader constant buffer.
|
||||
/// </summary>
|
||||
int ConstantBufferSizeInBytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The description on shader instance fields.
|
||||
/// </summary>
|
||||
EquatableArray<FieldInfo> Fields { get; }
|
||||
}
|
||||
@@ -34,4 +34,4 @@ internal sealed record ShaderInfo(
|
||||
EquatableArray<ResourceDescriptor> ResourceDescriptors,
|
||||
HlslBytecodeInfoKey HlslInfoKey,
|
||||
HlslBytecodeInfo HlslInfo,
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs);
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs) : IConstantBufferInfo;
|
||||
新しいイシューから参照
ユーザーをブロックする