Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gfx::texture Struct Reference

#include <texture.h>

Inheritance diagram for gfx::texture:
gfx::handle_impl< texture, texture_handle > gfx::ievictable

Public Member Functions

 texture ()=default
 
 texture (const char *_path, std::uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, std::uint8_t _skip=0, texture_info *_info=nullptr)
 
 texture (const void *_data, std::uint32_t _size, std::uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, std::uint8_t _skip=0, texture_info *_info=nullptr, const char *_name=nullptr)
 
 texture (std::uint16_t _width, std::uint16_t _height, bool _hasMips, std::uint16_t _numLayers, texture_format _format, std::uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, const memory_view *_mem=nullptr)
 
 texture (std::uint16_t _width, std::uint16_t _height, std::uint16_t _depth, bool _hasMips, texture_format _format, std::uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, const memory_view *_mem=nullptr)
 
 texture (std::uint16_t _size, bool _hasMips, std::uint16_t _numLayers, texture_format _format, std::uint64_t _flags=BGFX_TEXTURE_NONE|BGFX_SAMPLER_NONE, const memory_view *_mem=nullptr)
 
auto get_size () const -> usize32_t
 
auto is_render_target () const -> bool
 
auto is_gpu_generated () const -> bool
 Whether the texture's contents are produced on the GPU (render target or compute-write) rather than uploaded from CPU memory. Such textures have no CPU backing to restore from, so eviction can only recreate them as empty storage.
 
auto fallback_handle () const -> texture_handle
 
auto get_estimated_gpu_size () const -> std::uint64_t
 
- Public Member Functions inherited from gfx::handle_impl< texture, texture_handle >
 handle_impl ()=default
 
 handle_impl (const handle_impl &)=delete
 
 handle_impl (handle_impl &&)=delete
 
auto operator= (const handle_impl &) -> handle_impl &=delete
 
auto operator= (handle_impl &&) -> handle_impl &=delete
 
 ~handle_impl () override
 
void dispose ()
 
auto is_valid () const -> bool
 
auto native_handle () const -> texture_handle
 
void set_name (const hpp::string_view &_name)
 
auto on_evict () -> std::uint64_t override
 Release the GPU handle. Returns the number of GPU bytes freed. Must be idempotent.
 
auto on_restore () -> bool override
 Recreate the GPU handle from the CPU backing. Returns true on success.
 
auto gpu_size () const -> std::uint64_t override
 Approximate GPU footprint of the resource in bytes.
 
- Public Member Functions inherited from gfx::ievictable
 ievictable ()=default
 
 ievictable (const ievictable &)=delete
 
auto operator= (const ievictable &) -> ievictable &=delete
 
 ievictable (ievictable &&)=delete
 
auto operator= (ievictable &&) -> ievictable &=delete
 
virtual ~ievictable ()=default
 
auto get_evict_class () const -> evict_class
 
auto get_evict_state () const -> evict_state
 
auto get_last_use_frame () const -> std::uint64_t
 
auto get_use_count () const -> std::uint64_t
 
void touch () const noexcept
 

Public Attributes

texture_info info {}
 Texture detail info.
 
std::uint64_t flags = BGFX_TEXTURE_NONE
 Creation flags.
 

Additional Inherited Members

- Public Types inherited from gfx::handle_impl< texture, texture_handle >
using ptr
 
using uptr
 
using weak_ptr
 
using handle_type_t
 
using base_type
 
- Static Public Member Functions inherited from gfx::handle_impl< texture, texture_handle >
static auto invalid_handle () -> texture_handle
 
- Protected Member Functions inherited from gfx::handle_impl< texture, texture_handle >
auto fallback_handle () const -> texture_handle
 
auto get_fallback_handle () const -> texture_handle
 
void make_evictable (std::uint64_t gpu_bytes, std::function< bool(texture &)> restore_fn, evict_class cls=evict_class::evictable)
 
void make_evictable_deferred (std::uint64_t gpu_bytes, std::function< bool(texture &)> restore_fn, evict_class cls=evict_class::evictable)
 
- Protected Attributes inherited from gfx::handle_impl< texture, texture_handle >
texture_handle handle_
 
std::function< bool(texture &)> restore_fn_
 
std::uint64_t gpu_size_
 
- Protected Attributes inherited from gfx::ievictable
std::uint64_t last_use_frame_ {0}
 Frame the resource was last used on (heuristic, written from touch).
 
std::uint64_t use_count_ {0}
 Number of times the resource was used (heuristic, written from touch).
 
evict_state evict_state_ {evict_state::resident}
 Current residency state. Written by the owning resource during evict/restore.
 
evict_class evict_class_ {evict_class::non_evictable}
 Eligibility class. Set once when the resource opts into eviction.
 

Detailed Description

Definition at line 9 of file texture.h.

Constructor & Destructor Documentation

◆ texture() [1/6]

gfx::texture::texture ( )
default

◆ texture() [2/6]

gfx::texture::texture ( const char * _path,
std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
std::uint8_t _skip = 0,
texture_info * _info = nullptr )

Definition at line 124 of file texture.cpp.

◆ texture() [3/6]

gfx::texture::texture ( const void * _data,
std::uint32_t _size,
std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
std::uint8_t _skip = 0,
texture_info * _info = nullptr,
const char * _name = nullptr )

Definition at line 159 of file texture.cpp.

◆ texture() [4/6]

gfx::texture::texture ( std::uint16_t _width,
std::uint16_t _height,
bool _hasMips,
std::uint16_t _numLayers,
texture_format _format,
std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
const memory_view * _mem = nullptr )

Definition at line 187 of file texture.cpp.

◆ texture() [5/6]

gfx::texture::texture ( std::uint16_t _width,
std::uint16_t _height,
std::uint16_t _depth,
bool _hasMips,
texture_format _format,
std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
const memory_view * _mem = nullptr )

Definition at line 238 of file texture.cpp.

◆ texture() [6/6]

gfx::texture::texture ( std::uint16_t _size,
bool _hasMips,
std::uint16_t _numLayers,
texture_format _format,
std::uint64_t _flags = BGFX_TEXTURE_NONE | BGFX_SAMPLER_NONE,
const memory_view * _mem = nullptr )

Definition at line 290 of file texture.cpp.

Member Function Documentation

◆ fallback_handle()

auto gfx::texture::fallback_handle ( ) const -> texture_handle

Definition at line 354 of file texture.cpp.

◆ get_estimated_gpu_size()

auto gfx::texture::get_estimated_gpu_size ( ) const -> std::uint64_t

Definition at line 359 of file texture.cpp.

◆ get_size()

auto gfx::texture::get_size ( ) const -> usize32_t

Definition at line 339 of file texture.cpp.

◆ is_gpu_generated()

auto gfx::texture::is_gpu_generated ( ) const -> bool

Whether the texture's contents are produced on the GPU (render target or compute-write) rather than uploaded from CPU memory. Such textures have no CPU backing to restore from, so eviction can only recreate them as empty storage.

Definition at line 349 of file texture.cpp.

◆ is_render_target()

auto gfx::texture::is_render_target ( ) const -> bool

Definition at line 344 of file texture.cpp.

Member Data Documentation

◆ flags

std::uint64_t gfx::texture::flags = BGFX_TEXTURE_NONE

Creation flags.

Definition at line 127 of file texture.h.

◆ info

texture_info gfx::texture::info {}

Texture detail info.

Definition at line 125 of file texture.h.


The documentation for this struct was generated from the following files: