diff --git a/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 4ddd43012..9b5058390 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -29,18 +29,14 @@ private partial SyntaxNode RewriteSampledTextureAccess(IInvocationOperation oper } /// - private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName) + partial void TrackKnownMethodInvocation(string metadataName) { - // No special tracking is needed for D2D1 shaders + NeedsD2DRequiresScenePositionAttribute |= HlslKnownMethods.NeedsD2DRequiresScenePositionAttribute(metadataName); } /// - private partial void TrackKnownMethodInvocation(string metadataName) + partial void TrackExternalStaticField(StaticFieldRewriter staticFieldRewriter) { - // Track whether the method needs [D2DRequiresScenePosition] - if (HlslKnownMethods.NeedsD2DRequiresScenePositionAttribute(metadataName)) - { - NeedsD2DRequiresScenePositionAttribute = true; - } + NeedsD2DRequiresScenePositionAttribute |= staticFieldRewriter.NeedsD2DRequiresScenePositionAttribute; } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index e71d9f25f..30ccf7288 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -817,11 +817,17 @@ ArgumentSyntax[] ExtractArguments() /// The instance for the operation. /// The instance for the operation. /// The mapped name for the property access. - private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName); + partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName); /// /// Tracks a method invocation for a known HLSL method. /// /// The metadata name of the method being invoked. - private partial void TrackKnownMethodInvocation(string metadataName); + partial void TrackKnownMethodInvocation(string metadataName); + + /// + /// Tracks an access to an external static field. + /// + /// The instance used to rewrite the field expression. + partial void TrackExternalStaticField(StaticFieldRewriter staticFieldRewriter); } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 4d6847309..9a7b0748d 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -48,7 +48,7 @@ private partial SyntaxNode RewriteSampledTextureAccess(IInvocationOperation oper } /// - private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName) + partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName) { // Mark which dispatch properties have been used, to optimize the declaration afterwards if (operation.Member.IsStatic) @@ -88,10 +88,4 @@ private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operatio } } } - - /// - private partial void TrackKnownMethodInvocation(string metadataName) - { - // No special tracking is needed for DX12 compute shaders - } } \ No newline at end of file