FTextureStreamer
Texture mip-streaming (slice 1). A streamable texture is a cooked .mtex whose per-mip table lets us read ANY mip range without touching the rest of the file. Registration makes only the coarse TAIL resident; StreamTo(mip) re-reads mips [mip..N) and swaps in a new image (Vulkan commits an image's full memory at creation, so residency changes are recreate-and-swap — the UE non-virtual streaming model). Synchronous v1; async via StreamingIOQueue and GPU-copy reuse of already-resident levels are follow-ups. Consumers must re-query GetImage() after a stream (the Ref changes) — cached descriptor sets keep the OLD image alive until rebound.
- Module
- Game
- Header
#include "Streaming/TextureStreamer.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kInvalidHandle | Default 0xFFFFFFFFu. |
Public functions
| Returns | Name | Description |
|---|---|---|
uint32_t | Register | Reads the header + mip table (not the pixels). |
uint32_t | RegisterFromSource | Register an ordinary image source (PNG/JPG/BMP/...): cooks it into a .mtex mip chain in the DDC (EnsureCookedMtex — requires ddc.TextureCook on + an initialized DDC) and streams from the cache entry. |
void | Unregister | |
bool | StreamTo | Make mips [topMip..chain end) resident. |
bool | StreamToAsync | Async variant: one range-read on the StreamingIOQueue, upload+swap deferred to ApplyCompleted() (GPU uploads and the Ref swap must happen on the main thread). |
uint32_t | ApplyCompleted | Drain finished async reads and finished GPU assemblies, on the CALLER's thread (main). |
bool | HasPendingStream | |
Ref<Image2D> | GetImage | |
uint32_t | GetResidentTopMip | |
uint32_t | GetMipCount | |
uint64_t | GetResidentBytes | |
uint64_t | GetTotalResidentBytes | |
uint32_t | GetTopWidth | Source mip 0 width — the full-resolution extent mip selection is computed against. |
bool | GetAverageColor | The cook-baked linear-space average color from a v2 .mtex header. |
uint64_t | GetChainBytes | Bytes the chain [topMip..N) would occupy if resident — the budget math FTextureStreamingManager coarsens against. |
Function details
Register
uint32_t Register(const std::string& mtexPath, uint32_t tailMips = 3)Reads the header + mip table (not the pixels). tailMips = how many coarsest levels to make resident immediately (clamped to the chain).
RegisterFromSource
uint32_t RegisterFromSource(const std::string& sourcePath, uint32_t tailMips = 3)Register an ordinary image source (PNG/JPG/BMP/...): cooks it into a .mtex mip chain in the DDC (EnsureCookedMtex — requires ddc.TextureCook on + an initialized DDC) and streams from the cache entry. .mtex paths pass straight through to Register.
Unregister
void Unregister(uint32_t handle)StreamTo
bool StreamTo(uint32_t handle, uint32_t topMip)Make mips [topMip..chain end) resident. topMip 0 = full resolution. Returns false when the handle/mip is invalid or IO fails (previous residency is kept).
StreamToAsync
bool StreamToAsync(uint32_t handle, uint32_t topMip, IOPriority priority = IOPriority::High)Async variant: one range-read on the StreamingIOQueue, upload+swap deferred to ApplyCompleted() (GPU uploads and the Ref swap must happen on the main thread). A newer request for the same handle supersedes a pending one (the stale read's apply is dropped).
ApplyCompleted
uint32_t ApplyCompleted()Drain finished async reads and finished GPU assemblies, on the CALLER's thread (main). Uploads are submitted fire-and-forget through the RHI's async image assembly and byte-budgeted per frame (r.TextureStreaming.MaxUploadBytesPerFrame); the visible Ref swap happens only when the GPU work's fence has signalled. Returns how many textures changed residency this call.
HasPendingStream
bool HasPendingStream(uint32_t handle) constGetImage
Ref<Image2D> GetImage(uint32_t handle) constGetResidentTopMip
uint32_t GetResidentTopMip(uint32_t handle) constGetMipCount
uint32_t GetMipCount(uint32_t handle) constGetResidentBytes
uint64_t GetResidentBytes(uint32_t handle) constGetTotalResidentBytes
uint64_t GetTotalResidentBytes() constGetTopWidth
uint32_t GetTopWidth(uint32_t handle) constSource mip 0 width — the full-resolution extent mip selection is computed against.
GetAverageColor
bool GetAverageColor(uint32_t handle, float outRgba[4]) constThe cook-baked linear-space average color from a v2 .mtex header. False for v1 files (no average was baked).
GetChainBytes
uint64_t GetChainBytes(uint32_t handle, uint32_t topMip) constBytes the chain [topMip..N) would occupy if resident — the budget math FTextureStreamingManager coarsens against.