Use type aliases in DX12/D2D generators to write HLSL
このコミットが含まれているのは:
1 親
1cc03cdd7b
コミット
0d667a5da0
8ファイル変更
+121
-105
検索条件に一致するファイルはありません
@@ -28,6 +28,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\FieldInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\HlslBytecodeInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\Interfaces\IConstantBufferInfo.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Models\TypeAliases.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\ConstantBufferSyntaxProcessor.Generation.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\HlslDefinitionsSyntaxProcessor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.Tracking.cs" />
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable IDE0005
|
||||
|
||||
// Shared type aliases for transparent models for gathered HLSL info. These are used
|
||||
// when writing the transpiled HLSL. No need for concrete types for any of these, so
|
||||
// just using type aliases keeps things simpler while still making the code explicit.
|
||||
global using HlslConstant = (string Name, string Value);
|
||||
global using HlslUserType = (string Name, string Definition);
|
||||
global using HlslResourceField = (string MetadataName, string Name, string Type);
|
||||
global using HlslValueField = (string Name, string Type);
|
||||
global using HlslResourceTextureField = (string Name, string Type, int Index);
|
||||
global using HlslStaticField = (string Name, string TypeDeclaration, string? Assignment);
|
||||
global using HlslSharedBuffer = (string Name, string Type, int? Count);
|
||||
global using HlslMethod = (string Signature, string Declaration);
|
||||
+4
-4
@@ -26,9 +26,9 @@ internal static class HlslDefinitionsSyntaxProcessor
|
||||
/// </summary>
|
||||
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
|
||||
/// <returns>A sequence of discovered constants to declare in the shader.</returns>
|
||||
public static ImmutableArray<(string Name, string Value)> GetDefinedConstants(IReadOnlyDictionary<IFieldSymbol, string> constantDefinitions)
|
||||
public static ImmutableArray<HlslConstant> GetDefinedConstants(IReadOnlyDictionary<IFieldSymbol, string> constantDefinitions)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string)> builder = new();
|
||||
using ImmutableArrayBuilder<HlslConstant> builder = new();
|
||||
|
||||
foreach (KeyValuePair<IFieldSymbol, string> constant in constantDefinitions)
|
||||
{
|
||||
@@ -144,14 +144,14 @@ internal static class HlslDefinitionsSyntaxProcessor
|
||||
/// <param name="instanceMethods">The collection of discovered instance methods for custom struct types.</param>
|
||||
/// <param name="constructors">The collection of discovered constructors for custom struct types.</param>
|
||||
/// <returns>A sequence of custom type definitions to add to the shader source.</returns>
|
||||
public static ImmutableArray<(string Name, string Definition)> GetDeclaredTypes(
|
||||
public static ImmutableArray<HlslUserType> GetDeclaredTypes(
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
INamedTypeSymbol structDeclarationSymbol,
|
||||
IEnumerable<INamedTypeSymbol> types,
|
||||
IReadOnlyDictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods,
|
||||
IReadOnlyDictionary<IMethodSymbol, (MethodDeclarationSyntax, MethodDeclarationSyntax)> constructors)
|
||||
{
|
||||
using ImmutableArrayBuilder<(string, string)> builder = new();
|
||||
using ImmutableArrayBuilder<HlslUserType> builder = new();
|
||||
|
||||
IReadOnlyCollection<INamedTypeSymbol> invalidTypes;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
SemanticModelProvider semanticModel,
|
||||
ICollection<INamedTypeSymbol> discoveredTypes,
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
IDictionary<IFieldSymbol, (string, string, string?)> staticFieldDefinitions,
|
||||
IDictionary<IFieldSymbol, HlslStaticField> staticFieldDefinitions,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
CancellationToken token)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
|
||||
/// <summary>
|
||||
/// Gets the collection of discovered static field definitions.
|
||||
/// </summary>
|
||||
protected IDictionary<IFieldSymbol, (string, string, string?)> StaticFieldDefinitions { get; }
|
||||
protected IDictionary<IFieldSymbol, HlslStaticField> StaticFieldDefinitions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of produced <see cref="DiagnosticInfo"/> instances.
|
||||
|
||||
@@ -40,7 +40,7 @@ internal sealed partial class ShaderSourceRewriter(
|
||||
IDictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods,
|
||||
IDictionary<IMethodSymbol, (MethodDeclarationSyntax, MethodDeclarationSyntax)> constructors,
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
IDictionary<IFieldSymbol, (string, string, string?)> staticFieldDefinitions,
|
||||
IDictionary<IFieldSymbol, HlslStaticField> staticFieldDefinitions,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
CancellationToken token,
|
||||
bool isEntryPoint = false)
|
||||
|
||||
@@ -30,7 +30,7 @@ internal sealed partial class StaticFieldRewriter(
|
||||
SemanticModelProvider semanticModel,
|
||||
ICollection<INamedTypeSymbol> discoveredTypes,
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
IDictionary<IFieldSymbol, (string, string, string?)> staticFieldDefinitions,
|
||||
IDictionary<IFieldSymbol, HlslStaticField> staticFieldDefinitions,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
CancellationToken token)
|
||||
: HlslSourceRewriter(semanticModel, discoveredTypes, constantDefinitions, staticFieldDefinitions, diagnostics, token)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする