Enable tracking external static fields
このコミットが含まれているのは:
1 親
dedfbd8728
コミット
1372d14a90
3ファイル変更
+51
検索条件に一致するファイルはありません
@@ -286,6 +286,12 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
}
|
||||
}
|
||||
|
||||
// Also gather the external static fields (same as in the DX12 generator)
|
||||
foreach ((string, string, string?) externalField in staticFieldDefinitions.Values)
|
||||
{
|
||||
builder.Add(externalField);
|
||||
}
|
||||
|
||||
return builder.ToImmutable();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Mappings;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using ComputeSharp.SourceGeneration.SyntaxProcessors;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
@@ -366,6 +367,44 @@ internal sealed partial class ShaderSourceRewriter(
|
||||
{
|
||||
return updatedNode.Name;
|
||||
}
|
||||
|
||||
// Handle static fields, but only if they're not in the shader type itself. If that is the case, they will already
|
||||
// be discovered separately, when crawling all members of the shader type. Here we only gather external fields.
|
||||
if (fieldOperation.Field.IsStatic &&
|
||||
!SymbolEqualityComparer.Default.Equals(fieldOperation.Field.ContainingType, this.shaderType))
|
||||
{
|
||||
if (!StaticFieldDefinitions.TryGetValue(fieldOperation.Field, out (string Name, string, string?) info))
|
||||
{
|
||||
// Execute the same logic as for shader static fields, to process them and extract the relevant info.
|
||||
// In this case, we use the fully qualified name of the field as identifier, not just the field name.
|
||||
if (HlslDefinitionsSyntaxProcessor.TryGetStaticField(
|
||||
this.shaderType,
|
||||
fieldOperation.Field,
|
||||
SemanticModel,
|
||||
DiscoveredTypes,
|
||||
ConstantDefinitions,
|
||||
StaticFieldDefinitions,
|
||||
Diagnostics,
|
||||
CancellationToken,
|
||||
out _,
|
||||
out string? typeDeclaration,
|
||||
out string? assignmentExpression,
|
||||
out _))
|
||||
{
|
||||
info.Name = fieldOperation.Field.GetFullyQualifiedMetadataName().ToHlslIdentifierName();
|
||||
|
||||
StaticFieldDefinitions.Add(fieldOperation.Field, (info.Name, typeDeclaration, assignmentExpression));
|
||||
}
|
||||
else
|
||||
{
|
||||
// We failed to process the field for whatever reason. Just stop rewriting it and return
|
||||
// the current updated node. We'll have some diagnostic for this case emitted previously.
|
||||
return updatedNode;
|
||||
}
|
||||
}
|
||||
|
||||
return IdentifierName(info.Name);
|
||||
}
|
||||
}
|
||||
|
||||
// If the current member access is a field or property access, check the lookup table
|
||||
|
||||
@@ -300,6 +300,12 @@ partial class ComputeShaderDescriptorGenerator
|
||||
}
|
||||
}
|
||||
|
||||
// Also gather the external static fields
|
||||
foreach ((string, string, string?) externalField in staticFieldDefinitions.Values)
|
||||
{
|
||||
builder.Add(externalField);
|
||||
}
|
||||
|
||||
return builder.ToImmutable();
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする