Fix handling empty shaders with just artificial fields

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-20 21:11:45 +01:00
1 親 777f8537f2
コミット 940cdfdcdc
4ファイル変更
+46 -13

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

@@ -42,8 +42,8 @@ partial class ConstantBufferSyntaxProcessor
ConstantBufferSyntaxProcessor.generatorName = generatorName;
ConstantBufferSyntaxProcessor.direction = direction;
// If there are no fields, there is no need for a constant buffer type
if (info.Fields.IsEmpty)
// If there are no fields (including artificial ones), there is no need for a constant buffer type
if (info.Fields.IsEmpty && !HasArtificialFields())
{
return;
}
@@ -307,9 +307,22 @@ partial class ConstantBufferSyntaxProcessor
}
callbacks.Add(ConstantBufferCallback);
callbacks.Add(ConstantBufferMarshallerCallback);
// Only emit the marshaller type if there are any non artificial fields.
// Otherwise, it's not needed, as there are either just no fields at all,
// or only artificial ones, which would be assigned directly by callers.
if (!info.Fields.IsEmpty)
{
callbacks.Add(ConstantBufferMarshallerCallback);
}
}
/// <summary>
/// Checks whether any artificial fields are present.
/// </summary>
/// <returns>Whether any artificial fields are present.</returns>
private static partial bool HasArtificialFields();
/// <summary>
/// Appends any artificial fields to the generated constant buffer type.
/// </summary>