Skip to content

Commit

Permalink
Track [D2DRequiresScenePosition] from external static fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Dec 6, 2023
1 parent 785f332 commit b832874
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,14 @@ private partial SyntaxNode RewriteSampledTextureAccess(IInvocationOperation oper
}

/// <inheritdoc/>
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);
}

/// <inheritdoc/>
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,17 @@ ArgumentSyntax[] ExtractArguments()
/// <param name="operation">The <see cref="IMemberReferenceOperation"/> instance for the operation.</param>
/// <param name="node">The <see cref="MemberAccessExpressionSyntax"/> instance for the operation.</param>
/// <param name="mappedName">The mapped name for the property access.</param>
private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName);
partial void TrackKnownPropertyAccess(IMemberReferenceOperation operation, MemberAccessExpressionSyntax node, string mappedName);

/// <summary>
/// Tracks a method invocation for a known HLSL method.
/// </summary>
/// <param name="metadataName">The metadata name of the method being invoked.</param>
private partial void TrackKnownMethodInvocation(string metadataName);
partial void TrackKnownMethodInvocation(string metadataName);

/// <summary>
/// Tracks an access to an external static field.
/// </summary>
/// <param name="staticFieldRewriter">The <see cref="StaticFieldRewriter"/> instance used to rewrite the field expression.</param>
partial void TrackExternalStaticField(StaticFieldRewriter staticFieldRewriter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private partial SyntaxNode RewriteSampledTextureAccess(IInvocationOperation oper
}

/// <inheritdoc/>
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)
Expand Down Expand Up @@ -88,10 +88,4 @@ private partial void TrackKnownPropertyAccess(IMemberReferenceOperation operatio
}
}
}

/// <inheritdoc/>
private partial void TrackKnownMethodInvocation(string metadataName)
{
// No special tracking is needed for DX12 compute shaders
}
}

0 comments on commit b832874

Please sign in to comment.