Skip to content

Replace animation uses of BlittableHelper with RuntimeHelpers.IsReferenceOrContainsReferences - #3481

Merged
xen2 merged 3 commits into
stride3d:masterfrom
ds5678:animation-blittable-channels
Sep 26, 2026
Merged

xen2 merged 3 commits into
stride3d:masterfrom
ds5678:animation-blittable-channels

Conversation

@ds5678

@ds5678 ds5678 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

PR Details

This pull request replaces uses of BlittableHelper with RuntimeHelpers.IsReferenceOrContainsReferences in animation classes.

Related Issue

BlittableHelper is very inefficient. It has a global lock on every call and uses exception handling to check blittability.

Types of changes

  • Docs change / refactoring / dependency upgrade

Checklist

  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Context

I'm working on the assembly processor, and this is a change I can separate out for easier review.

The other uses of BlittableHelper are all in the Stride.Updater namespace. Those uses will be removed as part of my work on those classes.

@xen2 xen2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea, what about adding this to AnimationClip?

internal bool IsChannelBlittable(in Channel channel)
{
    if (channel.CurveIndex != -1)
        return Curves[channel.CurveIndex].IsElementBlittable;

    // Optimized channels are grouped by element type (see Optimize)
    if (OptimizedAnimationDatas != null)
    {
        foreach (var optimizedData in OptimizedAnimationDatas)
        {
            if (optimizedData.ElementType == channel.ElementType)
                return optimizedData.IsElementBlittable;
        }
    }

    throw new InvalidOperationException($"Channel [{channel.PropertyName}] has no curve and no optimized data");
}

Note: Just an idea. if not going that way, current approach would work too but invalidate build cache (cf comment)

Comment thread sources/engine/Stride.Engine/Animations/AnimationClip.cs Outdated

@xen2 xen2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise, thanks!

Comment thread sources/engine/Stride.Engine/Animations/AnimationCurve.cs Outdated
Comment thread sources/engine/Stride.Engine/Animations/AnimationCurve.cs Outdated
Remove `IsElementBlittable` from the public surface
by changing it to `internal` in `AnimationCurve` and
`AnimationData`, and update the concrete overrides
accordingly while preserving internal animation logic.
@ds5678
ds5678 requested a review from xen2 September 26, 2026 21:25
@xen2 xen2 added ci-enduser Run the end-user sample screenshot + packaging suite on this PR ci-ios Run the iOS game test suite on this PR ci-android Run the Android game test suite on this PR labels Sep 26, 2026
@xen2
xen2 merged commit a2f1ad5 into stride3d:master Sep 26, 2026
51 checks passed
@ds5678
ds5678 deleted the animation-blittable-channels branch September 26, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-android Run the Android game test suite on this PR ci-enduser Run the end-user sample screenshot + packaging suite on this PR ci-ios Run the iOS game test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants