Remove allocations when checking duplicate resource indices
このコミットが含まれているのは:
1 親
a15fce2a54
コミット
eb34817073
2ファイル変更
+25
-10
検索条件に一致するファイルはありません
+11
-5
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -71,14 +70,21 @@ partial class ID2D1ShaderGenerator
|
||||
return;
|
||||
}
|
||||
|
||||
HashSet<uint> inputDescriptionIndices = new(inputDescriptionsBuilder.Select(description => description.Index));
|
||||
Span<bool> selectedInputDescriptionIndices = stackalloc bool[8];
|
||||
|
||||
// All input description indices must be unique
|
||||
if (inputDescriptionIndices.Count != inputDescriptionsBuilder.Count)
|
||||
foreach (InputDescription inputDescription in inputDescriptionsBuilder)
|
||||
{
|
||||
diagnostics.Add(RepeatedD2DInputDescriptionIndices, structDeclarationSymbol, structDeclarationSymbol);
|
||||
ref bool isInputDescriptionIndexUsed = ref selectedInputDescriptionIndices[(int)inputDescription.Index];
|
||||
|
||||
return;
|
||||
if (isInputDescriptionIndexUsed)
|
||||
{
|
||||
diagnostics.Add(RepeatedD2DInputDescriptionIndices, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
isInputDescriptionIndexUsed = true;
|
||||
}
|
||||
|
||||
inputDescriptions = inputDescriptionsBuilder.ToImmutable();
|
||||
|
||||
+14
-5
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -99,12 +99,21 @@ partial class ID2D1ShaderGenerator
|
||||
return;
|
||||
}
|
||||
|
||||
HashSet<int> resourceTextureIndices = new(resourceTextureInfos.Where(info => info.Index.HasValue).Select(info => info.Index!.Value));
|
||||
Span<bool> selectedResourceTextureIndices = stackalloc bool[16];
|
||||
|
||||
// All input description indices must be unique
|
||||
if (resourceTextureIndices.Count != resourceTextureInfos.Count(info => info.Index.HasValue))
|
||||
// All input description indices must be unique (also take this path for invalid indices)
|
||||
foreach ((int? index, _) in resourceTextureInfos)
|
||||
{
|
||||
diagnostics.Add(RepeatedD2DResourceTextureIndices, structDeclarationSymbol, structDeclarationSymbol);
|
||||
ref bool isResourceTextureIndexUsed = ref selectedResourceTextureIndices[index ?? 0];
|
||||
|
||||
if (isResourceTextureIndexUsed)
|
||||
{
|
||||
diagnostics.Add(RepeatedD2DResourceTextureIndices, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
isResourceTextureIndexUsed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする