From be95b2bfc87710775789e07d4f9bb816fc4d95cd Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 24 Sep 2023 17:31:02 +0200 Subject: [PATCH] Remove leftover GetInputTypesSwitchExpression method --- ...nerator.CreateInputTypesProperty.Syntax.cs | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs index 3a767a23..f6ee5550 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs @@ -247,48 +247,5 @@ partial class ID2D1ShaderGenerator return typeDeclaration.AddMembers(memberDeclarations.ToArray()); } - - /// - /// Gets the expression to get the type of a given shader input from its index. - /// - /// The input types for the shader. - /// The expression to extract the values from . - private static ExpressionSyntax GetInputTypesSwitchExpression(ImmutableArray inputTypes) - { - // If there are no inputs, just return an unspecified value. - if (inputTypes.IsEmpty) - { - return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); - } - - // In order to avoid repeated branches, we can build a bitmask that stores in each - // bit whether the corresponding pixel shader input is simple or complex. This will - // allow the logic to be branchless and to just extract the target bit from the mask. - uint bitmask = 0; - - for (int i = 0; i < inputTypes.Length; i++) - { - bitmask |= inputTypes[i] << i; - } - - // If all inputs are simple, also just return 0 - if (bitmask == 0) - { - return LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(0)); - } - - // This code produces a bitmask flag extraction expression as follows: - // - // ( >> (int)index) & 1; - return - BinaryExpression( - SyntaxKind.BitwiseAndExpression, - ParenthesizedExpression( - BinaryExpression( - SyntaxKind.RightShiftExpression, - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bitmask)), - CastExpression(PredefinedType(Token(SyntaxKind.IntKeyword)), IdentifierName("index")))), - LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))); - } } } \ No newline at end of file