TextureAsset
TextureAsset: UUID-identified, two-phase loaded texture. Load() lifts a block-compressed .mtex chain for GPU-native upload when the source (or its cooked sidecar) carries one, and otherwise decodes the image from VFS to RGBA8 (CPU, thread-safe). CreateGPU() uploads the BC mips as-is through Image2D::CreateWithMips — no CPU decompress, the cooked compression reaches the device — or the decoded RGBA through Texture2D::Create on the fallback path.
- Module
- AssetSystem
- Header
#include "AssetSystem/Assets/TextureAsset.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
TextureAsset() | TextureAsset | |
~TextureAsset() override | ~TextureAsset |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Load | Asset interface |
void | Unload | |
bool | CreateGPU | |
void | DestroyGPU | |
bool | DestroyGPUIsFrameSafe | |
bool | CanAdoptLoadedState | |
void | AdoptLoadedState | |
Ref<Texture2D> | GetGPUTexture | Get Platform/ texture (available after CreateGPU) |
Ref<Image2D> | GetGPUImage | |
const DecodedImage& | GetDecodedImage | Decoded RGBA8 pixels: filled by Load and, unless the CPU copy is kept, emptied once CreateGPU has uploaded them — the device copy is the one every sampler reads, and a 4K source held a 64 MB duplicate for the asset's lifetime. |
void | SetKeepCpuCopy | Opt-in for a tool that reads the pixels after upload (a CPU sampler, a heightfield, an editor paint tool): call before CreateGPU. |
bool | HasCpuCopy | |
bool | IsArray | A Texture2DArray asset: an array .mtex (FTextureArrayBuilder writes one from a list of images). |
uint32_t | GetLayerCount | |
uint32_t | GetWidth | |
uint32_t | GetHeight | |
uint64_t | EstimatedMemoryUsage | Native BC: the exact cooked chain size. |
TextureImportSettings& | GetImportSettings | Import settings |
const TextureImportSettings& | GetImportSettings | |
bool | HasAuthoredImportSettings | True once a sidecar has spoken for this texture. |
void | WriteImportSettings | Metadata |
void | ReadImportSettings |
Function details
TextureAsset
TextureAsset()~TextureAsset
~TextureAsset() overrideLoad
bool Load(const std::string& path) overrideAsset interface
Unload
void Unload() overrideCreateGPU
bool CreateGPU(const GPUContext& ctx) overrideDestroyGPU
void DestroyGPU() overrideDestroyGPUIsFrameSafe
bool DestroyGPUIsFrameSafe() const overrideCanAdoptLoadedState
bool CanAdoptLoadedState() const overrideAdoptLoadedState
void AdoptLoadedState(Asset& loaded) overrideGetGPUTexture
Ref<Texture2D> GetGPUTexture() constGet Platform/ texture (available after CreateGPU)
GetGPUImage
Ref<Image2D> GetGPUImage() constGetDecodedImage
const DecodedImage& GetDecodedImage() constDecoded RGBA8 pixels: filled by Load and, unless the CPU copy is kept, emptied once CreateGPU has uploaded them — the device copy is the one every sampler reads, and a 4K source held a 64 MB duplicate for the asset's lifetime. A CreateGPU after DestroyGPU re-reads the source.
SetKeepCpuCopy
void SetKeepCpuCopy(bool keep)Opt-in for a tool that reads the pixels after upload (a CPU sampler, a heightfield, an editor paint tool): call before CreateGPU. r.Texture. KeepCpuCopy=1 keeps every texture's copy.
HasCpuCopy
bool HasCpuCopy() constIsArray
bool IsArray() constA Texture2DArray asset: an array .mtex (FTextureArrayBuilder writes one from a list of images). Material graphs sample it with TextureSampleArray; every other consumer sees layer 0.
GetLayerCount
uint32_t GetLayerCount() constGetWidth
uint32_t GetWidth() constGetHeight
uint32_t GetHeight() constEstimatedMemoryUsage
uint64_t EstimatedMemoryUsage() const overrideNative BC: the exact cooked chain size. RGBA8: pixels + full mip chain (×4/3). Once the CPU copy is gone, what the upload measured.
GetImportSettings
TextureImportSettings& GetImportSettings()Import settings
GetImportSettings
const TextureImportSettings& GetImportSettings() constHasAuthoredImportSettings
bool HasAuthoredImportSettings() constTrue once a sidecar has spoken for this texture. Load() derives sRGB and the texture group from the filename ONLY while this is false, so an artist who set sRGB by hand keeps it through every later rescan.
WriteImportSettings
void WriteImportSettings(MdfNode& importNode) const overrideMetadata
ReadImportSettings
void ReadImportSettings(const MdfNode& importNode) override