Add diagnostic when [EmbeddedBytecode] is missing

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-19 16:47:34 +01:00
1 親 b9313ca6d8
コミット 71fad3a8fd
4ファイル変更
+49 -22

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

+11 -3
ファイルの表示
@@ -32,26 +32,34 @@ public sealed partial class IShaderGenerator
/// </summary>
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
/// <param name="isDynamicShader">Indicates whether or not the shader is dynamic (ie. captures delegates).</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <param name="diagnostics">The resulting diagnostics from the processing operation.</param>
/// <returns>The thread ids for the precompiled shader, if available.</returns>
public static ThreadIdsInfo GetInfo(
INamedTypeSymbol structDeclarationSymbol,
bool isDynamicShader,
bool supportsDynamicShaders,
out ImmutableArray<Diagnostic> diagnostics)
{
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();
AttributeData? attribute = structDeclarationSymbol
.GetAttributes()
.FirstOrDefault(static a => a.AttributeClass?.ToDisplayString() == typeof(EmbeddedBytecodeAttribute).FullName);
if (attribute is null)
{
diagnostics = ImmutableArray<Diagnostic>.Empty;
// Emit the diagnostics if dynamic shaders are not supported
if (!supportsDynamicShaders)
{
builder.Add(MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported, structDeclarationSymbol, structDeclarationSymbol);
}
diagnostics = builder.ToImmutable();
return new(true, 0, 0, 0);
}
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();
// Validate the thread number arguments
if (attribute.ConstructorArguments.Length != 3 ||
attribute.ConstructorArguments[0].Value is not int threadsX ||