TextureAsset
- Namespace: Turian.Engine.Core
- Source File: TextureAsset.cs
A 2D texture asset. GetContent reads the artifact the importer wrote and uploads it to the GPU: an .amtex container goes up as-is, block compression and mip chain intact, while any other payload is decoded to RGBA8 first. The resulting Texture is cached per asset and device.
Properties
UploadedBytes
(ulong): Bytes of device memory the currently cached textures occupy across every mip level and device. Grows as textures upload and shrinks when the cache is invalidated.
UploadedCount
(int): Number of textures currently held on the GPU.
IsSrgb
(bool) { get; set } = true: Whether the texture is sampled in sRGB color space. True for albedo / base-color / emissive textures; false for normal, metallic-roughness, and other linear data textures.
GenerateMips
(bool) { get; set } = true: Whether mipmaps should be generated when the texture is uploaded.
FlipGreenChannel
(bool) { get; set }: Whether the green channel is inverted relative to the OpenGL/glTF normal-map convention. True for DirectX-convention normal maps. Applied by the shader, since block-compressed data cannot be rewritten at import without recompressing it.
ImportSettings
(TextureImportSettings) { get; set } = new(): How the importer bakes this texture into cache artifacts.
Public Methods
InvalidateCacheEntry
public static void InvalidateCacheEntry(Guid assetId)
Removes the cached Texture for assetId and disposes it. Call this when an asset is reimported so the next access reloads from disk.
Parameters:
assetId(Guid): Identifier of the texture asset.
ClearCache
public static void ClearCache()
Disposes all cached textures and clears the cache. Call this on Vulkan device teardown.
GetContent
public Texture? GetContent(Vulkan vulkan)
Reads this texture's artifact and uploads it to the GPU. The returned Texture is owned by the cache — do not dispose it.
Parameters:
vulkan(Vulkan): The Vulkan context the texture is created on.
Returns: Texture?
- The uploaded texture, or
nullwhen the artifact is missing or undecodable.