Table of Contents

Upgrade to Stride 4.5

Upgrade steps

The steps that upgrade a project from a version older than 4.5, and from one 4.5 release to the next.

You don't run these steps yourself: Game Studio runs them when you open a project made with an older version, and stride upgrade runs them from the command line. Each section says what its step changes, and how to make the change by hand when the step fails: the upgrade report (upgrade-report.md) links each step to its section. See the upgrade guide for how steps run and what to do when one fails.

Stride-4.5.0-C1 Use Game.Audio as an extension member of Stride.Audio

Audio left Stride.Engine for the optional Stride.Audio package, and Game.Audio became an extension property there. The step adds using Stride.Audio; to the files that use it, writes this.Audio for a bare Audio in a game class, and Game.Audio for Audio in a script.

By hand: add using Stride.Audio;, and write this.Audio in a class that derives from Game, Game.Audio in a script. Extension properties need C# 14: a project that sets an older LangVersion uses Services.GetService<AudioSystem>() instead.

Stride-4.5.0-C2 Add [EffectKeys] to the types that hold static ParameterKey fields

Warning

A type left without the attribute still compiles, but its keys have no name, so the shaders don't get their values. The build doesn't show it.

The assembly processor no longer names the parameter keys you declare: a source generator does, for the types marked [EffectKeys]. The step adds [EffectKeys] to each class or struct that declares a static field of a ParameterKey type (once, for a partial type).

By hand: add [EffectKeys] (namespace Stride.Rendering) to each type that declares static ParameterKey, ValueParameterKey<T>, ObjectParameterKey<T> or PermutationParameterKey<T> fields, and make the type partial.

Stride-4.5.0-C3 Pass what the Dispatcher callbacks capture as a state, to static lambdas

The assembly processor no longer pools the delegates you pass to Dispatcher.For, ForEach and ForBatched, so a capturing lambda allocates at each call. The step moves each call to the overload that takes a state and a static lambda: what the lambda captured (this, locals) becomes the state. A call with initializeLocal and finalizeLocal becomes a ForBatched. A call is left as it was when the move would change what it does, such as a lambda that writes a captured local.

By hand: pass the values the lambda uses as the state argument, and make the lambda static:

// Before
Dispatcher.For(0, count, i => Update(items[i]));
// After
Dispatcher.For(0, count, (this, items), static (state, i) => state.Item1.Update(state.items[i]));

A call left as it was still works, and allocates.

Stride-4.5.0-P1 Add a Stride.Audio reference, since audio left Stride.Engine

Stride.Engine no longer brings Stride.Audio. The step adds a Stride.Audio reference next to the Stride.Engine one, with the same version, condition and metadata, unless the project already has one. It warns when the project sets a LangVersion older than 14 (see Stride-4.5.0-C1).

By hand: add this reference, with the version of your Stride.Engine reference. Leave it out if the project doesn't use audio.

<PackageReference Include="Stride.Audio" Version="..." />

Stride-4.5.0-P2 Add the plugin packages whose assets the project has

Stride.Assets held the asset types of the plugin packages before 4.5. The step adds a reference, next to the Stride.Engine one, to each package whose assets the project has and doesn't reference:

Files Package
.sdhull Stride.BepuPhysics
.sdvid Stride.Video
.sdphy, .sdhmap Stride.Physics
.sdnavmesh Stride.Navigation
.sdss4s, .sdss4a Stride.SpriteStudio.Runtime
.sdsnd Stride.Audio
.sduipage, .sduilib Stride.UI

When Stride.Engine comes from another file (a Directory.Build.props, for example), the step only warns.

By hand: add the references the table names, with the version of Stride.Engine, where the project gets Stride.Engine. Without them, these assets don't load in Game Studio and don't build.

Stride-4.5.1-C1 Replace the CommandList members that only some graphics APIs had

These CommandList members are gone. The step:

  • renames UnsetRenderTargets to ResetTargets, which unbinds the same targets and also forgets them;
  • removes the calls of ResetQueryPool, which had nothing to do;
  • removes the calls of SetStreamTargets, which bound buffers that no shader could write since 4.4.

By hand: make the same changes. Code that read back stream-output buffers needs a compute shader instead.

Stride-4.5.2-C1 Remove the assignments and subscriptions of BepuSimulation.MaxStepPerFrame

MaxStepPerFrame was replaced by MaximumTimeSpanToProcess, which limits time rather than a number of steps. The step removes the assignments of MaxStepPerFrame.

By hand: delete them, and set MaximumTimeSpanToProcess if the game needs a limit: there is no exact conversion.

Stride-4.5.3-C1 Add CaptureState to the classes that implement IInputDevice

Input devices hold their capture state. The step adds this property to each class that implements IInputDevice itself, not through a base class of Stride, with using Stride.Input;:

public DeviceCaptureState CaptureState { get; } = new DeviceCaptureState();

By hand: add the property to these classes (CS0535 names them).

Stride-4.5.3-C2 Move the overrides of GamePadDeviceBase.State to protected RawState

GamePadDeviceBase.State is no longer virtual, so that it can hide a captured gamepad. A custom gamepad gives its state through RawState. The step renames each override, and its base.State uses become base.RawState:

// Before
public override GamePadState State => state;
// After
protected override GamePadState RawState => state;

By hand: make the same change (CS0506 names each override).

Stride-4.5.4-C1 Move the overrides of the TouchController queries to their protected raw members, such as Trigger to RawTrigger

The queries of TouchController are no longer virtual, so that they can hide a captured controller. A custom virtual reality backend gives its input through the raw members. This step renames each override and makes it protected, and its base.Trigger uses become base.RawTrigger:

// Before
public override float Trigger => ...
// After
protected override float RawTrigger => ...
Query Raw member
Trigger RawTrigger
Grip RawGrip
IndexPointing RawIndexPointing
IndexResting RawIndexResting
ThumbUp RawThumbUp
ThumbResting RawThumbResting
ThumbAxis RawThumbAxis
ThumbstickAxis RawThumbstickAxis
IsPressedDown() IsRawPressedDown()
IsPressed() IsRawPressed()
IsPressReleased() IsRawPressReleased()
IsTouchedDown() IsRawTouchedDown()
IsTouched() IsRawTouched()
IsTouchReleased() IsRawTouchReleased()

By hand: rename each override as the table says and make it protected (CS0506 names each one).