150 std::span<const u8> pixels,
164 const std::vector<u8>& pixels,
206 void setData(std::span<const u8> pixels);
212 void setData(
const std::vector<u8>& pixels);
226 const void* data,
u32 sizeBytes,
bool flipY =
false);
253 return handle_ == other.handle_;
303 void setDataRaw(
const void* data,
u32 sizeBytes,
bool flipY =
false);
Who restores a GPU object's contents after the device is lost.
Backend-agnostic graphics enumerations.
Core type definitions and utilities for ESEngine.
A content policy. provider names who refills a Sourced object and key what it refills; both are the p...
Abstract graphics device interface.
void updateSubRegion(u32 xoffset, u32 yoffset, u32 width, u32 height, const void *data, u32 sizeBytes, bool flipY=false)
Uploads pixel data to a sub-rectangle of the texture.
u32 getWidth() const
Gets the texture width in pixels.
Texture(const Texture &)=delete
void bind(u32 slot=0) const
Binds the texture to a texture unit.
static Unique< Texture > createCompressed(GfxDevice &device, GfxContent content, u32 width, u32 height, GfxCompressedFormat format, std::span< const u8 > data, u32 mipLevels=1)
Creates a block-compressed texture (KTX2 → ETC2/ASTC/BC), uploading the pre-compressed blocks in one ...
bool operator==(const Texture &other) const
Compares textures by GPU ID.
static Unique< Texture > createFromExternalId(GfxDevice &device, GfxContent content, u32 glTextureId, u32 width, u32 height, TextureFormat format=TextureFormat::RGBA8)
Hands the device a texture the host made with its own API; the device owns it from here.
void setDataRaw(const void *data, u32 sizeBytes, bool flipY=false)
Updates texture pixel data from raw pointer (internal use).
void unbind() const
Unbinds the texture.
static Unique< Texture > createArray(GfxDevice &device, GfxContent content, const TextureSpecification &spec, const void *pixels)
Creates a 2D texture array from spec.layers layers of spec.width x spec.height.
u32 getHeight() const
Gets the texture height in pixels.
static Unique< Texture > createRaw(GfxDevice &device, GfxContent content, u32 width, u32 height, const void *data, TextureFormat format=TextureFormat::RGBA8, bool flipY=false)
Creates a texture from raw pixel pointer (internal use).
static Unique< Texture > createVolume(GfxDevice &device, GfxContent content, u32 width, u32 height, u32 depth, const void *data, TextureFormat format)
A 3D texture, linearly filtered across all three axes and clamped at every edge.
TextureFormat getFormat() const
Gets the pixel format.
static Unique< Texture > create(GfxDevice &device, GfxContent content, const TextureSpecification &spec)
Creates an empty texture from specification.
u32 getId() const
Gets the texture handle's raw value, for command payloads and the WASM boundary.
void setData(std::span< const u8 > pixels)
Updates texture pixel data from span.
TextureHandle handle() const
Gets the device texture handle.
Texture & operator=(const Texture &)=delete
static Unique< Texture > borrow(GfxDevice &device, TextureHandle texture, u32 width, u32 height)
Names a texture the device already holds for another owner (a render target's colour plane),...
bool adoptContent(Texture &from)
Takes from's pixels behind this texture's handle; from is empty afterwards.
@ Repeat
Tile the texture.
@ Linear
Bilinear interpolation (smooth).
TextureFormat
Texture pixel format.
@ SRGB8A8
sRGB-encoded RGBA8: hardware-linearized on sample (32 bpp)
@ RGBA8
4 channels, 8 bits each (32 bpp)
@ Depth24
Depth buffer format (24 bits).
GfxCompressedFormat
GPU-compressed texture internal formats for createCompressedTexture.
std::unique_ptr< T > Unique
Unique ownership smart pointer.
std::uint32_t u32
Unsigned 32-bit integer.
Texture creation parameters.
TextureFilter minFilter
Minification filter.
bool volume
A 3D texture layers deep (see TextureDesc::volume).
TextureWrap wrapS
Horizontal wrap mode.
u32 height
Texture height in pixels.
bool generateMips
Generate mipmaps automatically.
TextureFormat format
Pixel format.
u32 width
Texture width in pixels.
TextureWrap wrapT
Vertical wrap mode.
TextureFilter magFilter
Magnification filter.
u32 layers
Above 1, a 2D texture array of this many layers (see TextureDesc::layers).