class render::Texture

Inherits: RenderProxy

Render thread counterpart of a Texture.

Public

Constructors

Texture

Texture(const TextureCreateInformation &createInformation)

Methods

~Texture

virtual ~Texture() noexcept

Initialize

void Initialize() override

Called on the render thread when the object is first created.

SetName

virtual void SetName(const StringView &name)

Assigns an name to the image, primarily used for easier debugging.

GetName

const String &GetName() const

Returns the name of the image.

Primarily used for debugging purposes.

GetSupportedFormat

virtual PixelFormat GetSupportedFormat() const

Returns the pixel format this texture is using.

This may be different from the requested format in case the device doesn't support it.

Map

virtual GpuTextureMappedScope Map(u32 mipLevel, u32 arrayLayer, GpuMapOptions options) = 0

Maps a texture subresource for CPU access.

mipLevel
Mipmap level to map.
arrayLayer
Texture array layer (or cubemap face, or depth slice) to map.
options
Specifies read/write intent for the mapping.

Returns: RAII scope containing PixelData with mapped memory.

GetDevice

virtual GpuDevice &GetDevice() const = 0

Returns the GPU device this texture belongs to.

Flush

virtual void Flush(u32 mipLevel, u32 arrayLayer)

Flushes CPU writes to the specified subresource to make them visible to the GPU.

Only relevant for directly mappable textures with non-coherent memory.

mipLevel
Mipmap level to flush.
arrayLayer
Array layer (or cubemap face, or depth slice) to flush.

Invalidate

virtual void Invalidate(u32 mipLevel, u32 arrayLayer)

Invalidates GPU writes to the specified subresource to make them visible to the CPU.

Only relevant for directly mappable textures with non-coherent memory.

mipLevel
Mipmap level to invalidate.
arrayLayer
Array layer (or cubemap face, or depth slice) to invalidate.

RecreateInternalTexture

virtual void RecreateInternalTexture() = 0

Recreates the underlying texture.

Note this will clear all currently written data. Old texture will be released once its done being used.

GetMappedMemory

void *GetMappedMemory() const

Returns a pointer to persistently mapped memory, or nullptr if not mappable.

GetUseMask

virtual GpuQueueMask GetUseMask(u32 mipLevel, u32 arrayLayer, GpuAccessFlags accessFlags = GpuAccessFlag::Read | GpuAccessFlag::Write) const = 0

Returns which GPU queues are currently using the specified subresource.

mipLevel
Mipmap level.
arrayLayer
Texture array layer (or cubemap face, or depth slice).
accessFlags
Filter by read/write access type.

GetBoundCount

virtual u32 GetBoundCount(u32 mipLevel, u32 arrayLevel) const = 0

Returns how many command buffers the specified subresource is bound to.

GetUseCount

virtual u32 GetUseCount(u32 mipLevel, u32 arrayLevel) const = 0

Returns how many submitted command buffers are using the specified subresource.

GetProperties

const TextureProperties &GetProperties() const

Returns properties that contain information about the texture.

RequestView

SPtr<TextureView> RequestView(const TextureSurface &surface, GpuViewUsage usage)

Requests a texture view for the specified mip and array ranges.

Returns an existing view of one for the specified ranges already exists, otherwise creates a new one. You must release all views by calling ReleaseView() when done.

surface
Texture surface to create a view for.
usage
Usage of the texture view.

Protected

Methods

CreateView

virtual SPtr<TextureView> CreateView(const TextureViewInformation &desc)

Creates a view of a specific subresource in a texture.

ClearBufferViews

void ClearBufferViews()

Releases all internal texture view references.

Fields

mTextureViews

UnorderedMap<TextureViewInformation, SPtr<TextureView>, TextureView::HashFunction, TextureView::EqualFunction> mTextureViews

mName

String mName

mProperties

TextureProperties mProperties

mInitData

SPtr<PixelData> mInitData

mMappedMemory

void * mMappedMemory