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
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kInvalidId | Default 0xFFFFFFFFu. |
Public functions
| Returns | Name | Description |
|---|---|---|
uint32_t | Add | Wraps FTextureStreamer::Register / RegisterFromSource. |
uint32_t | AddFromSource | |
void | Remove | |
void | SetBounds | |
void | SetInstances | Every instance drawing the texture; the nearest, largest one on screen decides its mip. |
void | SetSwapCallback | Fired from Update() whenever the texture's residency actually changed (the image Ref swapped). |
Ref<Texture2D> | CreateStreamedTexture | Ref-counted Texture2D view of a tracked texture — GetImage() resolves to the CURRENT image. |
void | SetBudgetBytes | 0 = unlimited. |
uint32_t | GetBudgetCoarsenedTextures | 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. |
uint32_t | GetBudgetDroppedMips | |
uint64_t | GetBudgetBytes | |
uint32_t | Update | One frame of streaming: apply finished async swaps, recompute desired mips for the camera, enforce the budget, issue requests. |
uint32_t | Update | |
Ref<Image2D> | GetImage | |
uint32_t | GetDesiredTopMip | |
uint32_t | GetResidentTopMip | |
uint64_t | GetTotalResidentBytes | |
FTextureStreamer& | GetStreamer | |
uint32_t | ComputeDesiredTopMip | 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]. |
float | ComputeScreenPixels | 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). |
float | InstanceWorldSize | 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. |
Function details
Add
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
uint32_t AddFromSource(const std::string& sourcePath, const Vec3& center, float radius, float worldSize, uint32_t tailMips = 3)Remove
void Remove(uint32_t id)SetBounds
void SetBounds(uint32_t id, const Vec3& center, float radius)SetInstances
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
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
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
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
uint32_t GetBudgetCoarsenedTextures() constWhat 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
uint32_t GetBudgetDroppedMips() constGetBudgetBytes
uint64_t GetBudgetBytes() constUpdate
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
uint32_t Update(const std::vector<FTextureStreamingView>& views)GetImage
Ref<Image2D> GetImage(uint32_t id) constGetDesiredTopMip
uint32_t GetDesiredTopMip(uint32_t id) constGetResidentTopMip
uint32_t GetResidentTopMip(uint32_t id) constGetTotalResidentBytes
uint64_t GetTotalResidentBytes() constGetStreamer
FTextureStreamer& GetStreamer()ComputeDesiredTopMip
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
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
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.