Skip shader fields of not accessible types

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-19 14:04:43 +02:00
1 親 17527764b9
コミット 76f27250f4
4ファイル変更
+24 -2

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

@@ -23,6 +23,7 @@ partial class ComputeShaderDescriptorGenerator
/// Explores a given type hierarchy and generates statements to load fields.
/// </summary>
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
/// <param name="compilation">The input <see cref="Compilation"/> object currently in use.</param>
/// <param name="structDeclarationSymbol">The current shader type being explored.</param>
/// <param name="isPixelShaderLike">Whether the compute shader is "pixel shader like", ie. outputting a pixel into a target texture.</param>
/// <param name="constantBufferSizeInBytes">The size of the shader constant buffer.</param>
@@ -31,6 +32,7 @@ partial class ComputeShaderDescriptorGenerator
/// <param name="resources">The sequence of <see cref="ResourceInfo"/> instances for all captured resources.</param>
public static void GetInfo(
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
Compilation compilation,
ITypeSymbol structDeclarationSymbol,
bool isPixelShaderLike,
out int constantBufferSizeInBytes,
@@ -39,6 +41,7 @@ partial class ComputeShaderDescriptorGenerator
out ImmutableArray<ResourceInfo> resources)
{
static void GetInfo(
Compilation compilation,
ITypeSymbol currentTypeSymbol,
ImmutableArray<string> fieldPath,
ref int resourceOffset,
@@ -56,6 +59,12 @@ partial class ComputeShaderDescriptorGenerator
continue;
}
// Skip fields of not accessible types (the analyzer will handle this)
if (!fieldSymbol.Type.IsAccessibleFromCompilationAssembly(compilation))
{
continue;
}
string fieldName = fieldSymbol.Name;
string typeName = fieldSymbol.Type.GetFullyQualifiedMetadataName();
@@ -78,7 +87,7 @@ partial class ComputeShaderDescriptorGenerator
else if (fieldSymbol.Type.IsUnmanagedType)
{
// Custom struct type defined by the user
GetInfo(fieldSymbol.Type, fieldPath.Add(fieldName), ref resourceOffset, ref rawDataOffset, fields, resources);
GetInfo(compilation, fieldSymbol.Type, fieldPath.Add(fieldName), ref resourceOffset, ref rawDataOffset, fields, resources);
}
}
}
@@ -93,6 +102,7 @@ partial class ComputeShaderDescriptorGenerator
{
// Traverse all shader fields and gather info, and update the tracking offsets
GetInfo(
compilation,
structDeclarationSymbol,
ImmutableArray<string>.Empty,
ref resourceOffset,