Removed implicit __z field from pixel shaders
このコミットが含まれているのは:
1 親
31c7058118
コミット
3aeb843023
7ファイル変更
+46
-13
検索条件に一致するファイルはありません
@@ -154,9 +154,11 @@ namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
List<StatementSyntax> statements = new();
|
||||
|
||||
var pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader<byte>) });
|
||||
var isComputeShader = pixelShaderSymbol is null;
|
||||
int
|
||||
resourceOffset = 0,
|
||||
rawDataOffset = sizeof(int) * 3;
|
||||
rawDataOffset = sizeof(int) * (isComputeShader ? 3 : 2);
|
||||
|
||||
AppendFields(structDeclarationSymbol, Array.Empty<string>(), ref resourceOffset, ref rawDataOffset, statements);
|
||||
|
||||
|
||||
@@ -172,6 +172,21 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters
|
||||
|
||||
return updatedNode.WithBody(Block(IfStatement(rangeCheckExpression, updatedNode.Body!)));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node)
|
||||
{
|
||||
IdentifierNameSyntax updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!;
|
||||
|
||||
// Since pixel shaders are only ever executed on 2D textures, the special __z field can
|
||||
// be removed and replaced with just numeric literal expressions, where the value is 1.
|
||||
if (updatedNode.Identifier.Text == "__z")
|
||||
{
|
||||
return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1));
|
||||
}
|
||||
|
||||
return updatedNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする