class Texture

Inherits: Resource

Abstract class representing a texture.

Specific render systems have their own Texture implementations. Internally represented as one or more surfaces with pixels in a certain number of dimensions, backed by a hardware buffer.

Public

Constructors

Texture

Texture() = default

*********************************************************************

Methods

WriteData

TAsyncOp<void> WriteData(const SPtr<PixelData> &data, u32 face = 0, u32 mipLevel = 0, bool discardEntireBuffer = false)

Updates the texture with new data.

Provided data buffer will be locked until the operation completes.

data
Pixel data to write. User must ensure it is in format and size compatible with the texture.
face
Texture face to write to.
mipLevel
Mipmap level to write to.
discardEntireBuffer
When true the existing contents of the resource you are updating will be discarded. This can make the operation faster. Resources with certain buffer types might require this flag to be in a specific state otherwise the operation will fail.

Returns: Async operation object you can use to track operation completion.

ReadData

TAsyncOp<void> ReadData(const SPtr<PixelData> &data, u32 face = 0, u32 mipLevel = 0)

Reads internal texture data to the provided previously allocated buffer.

Provided data buffer will be locked until the operation completes.

data
Pre-allocated buffer of proper size and format where data will be read to. You can use TextureProperties::allocBuffer() to allocate a buffer of a correct format and size.
face
Texture face to read from.
mipLevel
Mipmap level to read from.

Returns: Async operation object you can use to track operation completion.

ReadData

TAsyncOp<SPtr<PixelData>> ReadData(u32 face = 0, u32 mipLevel = 0)

Reads internal texture data into a newly allocated buffer.

face
Texture face to read from.
mipLevel
Mipmap level to read from.

Returns: Async operation object that will contain the buffer with the data once the operation completes.

ReadCachedData

void ReadCachedData(PixelData &data, u32 face = 0, u32 mipLevel = 0)

Reads data from the cached system memory texture buffer into the provided buffer.

data
Pre-allocated buffer of proper size and format where data will be read to. You can use TextureProperties::allocBuffer() to allocate a buffer of a correct format and size.
face
Texture face to read from.
mipLevel
Mipmap level to read from.

GetProperties

const TextureProperties &GetProperties() const

Returns properties that contain information about the texture.

staticCreate

static HTexture Create(const TextureCreateInformation &createInformation)

Creates a new texture.

createInformation
Description of the texture to create.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Internal

Methods

staticCreateShared

static SPtr<Texture> CreateShared(const TextureCreateInformation &createInformation)

Same as Create() excepts it creates a pointer to the texture instead of a texture handle.

staticCreateEmpty

static SPtr<Texture> CreateEmpty()

Creates an empty texture with default parameters.

Requires an explicit call to Initialize() before use. Primarily intended for deserialization.

Protected

Constructors

Texture

Texture(const TextureCreateInformation &createInformation, const SPtr<PixelData> &pixelData)

Texture

Texture(const TextureCreateInformation &createInformation)

Methods

Initialize

void Initialize() override

Initializes all the internal data of this object.

Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.

CreateRenderProxy

SPtr<render::RenderProxy> CreateRenderProxy() const override

Creates an object that contains render thread specific data and methods for this object.

Can be null if such object is not required.

CalculateSize

u32 CalculateSize() const

Calculates the size of the texture, in bytes.

CreateCpuBuffers

void CreateCpuBuffers()

Creates buffers used for caching of CPU texture data.

UpdateCpuBuffers

void UpdateCpuBuffers(u32 subresourceIdx, const PixelData &data)

Updates the cached CPU buffers with new data.

Fields

mCPUSubresourceData

Vector<SPtr<PixelData>> mCPUSubresourceData

mProperties

TextureProperties mProperties

mInitData

SPtr<PixelData> mInitData