Skip to content

Add [D2DEffectId] and [D2DEffectDisplayName] - #560

Merged
Sergio0694 merged 17 commits into
mainfrom
dev/effect-metadata
Sep 27, 2023
Merged

Sergio0694 merged 17 commits into
mainfrom
dev/effect-metadata

Conversation

@Sergio0694

Copy link
Copy Markdown
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
@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