Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [D2DEffectId] and [D2DEffectDisplayName] #560

Merged
merged 17 commits into from
Sep 27, 2023
Merged

Conversation

Sergio0694
Copy link
Owner

Contributes to #551

Description

This PR introduces the following changes:

  • Adds the new [D2DEffectId] and [D2DEffectDisplayName] attributes
  • Source-generate the effect id and display name for every shader type
    • Uses the attribute values, or a deterministic GUID and fully qualified type name otherwise
    • Removes the need for typeof(T).GUID and typeof(T).FullName at runtime
    • Contributes to reducing binary size with NativeAOT
    • Also marginally faster at runtime
    • Includes two new analyzers to enforce correct attribute use

API breakdown

namespace ComputeSharp.D2D1;

[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DEffectIdAttribute : Attribute
{
    public D2DEffectIdAttribute(string value);

    public Guid Value { get; }
}

[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DEffectDisplayNameAttribute : Attribute
{
    public D2DEffectDisplayNameAttribute(string value);

    public string Value { get; }
}

@Sergio0694 Sergio0694 added the optimization 🚀 Performance improvement to existing APIs label Sep 16, 2023
@Sergio0694 Sergio0694 merged commit 318d56d into main Sep 27, 2023
48 checks passed
@Sergio0694 Sergio0694 deleted the dev/effect-metadata branch September 27, 2023 13:02
@Sergio0694 Sergio0694 added the feature 🎉 A brand new feature for ComputeSharp label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎉 A brand new feature for ComputeSharp optimization 🚀 Performance improvement to existing APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant