Fixed issue with repeated static fields in shader body
このコミットが含まれているのは:
1 親
aa4bd1506d
コミット
1879176bb5
3ファイル変更
+9
-6
検索条件に一致するファイルはありません
@@ -43,7 +43,7 @@ namespace ComputeSharp.Shaders.Extensions
|
||||
/// <param name="variable">The info on parsed static fields, if any</param>
|
||||
/// <returns>A <see cref="SyntaxNode"/> instance that is compatible with HLSL</returns>
|
||||
[Pure]
|
||||
public static SyntaxNode ReplaceMember(this MemberAccessExpressionSyntax node, SemanticModel semanticModel, out (string name, FieldInfo FieldInfo)? variable)
|
||||
public static SyntaxNode ReplaceMember(this MemberAccessExpressionSyntax node, SemanticModel semanticModel, out (string Name, FieldInfo FieldInfo)? variable)
|
||||
{
|
||||
SymbolInfo containingMemberSymbolInfo = semanticModel.GetSymbolInfo(node.Expression);
|
||||
SymbolInfo memberSymbolInfo = semanticModel.GetSymbolInfo(node.Name);
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace ComputeSharp.Shaders.Translation
|
||||
// Register the captured static fields
|
||||
foreach (var item in syntaxRewriter.StaticFields)
|
||||
{
|
||||
LoadFieldInfo(item.FieldInfo, item.Name);
|
||||
LoadFieldInfo(item.Value, item.Key);
|
||||
}
|
||||
|
||||
// Get the thread ids identifier name and shader method body
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace ComputeSharp.Shaders.Translation
|
||||
/// <param name="semanticModel"></param>
|
||||
public ShaderSyntaxRewriter(SemanticModel semanticModel) => SemanticModel = semanticModel;
|
||||
|
||||
private readonly List<(string, FieldInfo)> _StaticFields = new List<(string, FieldInfo)>();
|
||||
private readonly Dictionary<string, FieldInfo> _StaticFields = new Dictionary<string, FieldInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of captured static fields used by the target code
|
||||
/// Gets the mapping of captured static fields used by the target code
|
||||
/// </summary>
|
||||
public IReadOnlyList<(string Name, FieldInfo FieldInfo)> StaticFields => _StaticFields;
|
||||
public IReadOnlyDictionary<string, FieldInfo> StaticFields => _StaticFields;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax node)
|
||||
@@ -101,7 +101,10 @@ namespace ComputeSharp.Shaders.Translation
|
||||
SyntaxNode syntaxNode = node.ReplaceMember(SemanticModel, out var variable);
|
||||
|
||||
// Register the captured member, if any
|
||||
if (variable.HasValue) _StaticFields.Add(variable.Value);
|
||||
if (variable.HasValue && !_StaticFields.ContainsKey(variable.Value.Name))
|
||||
{
|
||||
_StaticFields.Add(variable.Value.Name, variable.Value.FieldInfo);
|
||||
}
|
||||
|
||||
return syntaxNode;
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする