Streaming

BeginnerArtistProgrammer stream textures, Xenko only loads them when they’re needed. This significantly decreases the time it takes to load a game or scene, uses less memory, and makes your game easier to scale.

Note

Currently, only textures can be streamed.

How Xenko streams textures

Instead of loading a texture when Xenko loads the scene (with all its mipmaps), Xenko only loads it when it’s used (eg a model using the texture is onscreen). When the texture is no longer needed (ie no objects that use the texture are onscreen), Xenko unloads it. Currently, there’s no loading priority for textures. For example, Xenko doesn’t load textures based on distance; instead, Xenko loads them all in sequence.

Using streaming with mipmaps

texture properties, the lower-resolution mipmaps load first, as they’re smaller in size. The gif below shows this process happening in slow motion. In most situations, the process is very quick. We recommend you enable mipmaps for streaming as it means lower-resolution versions of textures act as placeholders until the higher-quality versions can load, reducing pop-in.

When not to use streaming

Streaming is enabled by default for all textures. You might want to disable streaming on important textures you always want to display immediately and in high quality, such as:

  • splash screens
  • textures on player models
  • particles (particles often have a short lifespan, so might disappear before the texture loads)

    Enable or disable streaming on a texture

  • Asset View, select the texture.
  • Property Grid, under Format, use the Stream check box.

    Global streaming settings

    You can access the global streaming settings in the Game Settings asset. These settings apply to all textures that have streaming enabled. Game Settings page.

    Properties

    Access the streaming manager in code

    Streaming. For example, to disable streaming globally, use:
    1. Streaming.EnableStreaming = false;
    To start streaming a texture:
    1. Streaming.StreamResources(myTexture);
    To disable streaming at load time:
    1. var texture = Content.Load<Texture>("myTexture", ContentManagerLoaderSettings.StreamingDisabled);

    Options

    StreamingOptions:
  • KeepLoaded option keeps the texture in memory even when the memory budget is exceeded.
  • ForceHighestQuality option loads only the highest-quality version of the texture.
  • KeepLoaded option keeps the texture in memory even when it’s not used. For example:
    1. var myOptions = new StreamingOptions() { KeepLoaded = true };Streaming.StreamResources(myTexture, myOptions);
    StreamingOptions at runtime, use SetResourceStreamingOptions. For example:
    1. var myNewOptions = new StreamingOptions() { KeepLoaded = false };Streaming.SetResourceStreamingOptions(myTexture, myNewOptions);

    See also

  • StreamingManager API
  • Textures index
  • Texture compression
  • Game Settings