Fixed a crash when handling incorrect group shared fields

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-18 00:11:58 +01:00
1 親 4fe3c857be
コミット e278ac8b36
3ファイル変更
+12 -15

検索条件に一致するファイルはありません

+1 -4
ファイルの表示
@@ -21,7 +21,7 @@ namespace ComputeSharp.Sample
using ReadWriteBuffer<float> gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array);
// Run the shader
Gpu.Default.For(100, new MainKernel());
Gpu.Default.For(100, new MainKernel(gpuBuffer));
// Print the initial matrix
PrintMatrix(array, width, height, "BEFORE");
@@ -41,9 +41,6 @@ namespace ComputeSharp.Sample
{
public readonly ReadWriteBuffer<float> buffer;
[GroupShared]
public static string[] Foo;
/// <inheritdoc/>
public void Execute()
{
+10 -10
ファイルの表示
@@ -95,6 +95,8 @@ namespace ComputeSharp.SourceGenerators
{
foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic) continue;
// Captured fields must be named type symbols
if (fieldSymbol.Type is not INamedTypeSymbol typeSymbol)
{
@@ -106,15 +108,6 @@ namespace ComputeSharp.SourceGenerators
continue;
}
if (fieldSymbol.IsStatic) continue;
string typeName = HlslKnownTypes.GetMappedName(typeSymbol);
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);
// Yield back the current mapping for the name (if the name used a reserved keyword)
yield return new[] { fieldSymbol.Name, mapping ?? fieldSymbol.Name, typeName };
// Track the type of items in the current buffer
if (HlslKnownTypes.IsTypedResourceType(typeSymbol.GetFullMetadataName()) &&
typeSymbol.TypeArguments.Length == 1)
@@ -129,6 +122,13 @@ namespace ComputeSharp.SourceGenerators
fieldSymbol.Locations.FirstOrDefault(),
structDeclarationSymbol, fieldSymbol.Name, typeSymbol));
}
string typeName = HlslKnownTypes.GetMappedName(typeSymbol);
_ = HlslKnownKeywords.TryGetMappedName(fieldSymbol.Name, out string? mapping);
// Yield back the current mapping for the name (if the name used a reserved keyword)
yield return new[] { fieldSymbol.Name, mapping ?? fieldSymbol.Name, typeName };
}
}
@@ -163,7 +163,7 @@ namespace ComputeSharp.SourceGenerators
continue;
}
if (typeSymbol.ElementType.IsUnmanagedType)
if (!typeSymbol.ElementType.IsUnmanagedType)
{
context.ReportDiagnostic(Diagnostic.Create(
DiagnosticDescriptors.InvalidGroupSharedFieldElementType,
+1 -1
ファイルの表示
@@ -195,7 +195,7 @@ namespace ComputeSharp.SourceGenerators.Mappings
{
if (KnownTypes.ContainsKey(type.GetFullMetadataName())) return;
customTypes.Add(type);
if (!customTypes.Add(type)) return;
foreach (var field in type.GetMembers().OfType<IFieldSymbol>())
{