Blender  V2.93
Namespaces
gpu_texture.cc File Reference
#include "BLI_string.h"
#include "GPU_framebuffer.h"
#include "GPU_texture.h"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_framebuffer_private.hh"
#include "gpu_vertex_buffer_private.hh"
#include "gpu_texture_private.hh"

Go to the source code of this file.

Namespaces

 blender
 
 blender::gpu
 

Functions

C-API
uint GPU_texture_memory_usage_get (void)
 
static GPUTexturegpu_texture_create (const char *name, const int w, const int h, const int d, const eGPUTextureType type, int UNUSED(mips), eGPUTextureFormat tex_format, eGPUDataFormat data_format, const void *pixels)
 
GPUTextureGPU_texture_create_1d (const char *name, int w, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_1d_array (const char *name, int w, int h, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_2d (const char *name, int w, int h, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_2d_array (const char *name, int w, int h, int d, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_3d (const char *name, int w, int h, int d, int mips, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
 
GPUTextureGPU_texture_create_cube (const char *name, int w, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_cube_array (const char *name, int w, int d, int mips, eGPUTextureFormat format, const float *data)
 
GPUTextureGPU_texture_create_compressed_2d (const char *name, int w, int h, int miplen, eGPUTextureFormat tex_format, const void *data)
 
GPUTextureGPU_texture_create_from_vertbuf (const char *name, GPUVertBuf *vert)
 
GPUTextureGPU_texture_create_error (int dimension, bool is_array)
 
void GPU_texture_update_mipmap (GPUTexture *tex_, int miplvl, eGPUDataFormat data_format, const void *pixels)
 
void GPU_texture_update_sub (GPUTexture *tex, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
 
void * GPU_texture_read (GPUTexture *tex_, eGPUDataFormat data_format, int miplvl)
 
void GPU_texture_clear (GPUTexture *tex, eGPUDataFormat data_format, const void *data)
 
void GPU_texture_update (GPUTexture *tex, eGPUDataFormat data_format, const void *data)
 
void GPU_unpack_row_length_set (uint len)
 
void GPU_texture_bind_ex (GPUTexture *tex_, eGPUSamplerState state, int unit, const bool UNUSED(set_number))
 
void GPU_texture_bind (GPUTexture *tex_, int unit)
 
void GPU_texture_unbind (GPUTexture *tex_)
 
void GPU_texture_unbind_all (void)
 
void GPU_texture_image_bind (GPUTexture *tex, int unit)
 
void GPU_texture_image_unbind (GPUTexture *tex)
 
void GPU_texture_image_unbind_all (void)
 
void GPU_texture_generate_mipmap (GPUTexture *tex)
 
void GPU_texture_copy (GPUTexture *dst_, GPUTexture *src_)
 
void GPU_texture_compare_mode (GPUTexture *tex_, bool use_compare)
 
void GPU_texture_filter_mode (GPUTexture *tex_, bool use_filter)
 
void GPU_texture_mipmap_mode (GPUTexture *tex_, bool use_mipmap, bool use_filter)
 
void GPU_texture_anisotropic_filter (GPUTexture *tex_, bool use_aniso)
 
void GPU_texture_wrap_mode (GPUTexture *tex_, bool use_repeat, bool use_clamp)
 
void GPU_texture_swizzle_set (GPUTexture *tex, const char swizzle[4])
 
void GPU_texture_free (GPUTexture *tex_)
 
void GPU_texture_ref (GPUTexture *tex)
 
int GPU_texture_width (const GPUTexture *tex)
 
int GPU_texture_height (const GPUTexture *tex)
 
int GPU_texture_orig_width (const GPUTexture *tex)
 
int GPU_texture_orig_height (const GPUTexture *tex)
 
void GPU_texture_orig_size_set (GPUTexture *tex_, int w, int h)
 
eGPUTextureFormat GPU_texture_format (const GPUTexture *tex)
 
bool GPU_texture_depth (const GPUTexture *tex)
 
bool GPU_texture_stencil (const GPUTexture *tex)
 
bool GPU_texture_integer (const GPUTexture *tex)
 
bool GPU_texture_cube (const GPUTexture *tex)
 
bool GPU_texture_array (const GPUTexture *tex)
 
int GPU_texture_opengl_bindcode (const GPUTexture *tex)
 
void GPU_texture_get_mipmap_size (GPUTexture *tex, int lvl, int *r_size)
 
GPU Sampler Objects

Simple wrapper around opengl sampler objects. Override texture sampler state for one sampler unit only.

void GPU_samplers_update (void)
 
GPU texture utilities
size_t GPU_texture_component_len (eGPUTextureFormat tex_format)
 
size_t GPU_texture_dataformat_size (eGPUDataFormat data_format)
 

Function Documentation

◆ GPU_samplers_update()

void GPU_samplers_update ( void  )

◆ GPU_texture_anisotropic_filter()

void GPU_texture_anisotropic_filter ( GPUTexture tex_,
bool  use_aniso 
)

◆ GPU_texture_array()

bool GPU_texture_array ( const GPUTexture tex)

Definition at line 579 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_ARRAY, and tex.

Referenced by blender::gpu::FrameBuffer::attachment_set().

◆ GPU_texture_bind()

void GPU_texture_bind ( GPUTexture tex_,
int  unit 
)

◆ GPU_texture_bind_ex()

void GPU_texture_bind_ex ( GPUTexture tex_,
eGPUSamplerState  state,
int  unit,
const bool   UNUSEDset_number 
)

◆ GPU_texture_clear()

void GPU_texture_clear ( GPUTexture tex,
eGPUDataFormat  data_format,
const void *  data 
)

Fills the whole texture with the same data for all pixels.

Warning
Only work for 2D texture for now.
Only clears the mip 0 of the texture.
Parameters
data_formatdata format of the pixel data.
data1 pixel worth of data to fill the texture with.

Definition at line 384 of file gpu_texture.cc.

References BLI_assert, clear(), data, and tex.

Referenced by pygpu_texture_clear().

◆ GPU_texture_compare_mode()

void GPU_texture_compare_mode ( GPUTexture tex_,
bool  use_compare 
)

◆ GPU_texture_component_len()

size_t GPU_texture_component_len ( eGPUTextureFormat  tex_format)

Definition at line 616 of file gpu_texture.cc.

References blender::gpu::to_component_len().

Referenced by pygpu_texture__tp_new(), and pygpu_texture_read().

◆ GPU_texture_copy()

void GPU_texture_copy ( GPUTexture dst_,
GPUTexture src_ 
)

◆ gpu_texture_create()

static GPUTexture* gpu_texture_create ( const char *  name,
const int  w,
const int  h,
const int  d,
const eGPUTextureType  type,
int   UNUSEDmips,
eGPUTextureFormat  tex_format,
eGPUDataFormat  data_format,
const void *  pixels 
)
inlinestatic

◆ GPU_texture_create_1d()

GPUTexture* GPU_texture_create_1d ( const char *  name,
int  w,
int  mip_len,
eGPUTextureFormat  format,
const float data 
)
Note
data is expected to be float. If the format is not compatible with float data or if the data is not in float format, use GPU_texture_update to upload the data with the right data format. mips is the number of mip level to allocate. It must be >= 1.

Definition at line 237 of file gpu_texture.cc.

References data, GPU_DATA_FLOAT, blender::gpu::GPU_TEXTURE_1D, gpu_texture_create(), and w().

Referenced by createGPUCurveMapping(), DRW_create_weight_colorramp_texture(), DRW_globals_update(), DRW_texture_create_1d(), GPU_material_sss_profile_get(), pygpu_texture__tp_new(), and workbench_volume_engine_init().

◆ GPU_texture_create_1d_array()

GPUTexture* GPU_texture_create_1d_array ( const char *  name,
int  w,
int  h,
int  mips,
eGPUTextureFormat  format,
const float data 
)

◆ GPU_texture_create_2d()

GPUTexture* GPU_texture_create_2d ( const char *  name,
int  w,
int  h,
int  mips,
eGPUTextureFormat  format,
const float data 
)

◆ GPU_texture_create_2d_array()

GPUTexture* GPU_texture_create_2d_array ( const char *  name,
int  w,
int  h,
int  d,
int  mips,
eGPUTextureFormat  format,
const float data 
)

◆ GPU_texture_create_3d()

GPUTexture* GPU_texture_create_3d ( const char *  name,
int  w,
int  h,
int  d,
int  mips,
eGPUTextureFormat  texture_format,
eGPUDataFormat  data_format,
const void *  data 
)

◆ GPU_texture_create_compressed_2d()

GPUTexture* GPU_texture_create_compressed_2d ( const char *  name,
int  w,
int  h,
int  miplen,
eGPUTextureFormat  format,
const void *  data 
)

◆ GPU_texture_create_cube()

GPUTexture* GPU_texture_create_cube ( const char *  name,
int  w,
int  mips,
eGPUTextureFormat  format,
const float data 
)

◆ GPU_texture_create_cube_array()

GPUTexture* GPU_texture_create_cube_array ( const char *  name,
int  w,
int  d,
int  mips,
eGPUTextureFormat  format,
const float data 
)

◆ GPU_texture_create_error()

GPUTexture* GPU_texture_create_error ( int  dimension,
bool  is_array 
)

◆ GPU_texture_create_from_vertbuf()

GPUTexture* GPU_texture_create_from_vertbuf ( const char *  name,
GPUVertBuf vert 
)

◆ GPU_texture_cube()

bool GPU_texture_cube ( const GPUTexture tex)

Definition at line 574 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_CUBE, and tex.

Referenced by blender::gpu::FrameBuffer::attachment_set().

◆ GPU_texture_dataformat_size()

size_t GPU_texture_dataformat_size ( eGPUDataFormat  data_format)

Definition at line 621 of file gpu_texture.cc.

References blender::gpu::to_bytesize().

Referenced by pygpu_buffer__sq_item(), and pygpu_buffer_calc_size().

◆ GPU_texture_depth()

bool GPU_texture_depth ( const GPUTexture tex)

◆ GPU_texture_filter_mode()

void GPU_texture_filter_mode ( GPUTexture tex_,
bool  use_filter 
)

◆ GPU_texture_format()

eGPUTextureFormat GPU_texture_format ( const GPUTexture tex)

◆ GPU_texture_free()

void GPU_texture_free ( GPUTexture tex_)

◆ GPU_texture_generate_mipmap()

void GPU_texture_generate_mipmap ( GPUTexture tex)

◆ GPU_texture_get_mipmap_size()

void GPU_texture_get_mipmap_size ( GPUTexture tex,
int  lvl,
int *  r_size 
)

◆ GPU_texture_height()

int GPU_texture_height ( const GPUTexture tex)

◆ GPU_texture_image_bind()

void GPU_texture_image_bind ( GPUTexture tex,
int  unit 
)

◆ GPU_texture_image_unbind()

void GPU_texture_image_unbind ( GPUTexture tex)

◆ GPU_texture_image_unbind_all()

void GPU_texture_image_unbind_all ( void  )

◆ GPU_texture_integer()

bool GPU_texture_integer ( const GPUTexture tex)

Definition at line 569 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_INTEGER, and tex.

Referenced by GPU_viewport_texture_pool_query().

◆ GPU_texture_memory_usage_get()

uint GPU_texture_memory_usage_get ( void  )

Definition at line 187 of file gpu_texture.cc.

Referenced by DRW_stats_draw().

◆ GPU_texture_mipmap_mode()

void GPU_texture_mipmap_mode ( GPUTexture tex_,
bool  use_mipmap,
bool  use_filter 
)

◆ GPU_texture_opengl_bindcode()

int GPU_texture_opengl_bindcode ( const GPUTexture tex)

Definition at line 585 of file gpu_texture.cc.

References tex.

Referenced by pygpu_offscreen_color_texture_get().

◆ GPU_texture_orig_height()

int GPU_texture_orig_height ( const GPUTexture tex)

Definition at line 542 of file gpu_texture.cc.

References tex.

Referenced by OVERLAY_image_empty_cache_populate().

◆ GPU_texture_orig_size_set()

void GPU_texture_orig_size_set ( GPUTexture tex_,
int  w,
int  h 
)

Definition at line 547 of file gpu_texture.cc.

References tex, and w().

Referenced by image_get_gpu_texture().

◆ GPU_texture_orig_width()

int GPU_texture_orig_width ( const GPUTexture tex)

Definition at line 537 of file gpu_texture.cc.

References tex.

Referenced by OVERLAY_image_empty_cache_populate().

◆ GPU_texture_read()

void* GPU_texture_read ( GPUTexture tex_,
eGPUDataFormat  data_format,
int  miplvl 
)

◆ GPU_texture_ref()

void GPU_texture_ref ( GPUTexture tex)

Definition at line 522 of file gpu_texture.cc.

References tex.

Referenced by drw_shgroup_material_texture().

◆ GPU_texture_stencil()

bool GPU_texture_stencil ( const GPUTexture tex)

◆ GPU_texture_swizzle_set()

void GPU_texture_swizzle_set ( GPUTexture tex,
const char  swizzle[4] 
)

Definition at line 503 of file gpu_texture.cc.

References tex.

Referenced by load_tex(), load_tex_cursor(), radial_control_set_tex(), and volume_grid_cache_get().

◆ GPU_texture_unbind()

void GPU_texture_unbind ( GPUTexture tex_)

◆ GPU_texture_unbind_all()

void GPU_texture_unbind_all ( void  )

◆ GPU_texture_update()

void GPU_texture_update ( GPUTexture tex,
eGPUDataFormat  data_format,
const void *  data 
)

◆ GPU_texture_update_mipmap()

void GPU_texture_update_mipmap ( GPUTexture tex_,
int  miplvl,
eGPUDataFormat  data_format,
const void *  pixels 
)

Definition at line 345 of file gpu_texture.cc.

References tex.

Referenced by eevee_lightcache_static_load(), and UI_icons_reload_internal_textures().

◆ GPU_texture_update_sub()

void GPU_texture_update_sub ( GPUTexture tex,
eGPUDataFormat  data_format,
const void *  pixels,
int  offset_x,
int  offset_y,
int  offset_z,
int  width,
int  height,
int  depth 
)

◆ GPU_texture_width()

int GPU_texture_width ( const GPUTexture tex)

◆ GPU_texture_wrap_mode()

void GPU_texture_wrap_mode ( GPUTexture tex_,
bool  use_repeat,
bool  use_clamp 
)

◆ GPU_unpack_row_length_set()

void GPU_unpack_row_length_set ( uint  len)