Blender V5.3
GPU_texture.hh File Reference
#include <string>
#include "BLI_assert.hh"
#include "BLI_bit_span.hh"
#include "BLI_enum_flags.hh"
#include "BLI_index_range.hh"
#include "GPU_format.hh"

Go to the source code of this file.

Classes

struct  blender::GPUSamplerState
struct  blender::GPUPixelBufferNativeHandle

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::gpu

Macros

#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_FORMAT_EXPAND(impl)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl)

Functions

Creation
gpu::Texture * blender::GPU_texture_create_1d (const char *name, int width, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_1d_array (const char *name, int width, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_2d (const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_2d_array (const char *name, int width, int height, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_3d (const char *name, int width, int height, int depth, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
gpu::Texture * blender::GPU_texture_create_cube (const char *name, int width, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_cube_array (const char *name, int width, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
gpu::Texture * blender::GPU_texture_create_compressed_2d (const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
gpu::Texture * blender::GPU_texture_create_from_vertbuf (const char *name, gpu::VertBuf *vertex_buf)
gpu::Texture * blender::GPU_texture_create_error (int dimension, bool array)
Texture Views
gpu::Texture * blender::GPU_texture_create_view (const char *name, gpu::Texture *source_texture, gpu::TextureFormat view_format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array, bool use_stencil)
Binding
void blender::GPU_texture_bind (gpu::Texture *texture, int unit)
void blender::GPU_texture_bind_ex (gpu::Texture *texture, GPUSamplerState state, int unit)
void blender::GPU_texture_unbind (gpu::Texture *texture)
void blender::GPU_texture_unbind_all ()
void blender::GPU_texture_image_bind (gpu::Texture *texture, int unit)
void blender::GPU_texture_image_unbind (gpu::Texture *texture)
void blender::GPU_texture_image_unbind_all ()
State API
void blender::GPU_texture_compare_mode (gpu::Texture *texture, bool use_compare)
void blender::GPU_texture_filter_mode (gpu::Texture *texture, bool use_filter)
void blender::GPU_texture_mipmap_mode (gpu::Texture *texture, bool use_mipmap, bool use_filter)
void blender::GPU_texture_anisotropic_filter (gpu::Texture *texture, bool use_aniso)
void blender::GPU_texture_extend_mode_x (gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void blender::GPU_texture_extend_mode_y (gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void blender::GPU_texture_extend_mode (gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void blender::GPU_texture_swizzle_set (gpu::Texture *texture, const char swizzle[4])
Introspection API
int blender::GPU_texture_dimensions (const gpu::Texture *texture)
int blender::GPU_texture_width (const gpu::Texture *texture)
int blender::GPU_texture_height (const gpu::Texture *texture)
int blender::GPU_texture_depth (const gpu::Texture *texture)
int blender::GPU_texture_layer_count (const gpu::Texture *texture)
int blender::GPU_texture_mip_count (const gpu::Texture *texture)
gpu::TextureFormat blender::GPU_texture_format (const gpu::Texture *texture)
eGPUTextureUsage blender::GPU_texture_usage (const gpu::Texture *texture)
bool blender::GPU_texture_is_array (const gpu::Texture *texture)
bool blender::GPU_texture_is_cube (const gpu::Texture *texture)
bool blender::GPU_texture_is_view (const gpu::Texture *texture)
bool blender::GPU_texture_has_depth_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_stencil_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_integer_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_float_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_normalized_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_signed_format (const gpu::Texture *texture)
bool blender::GPU_texture_has_compressed_format (const gpu::Texture *texture)
void blender::GPU_texture_get_mipmap_size (gpu::Texture *texture, int mip_level, int *r_size)
Python API & meta-data

These are not intrinsic properties of a texture but they are stored inside the gpu::Texture structure for tracking purpose.

int blender::GPU_texture_original_width (const gpu::Texture *texture)
int blender::GPU_texture_original_height (const gpu::Texture *texture)
void blender::GPU_texture_original_size_set (gpu::Texture *texture, int width, int height)
void ** blender::GPU_texture_py_reference_get (gpu::Texture *texture)
void blender::GPU_texture_py_reference_set (gpu::Texture *texture, void **py_ref)
Utilities
size_t blender::GPU_texture_component_len (gpu::TextureFormat format)
size_t blender::GPU_texture_dataformat_size (eGPUDataFormat data_format)
const char * blender::GPU_texture_format_name (gpu::TextureFormat format)
unsigned int blender::GPU_texture_memory_usage_get ()
Pixel Buffer

Used for interfacing with other graphic APIs using graphic interoperability. It can also be used for more efficient partial update from CPU side.

GPUPixelBuffer * blender::GPU_pixel_buffer_create (size_t byte_size)
void blender::GPU_pixel_buffer_free (GPUPixelBuffer *pixel_buf)
void * blender::GPU_pixel_buffer_map (GPUPixelBuffer *pixel_buf)
void blender::GPU_pixel_buffer_unmap (GPUPixelBuffer *pixel_buf)
size_t blender::GPU_pixel_buffer_size (GPUPixelBuffer *pixel_buf)
GPUPixelBufferNativeHandle blender::GPU_pixel_buffer_get_native_handle (GPUPixelBuffer *pixel_buf)
void blender::GPU_texture_update_sub_from_pixel_buffer (gpu::Texture *texture, eGPUDataFormat data_format, GPUPixelBuffer *pixel_buf, int offset_x, int offset_y, int offset_z, int width, int height, int depth)

Sampler State

#define GPU_SAMPLER_EXTEND_MODES_COUNT   (GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER + 1)
#define GPU_SAMPLER_CUSTOM_TYPES_COUNT   (GPU_SAMPLER_CUSTOM_ICON + 1)
enum  blender::GPUSamplerFiltering {
  blender::GPU_SAMPLER_FILTERING_DEFAULT = 0 , blender::GPU_SAMPLER_FILTERING_LINEAR = (1 << 0) , blender::GPU_SAMPLER_FILTERING_MIPMAP = (1 << 1) , blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_2 = (2 << 2) ,
  blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_4 = (3 << 2) , blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_8 = (4 << 2) , blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_16 = (5 << 2)
}
enum  blender::GPUSamplerExtendMode { blender::GPU_SAMPLER_EXTEND_MODE_EXTEND = 0 , blender::GPU_SAMPLER_EXTEND_MODE_REPEAT , blender::GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT , blender::GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER }
enum  blender::GPUSamplerCustomType { blender::GPU_SAMPLER_CUSTOM_COMPARE = 0 , blender::GPU_SAMPLER_CUSTOM_ICON }
enum  blender::GPUSamplerStateType { blender::GPU_SAMPLER_STATE_TYPE_PARAMETERS = 0 , blender::GPU_SAMPLER_STATE_TYPE_CUSTOM , blender::GPU_SAMPLER_STATE_TYPE_INTERNAL }
static const int blender::GPU_SAMPLER_FILTERING_TYPES_COUNT
static constexpr GPUSamplerFiltering blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_MASK
static constexpr GPUSamplerFiltering blender::GPU_SAMPLER_FILTERING_ANISOTROPIC_ENABLE
static GPUSamplerFiltering blender::GPU_anisotropic_filtering_flags (int anisotropic_samples)
static int blender::GPU_anisotropic_samples_get (GPUSamplerFiltering filtering_flags)

Freeing

#define GPU_TEXTURE_FREE_SAFE(texture)
void blender::GPU_texture_ref (gpu::Texture *texture)
void blender::GPU_texture_free (gpu::Texture *texture)

Texture Formats

enum class  blender::gpu::TextureFormat : uint8_t { blender::gpu::Invalid = 0 }
enum class  blender::gpu::TextureTargetFormat : uint8_t { blender::gpu::Invalid = 0 }
enum class  blender::gpu::TextureWriteFormat : uint8_t { blender::gpu::Invalid = 0 }
constexpr DataFormat blender::gpu::to_data_format (TextureFormat format)
constexpr TextureFormat blender::gpu::to_texture_format (TextureTargetFormat format)
constexpr TextureFormat blender::gpu::to_texture_format (TextureWriteFormat format)

Enums

enum  blender::eGPUDataFormat {
  blender::GPU_DATA_FLOAT , blender::GPU_DATA_HALF_FLOAT , blender::GPU_DATA_INT , blender::GPU_DATA_UINT ,
  blender::GPU_DATA_UBYTE , blender::GPU_DATA_UINT_24_8_DEPRECATED , blender::GPU_DATA_10_11_11_REV , blender::GPU_DATA_2_10_10_10_REV
}
enum  blender::eGPUTextureUsage {
  blender::GPU_TEXTURE_USAGE_SHADER_READ = (1 << 0) , blender::GPU_TEXTURE_USAGE_SHADER_WRITE = (1 << 1) , blender::GPU_TEXTURE_USAGE_ATTACHMENT = (1 << 2) , blender::GPU_TEXTURE_USAGE_FORMAT_VIEW = (1 << 3) ,
  blender::GPU_TEXTURE_USAGE_HOST_READ = (1 << 4) , blender::GPU_TEXTURE_USAGE_MEMORYLESS = (1 << 5) , blender::GPU_TEXTURE_USAGE_ATOMIC = (1 << 6) , blender::GPU_TEXTURE_USAGE_MEMORY_EXPORT = (1 << 7) ,
  blender::GPU_TEXTURE_USAGE_GENERAL
}
 blender::ENUM_OPERATORS (eGPUTextureUsage)

Modify & Update

constexpr int blender::GPU_TEXTURE_MIPMAP_UPDATE_CHUNK_SIZE = 256
void blender::GPU_texture_update (gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void blender::GPU_texture_update_sub (gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
void blender::GPU_texture_update_mipmap (gpu::Texture *texture, int mip_level, eGPUDataFormat data_format, const void *pixels, uint unpack_row_length=0)
void blender::GPU_texture_clear (gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void blender::GPU_texture_copy (gpu::Texture *dst, gpu::Texture *src)
eGPUTextureUsage blender::GPU_texture_mipmap_usage (gpu::TextureFormat format)
void blender::GPU_texture_update_mipmap_chain (gpu::Texture *texture)
void blender::GPU_texture_update_mipmap_chain_partial (gpu::Texture *texture, int layer, BitSpan modified_chunks)
void * blender::GPU_texture_read (gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
void blender::GPU_texture_read (gpu::Texture *texture, eGPUDataFormat data_format, int mip_level, void *dst)
size_t blender::GPU_texture_read_size_get (const gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)

Detailed Description

A gpu::Texture is a wrapper around backend specific texture objects. It allows, creation of diverse texture format and types, update, read, reference counting, internal sampler state tracking and texture binding.

Definition in file GPU_texture.hh.

Macro Definition Documentation

◆ DECLARE [1/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(TextureFormat::blender_enum),

Definition at line 44 of file GPU_texture.hh.

◆ DECLARE [2/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(TextureFormat::blender_enum),

Definition at line 44 of file GPU_texture.hh.

◆ DECLARE [3/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(DataFormat::blender_enum),

Definition at line 44 of file GPU_texture.hh.

◆ GPU_SAMPLER_CUSTOM_TYPES_COUNT

#define GPU_SAMPLER_CUSTOM_TYPES_COUNT   (GPU_SAMPLER_CUSTOM_ICON + 1)

◆ GPU_SAMPLER_EXTEND_MODES_COUNT

◆ GPU_TEXTURE_FORMAT_EXPAND

#define GPU_TEXTURE_FORMAT_EXPAND ( impl)

◆ GPU_TEXTURE_FREE_SAFE

◆ GPU_TEXTURE_TARGET_FORMAT_EXPAND

#define GPU_TEXTURE_TARGET_FORMAT_EXPAND ( impl)

Definition at line 146 of file GPU_texture.hh.

Referenced by blender::gpu::to_gpu_format_string().

◆ GPU_TEXTURE_WRITE_FORMAT_EXPAND

#define GPU_TEXTURE_WRITE_FORMAT_EXPAND ( impl)

Definition at line 217 of file GPU_texture.hh.