Search Results for

    Show / Hide Table of Contents

    Class TextureBase

    Base class for Texture, SpriteAtlas, IESProfile and other assets that can contain texture data.

    Inheritance
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    BinaryAsset
    TextureBase
    Inherited Members
    Asset::_deleteFileOnUnload
    BinaryAsset::_dependantAssets
    ScriptingObject::_gcHandle
    BinaryAsset::_header
    ScriptingObject::_id
    BinaryAsset::_isSaving
    Asset::_isVirtual
    Asset::_loadingTask
    Asset::_loadState
    Asset::_refCount
    BinaryAsset::_storageRef
    ScriptingObject::_type
    BinaryAsset::AddDependency(BinaryAsset* asset)
    Asset::AddReference()
    Asset::Asset(const SpawnParams& params, const AssetInfo* info)
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    ScriptingObject::Cast(ScriptingObject* obj)
    Asset::ChangeID(const Guid& newId)
    BinaryAsset::ClearDependencies()
    Asset::const
    BinaryAsset::createLoadingTask()
    Asset::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    Asset::DECLARE_ENUM_7(LoadResult, Ok, Failed, MissingDataChunk, CannotLoadData, CannotLoadStorage, CannotLoadInitData, InvalidData)
    ScriptingObject::Deleted
    Asset::DeleteManaged()
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    BinaryAsset::Dependencies
    Asset::DEPRECATED("Use GetReferences with assets and files parameter instead")
    Asset::DestroyManaged()
    TextureBase
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    BinaryAsset::GetChunk(int32 index)
    BinaryAsset::GetChunkData(int32 index, BytesContainer& data)
    BinaryAsset::GetChunkSize(int32 index)
    BinaryAsset::getChunksToPreload()
    ScriptingObject::GetClass()
    ScriptingObject::GetID()
    BinaryAsset::GetImportMetadata(String& path, String& username)
    BinaryAsset::GetImportPath()
    ScriptingObject::GetManagedInstance()
    BinaryAsset::GetOrCreateChunk(int32 index)
    ScriptingObject::GetOrCreateManagedInstance()
    BinaryAsset::GetPath()
    Asset::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
    Asset::GetReferences()
    Asset::GetReferencesCount()
    BinaryAsset::GetSerializedVersion()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Asset::GetTypeName()
    BinaryAsset::HasChunk(int32 index)
    BinaryAsset::HasChunkLoaded(int32 index)
    BinaryAsset::HasDependenciesModified()
    ScriptingObject::HasManagedInstance()
    BinaryAsset::Init(const FlaxStorageReference& storage, AssetHeader& header)
    BinaryAsset::Init(AssetInitData& initData)
    Asset::InitAsVirtual()
    BinaryAsset::InitVirtual(AssetInitData& initData)
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    Asset::IsInternalType()
    Asset::IsLoaded()
    ScriptingObject::IsRegistered()
    Asset::IsVirtual()
    Asset::LastLoadFailed()
    BinaryAsset::loadAsset()
    BinaryAsset::LoadChunk(int32 chunkIndex)
    BinaryAsset::LoadChunks(AssetChunksFlag chunks)
    TextureBase
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    BinaryAsset::Metadata
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Asset::OnCheckSave(const StringView& path=StringView::Empty)
    BinaryAsset::OnDeleteObject()
    BinaryAsset::OnDependencyModified(BinaryAsset* asset)
    Asset::onLoad(LoadAssetTask* task)
    Asset::OnLoaded
    Asset::onLoaded()
    Asset::onLoaded_MainThread()
    Asset::OnManagedInstanceDeleted()
    Asset::OnReloading
    BinaryAsset::onRename(const StringView& newPath)
    Asset::OnScriptingDispose()
    Asset::onUnload_MainThread()
    Asset::OnUnloaded
    ScriptingObject::RegisterObject()
    BinaryAsset::Reimport()
    BinaryAsset::ReleaseChunk(int32 index)
    BinaryAsset::ReleaseChunks()
    BinaryAsset::releaseStorage()
    Asset::Reload()
    Asset::RemoveReference()
    BinaryAsset::RequestChunkDataAsync(int32 index)
    Asset::Save(const StringView& path=StringView::Empty)
    BinaryAsset::SaveAsset(AssetInitData& data, bool silentMode=false)
    BinaryAsset::SaveAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
    BinaryAsset::SaveToAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    BinaryAsset::SetChunk(int32 index, const Span<byte>& data)
    ManagedScriptingObject::SetManagedInstance(MObject* instance)
    Asset::ShouldDeleteFileOnUnload()
    TextureBase
    Asset::startLoading()
    BinaryAsset::Storage
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Asset::ToString()
    ScriptingObject::UnregisterObject()
    Asset::WaitForLoaded(double timeoutInMilliseconds=30000.0)
    BinaryAsset::~BinaryAsset()
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    Assembly: FlaxEngine.dll
    File: Engine/Graphics/Textures/TextureBase.h
    Syntax
    public class TextureBase : public BinaryAsset, public ITextureOwner

    Fields

    _customData

    Declaration
    protected InitData* _customData
    Field Value
    InitData

    _parent

    Declaration
    protected BinaryAsset* _parent
    Field Value
    BinaryAsset

    _texture

    Declaration
    protected StreamingTexture _texture
    Field Value
    StreamingTexture

    Methods

    CalculateChunkIndex(int32 mipIndex)

    Declaration
    protected virtual int32 CalculateChunkIndex(int32 mipIndex) const
    Parameters
    int32 mipIndex

    Returns
    int32

    CancelStreaming()

    Cancels any asynchronous content streaming by this asset (eg. mesh data streaming into GPU memory). Will release any locks for asset storage container.

    Declaration
    public virtual void CancelStreaming() override
    Overrides
    Asset::CancelStreaming()

    Format()

    Gets the texture data format.

    Declaration
    public PixelFormat Format() const
    Returns
    PixelFormat

    GetArraySize()

    Gets the total array size of the texture.

    Declaration
    public int32 GetArraySize() const
    Returns
    int32

    GetCurrentMemoryUsage()

    Gets the amount of the memory used by this resource. Exact value may differ due to memory alignment and resource allocation policy.

    Declaration
    public uint64 GetCurrentMemoryUsage() const
    Returns
    uint64

    GetMemoryUsage()

    Gets amount of CPU memory used by this resource (in bytes). It's a rough estimation. Memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary.

    Declaration
    public virtual uint64 GetMemoryUsage() const override
    Returns
    uint64

    Overrides
    BinaryAsset::GetMemoryUsage()

    GetMipData(int32 mipIndex, BytesContainer& data)

    Gets texture mip map data. May fail if not data requested. See RequestMipDataAsync.

    Declaration
    public virtual void GetMipData(int32 mipIndex, BytesContainer& data) const override
    Parameters
    int32 mipIndex

    Mip map index

    BytesContainer data

    Result data

    Overrides
    ITextureOwner::GetMipData(int32 mipIndex, BytesContainer& data)

    GetMipData(int32 mipIndex, int32& rowPitch, int32& slicePitch)

    Gets the mip data.

    Declaration
    public BytesContainer GetMipData(int32 mipIndex, int32& rowPitch, int32& slicePitch)
    Parameters
    int32 mipIndex

    The mip index (zero-based).

    int32 rowPitch

    The data row pitch (in bytes).

    int32 slicePitch

    The data slice pitch (in bytes).

    Returns
    BytesContainer

    The mip-map data or empty if failed to get it.

    GetMipDataCustomPitch(int32 mipIndex, uint32& rowPitch, uint32& slicePitch)

    Gets texture mip map data row and slice pitch. Cna be used to override the default values.

    Declaration
    public virtual bool GetMipDataCustomPitch(int32 mipIndex, uint32& rowPitch, uint32& slicePitch) const override
    Parameters
    int32 mipIndex

    Mip map index

    uint32 rowPitch

    Data row pitch (in bytes).

    uint32 slicePitch

    Data slice pitch (in bytes).

    Returns
    bool

    True if has a custom row/slice pitch values, otherwise false (to use default values).

    Overrides
    ITextureOwner::GetMipDataCustomPitch(int32 mipIndex, uint32& rowPitch, uint32& slicePitch)

    GetMipDataWithLoading(int32 mipIndex, BytesContainer& data)

    Gets texture mip map data. Performs loading if data is not in memory (may stall the callee thread).

    Declaration
    public virtual void GetMipDataWithLoading(int32 mipIndex, BytesContainer& data) const override
    Parameters
    int32 mipIndex

    Mip map index

    BytesContainer data

    Result data

    Overrides
    ITextureOwner::GetMipDataWithLoading(int32 mipIndex, BytesContainer& data)

    GetMipLevels()

    Gets the total mip levels count of the texture. Actual resident mipmaps count may be different due to dynamic content streaming.

    Declaration
    public int32 GetMipLevels() const
    Returns
    int32

    GetOwnerLocker()

    Gets the texture owner mutex used to synchronize texture logic.

    Declaration
    public virtual CriticalSection GetOwnerLocker() const override
    Returns
    CriticalSection

    Overrides
    ITextureOwner::GetOwnerLocker()

    GetPixels(Array<Color>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0)

    Gets the texture pixels as Color array.

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Declaration
    public bool GetPixels(Array<Color>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0)
    Parameters
    Array<Color> pixels

    The result texture pixels array.

    int32 mipIndex

    The mip index (zero-based).

    int32 arrayIndex

    The array or depth slice index (zero-based).

    Returns
    bool

    True if failed, otherwise false.

    GetPixels(Array<Color32>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0)

    Gets the texture pixels as Color32 array.

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Declaration
    public bool GetPixels(Array<Color32>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0)
    Parameters
    Array<Color32> pixels

    The result texture pixels array.

    int32 mipIndex

    The mip index (zero-based).

    int32 arrayIndex

    The array or depth slice index (zero-based).

    Returns
    bool

    True if failed, otherwise false.

    GetResidentMipLevels()

    Gets the current mip levels count of the texture that are on GPU ready to use.

    Declaration
    public int32 GetResidentMipLevels() const
    Returns
    int32

    GetTexture()

    Gets GPU texture object allocated by the asset.

    Declaration
    public GPUTexture* GetTexture() const
    Returns
    GPUTexture

    GetTextureData(TextureData& result, bool copyData=true)

    Loads the texture data from the asset.

    Declaration
    public bool GetTextureData(TextureData& result, bool copyData=true)
    Parameters
    TextureData result

    The result data.

    bool copyData

    True if copy asset data to the result buffer, otherwise texture data will be linked to the internal storage (then the data is valid while asset is loaded and there is no texture data copy operations - faster).

    Returns
    bool

    True if cannot load data, otherwise false.

    GetTextureGroup()

    Gets the index of the texture group used by this texture.

    Declaration
    public int32 GetTextureGroup() const
    Returns
    int32

    GetTextureMipData(TextureMipData& result, int32 mipIndex = 0, int32 arrayIndex = 0, bool copyData=true)

    Loads the texture data from the asset (single mip).

    Declaration
    public bool GetTextureMipData(TextureMipData& result, int32 mipIndex = 0, int32 arrayIndex = 0, bool copyData=true)
    Parameters
    TextureMipData result

    The result data.

    int32 mipIndex

    The mip index (zero-based).

    int32 arrayIndex

    The array or depth slice index (zero-based).

    bool copyData

    True if copy asset data to the result buffer, otherwise texture data will be linked to the internal storage (then the data is valid while asset is loaded and there is no texture data copy operations - faster).

    Returns
    bool

    True if cannot load data, otherwise false.

    GetTotalMemoryUsage()

    Gets the total memory usage that texture may have in use (if loaded to the maximum quality). Exact value may differ due to memory alignment and resource allocation policy.

    Declaration
    public uint64 GetTotalMemoryUsage() const
    Returns
    uint64

    HasStreamingError()

    Returns true if texture streaming failed (eg. pixel format is unsupported or texture data cannot be uploaded to GPU due to memory limit).

    Declaration
    public bool HasStreamingError() const
    Returns
    bool

    Height()

    Gets the total height of the texture. Actual resident size may be different due to dynamic content streaming. Returns 0 if texture is not loaded.

    Declaration
    public int32 Height() const
    Returns
    int32

    init(AssetInitData& initData)

    Initializes the specified asset.

    Declaration
    protected virtual bool init(AssetInitData& initData) override
    Parameters
    AssetInitData initData

    The initialize data.

    Returns
    bool

    True if cannot init, otherwise false

    Overrides
    BinaryAsset::init(AssetInitData& initData)

    Init(InitData&& initData)

    Initializes the texture with specified initialize data source (asset must be virtual).

    Declaration
    public bool Init(InitData&& initData)
    Parameters
    InitData initData

    The initializer data. It will be used and released by the asset internal layer (memory allocation will be swapped).

    Returns
    bool

    True if failed, otherwise false.

    Init(InitData* initData)

    Initializes the texture with specified initialize data source (asset must be virtual).

    Declaration
    public bool Init(InitData* initData)
    Parameters
    InitData initData

    The initializer data allocated by the caller with New. It will be owned and released by the asset internal layer.

    Returns
    bool

    True if failed, otherwise false.

    load()

    Load data from the chunks

    Declaration
    protected virtual LoadResult load() override
    Returns
    LoadResult

    Loading result

    Overrides
    BinaryAsset::load()

    LockData()

    Prepares texture data. May lock data chunks to be keep in cache for a while.

    Declaration
    public virtual FlaxStorage::LockData LockData() override
    Returns
    FlaxStorage::LockData

    Overrides
    ITextureOwner::LockData()

    RequestMipDataAsync(int32 mipIndex)

    Get texture mip map data

    Declaration
    public virtual Task* RequestMipDataAsync(int32 mipIndex) override
    Parameters
    int32 mipIndex

    Mip map index

    Returns
    Task

    Task that will get asset data (may be null if data already loaded).

    Overrides
    ITextureOwner::RequestMipDataAsync(int32 mipIndex)

    SetPixels(const Span<Color>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0, bool generateMips=false)

    Sets the texture pixels as Color array (asset must be virtual and already initialized).

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Declaration
    public bool SetPixels(const Span<Color>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0, bool generateMips=false)
    Parameters
    Span<Color> pixels

    The texture pixels array.

    int32 mipIndex

    The mip index (zero-based).

    int32 arrayIndex

    The array or depth slice index (zero-based).

    bool generateMips

    Enables automatic mip-maps generation (fast point filter) based on the current mip (will generate lower mips).

    Returns
    bool

    True if failed, otherwise false.

    SetPixels(const Span<Color32>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0, bool generateMips=false)

    Sets the texture pixels as Color32 array (asset must be virtual and already initialized).

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Declaration
    public bool SetPixels(const Span<Color32>& pixels, int32 mipIndex = 0, int32 arrayIndex = 0, bool generateMips=false)
    Parameters
    Span<Color32> pixels

    The texture pixels array.

    int32 mipIndex

    The mip index (zero-based).

    int32 arrayIndex

    The array or depth slice index (zero-based).

    bool generateMips

    Enables automatic mip-maps generation (fast point filter) based on the current mip (will generate lower mips).

    Returns
    bool

    True if failed, otherwise false.

    SetTextureGroup(int32 textureGroup)

    Sets the index of the texture group used by this texture.

    Declaration
    public void SetTextureGroup(int32 textureGroup)
    Parameters
    int32 textureGroup

    Size()

    Gets the total size of the texture. Actual resident size may be different due to dynamic content streaming. Returns Float2::Zero if texture is not loaded.

    Declaration
    public Float2 Size() const
    Returns
    Float2

    StreamingTexture()

    Gets the streaming texture object handle.

    Declaration
    public StreamingTexture* StreamingTexture() const
    Returns
    StreamingTexture

    unload(bool isReloading)

    Unloads asset data

    Declaration
    protected virtual void unload(bool isReloading) override
    Parameters
    bool isReloading

    True if asset is reloading data, otherwise false.

    Overrides
    Asset::unload(bool isReloading)

    Width()

    Gets the total width of the texture. Actual resident size may be different due to dynamic content streaming. Returns 0 if texture is not loaded.

    Declaration
    public int32 Width() const
    Returns
    int32

    See Also

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat