class

FTextureStreamingManager

Camera-distance mip prioritization on top of FTextureStreamer. Each tracked texture carries world-space bounds + the world extent one repeat of the texture covers; Update() projects that extent to screen pixels, picks the top mip whose resolution matches, coarsens the FARTHEST textures first while the residency budget is exceeded, and drives StreamToAsync (High priority for detail upgrades, Background for downgrades) + ApplyCompleted. Consumers re-query GetImage() after Update — the Ref changes when residency does.

Module
Game
Header
#include "Streaming/TextureStreamingManager.h"
Namespace
Mowo

Properties

TypeNameDescription
static constexpr uint32_tkInvalidIdDefault 0xFFFFFFFFu.

Public functions

ReturnsNameDescription
uint32_tAddWraps FTextureStreamer::Register / RegisterFromSource.
uint32_tAddFromSource
voidRemove
voidSetBounds
voidSetInstancesEvery instance drawing the texture; the nearest, largest one on screen decides its mip.
voidSetSwapCallbackFired from Update() whenever the texture's residency actually changed (the image Ref swapped).
Ref<Texture2D>CreateStreamedTextureRef-counted Texture2D view of a tracked texture — GetImage() resolves to the CURRENT image.
voidSetBudgetBytes0 = unlimited.
uint32_tGetBudgetCoarsenedTexturesWhat the last Update's budget pass took away: how many textures it coarsened below the mip their screen size wanted, and by how many mip levels in total.
uint32_tGetBudgetDroppedMips
uint64_tGetBudgetBytes
uint32_tUpdateOne frame of streaming: apply finished async swaps, recompute desired mips for the camera, enforce the budget, issue requests.
uint32_tUpdate
Ref<Image2D>GetImage
uint32_tGetDesiredTopMip
uint32_tGetResidentTopMip
uint64_tGetTotalResidentBytes
FTextureStreamer&GetStreamer
uint32_tComputeDesiredTopMipPure mip selection: smallest (finest) top mip whose resolution does not exceed what screenPixels can show — ceil(log2(topWidth/px)), clamped to [0, mipCount-1].
floatComputeScreenPixelsThe largest on-screen size, in pixels, any instance reaches in any view, and the nearest instance distance (the budget pass coarsens the farthest first).
floatInstanceWorldSizeThe world span one texture repeat covers on an instance: the mesh's UV density (GPUMesh::GetUvDensity, mesh-local units per repeat) times the instance's largest axis scale; with no density, the largest world extent — one repeat across the whole mesh.

Function details

Add

C++
uint32_t Add(const std::string& mtexPath, const Vec3& center, float radius, float worldSize, uint32_t tailMips = 3)

Wraps FTextureStreamer::Register / RegisterFromSource. worldSize = world-space extent (meters) one repeat of the texture covers; center/radius = bounds of the geometry using it.

AddFromSource

C++
uint32_t AddFromSource(const std::string& sourcePath, const Vec3& center, float radius, float worldSize, uint32_t tailMips = 3)

Remove

C++
void Remove(uint32_t id)

SetBounds

C++
void SetBounds(uint32_t id, const Vec3& center, float radius)

SetInstances

C++
void SetInstances(uint32_t id, std::vector<FTextureStreamingInstance> instances)

Every instance drawing the texture; the nearest, largest one on screen decides its mip. A shared texture judged by one arbitrary instance starved every other one of detail. Empty keeps the current bounds.

SetSwapCallback

C++
void SetSwapCallback(uint32_t id, std::function<void()> callback)

Fired from Update() whenever the texture's residency actually changed (the image Ref swapped). The material-rebind hook: re-set the streamed texture on its Material here so the texture version bumps and the renderer's DS cache rebuilds against the new image.

CreateStreamedTexture

C++
Ref<Texture2D> CreateStreamedTexture(uint32_t id)

Ref-counted Texture2D view of a tracked texture — GetImage() resolves to the CURRENT image. Bind it to Material texture slots.

SetBudgetBytes

C++
void SetBudgetBytes(uint64_t bytes)

0 = unlimited. The budget is enforced against DESIRED residency — the manager coarsens desires before requesting, it never lets the requested set exceed the budget.

GetBudgetCoarsenedTextures

C++
uint32_t GetBudgetCoarsenedTextures() const

What the last Update's budget pass took away: how many textures it coarsened below the mip their screen size wanted, and by how many mip levels in total. Zero while everything fits.

GetBudgetDroppedMips

C++
uint32_t GetBudgetDroppedMips() const

GetBudgetBytes

C++
uint64_t GetBudgetBytes() const

Update

C++
uint32_t Update(const Vec3& cameraPos, float fovYRadians, uint32_t viewportHeightPx)

One frame of streaming: apply finished async swaps, recompute desired mips for the camera, enforce the budget, issue requests. Returns how many textures changed residency this call.

Update

C++
uint32_t Update(const std::vector<FTextureStreamingView>& views)

GetImage

C++
Ref<Image2D> GetImage(uint32_t id) const

GetDesiredTopMip

C++
uint32_t GetDesiredTopMip(uint32_t id) const

GetResidentTopMip

C++
uint32_t GetResidentTopMip(uint32_t id) const

GetTotalResidentBytes

C++
uint64_t GetTotalResidentBytes() const

GetStreamer

C++
FTextureStreamer& GetStreamer()

ComputeDesiredTopMip

C++
static uint32_t ComputeDesiredTopMip(uint32_t topWidth, uint32_t mipCount, float screenPixels)

Pure mip selection: smallest (finest) top mip whose resolution does not exceed what screenPixels can show — ceil(log2(topWidth/px)), clamped to [0, mipCount-1]. Exposed for tests.

ComputeScreenPixels

C++
static float ComputeScreenPixels(const std::vector<FTextureStreamingInstance>& instances, const std::vector<FTextureStreamingView>& views, float& outNearestDistance)

The largest on-screen size, in pixels, any instance reaches in any view, and the nearest instance distance (the budget pass coarsens the farthest first). Exposed for tests.

InstanceWorldSize

C++
static float InstanceWorldSize(float uvDensity, float maxAxisScale, const Vec3& worldExtent)

The world span one texture repeat covers on an instance: the mesh's UV density (GPUMesh::GetUvDensity, mesh-local units per repeat) times the instance's largest axis scale; with no density, the largest world extent — one repeat across the whole mesh.

Generated from Streaming/TextureStreamingManager.h via game.json · Nov 5, 2026Version 1.0.0