Blender  V2.93
Classes | Macros | Typedefs | Functions
image_gpu.c File Reference
#include "MEM_guardedalloc.h"
#include "BLI_bitmap.h"
#include "BLI_boxpack_2d.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "DNA_image_types.h"
#include "DNA_userdef_types.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "GPU_capabilities.h"
#include "GPU_state.h"
#include "GPU_texture.h"
#include "PIL_time.h"

Go to the source code of this file.

Classes

struct  ImagePartialRefresh
 
struct  PackTile
 

Macros

#define IMA_PARTIAL_REFRESH_TILE_SIZE   256
 
#define GPU_FLAGS_TO_CHECK   (IMA_GPU_MAX_RESOLUTION)
 

Typedefs

typedef struct ImagePartialRefresh ImagePartialRefresh
 

Functions

bool BKE_image_has_gpu_texture_premultiplied_alpha (Image *image, ImBuf *ibuf)
 
Deletion
static void image_free_gpu (Image *ima, const bool immediate)
 
void BKE_image_free_gputextures (Image *ima)
 
void BKE_image_free_all_gputextures (Main *bmain)
 
void BKE_image_free_anim_gputextures (Main *bmain)
 
void BKE_image_free_old_gputextures (Main *bmain)
 
Paint Update
static void image_update_gputexture_ex (Image *ima, ImageTile *tile, ImBuf *ibuf, int x, int y, int w, int h)
 
static ImBufupdate_do_scale (uchar *rect, float *rect_float, int *x, int *y, int *w, int *h, int limit_w, int limit_h, int full_w, int full_h)
 
static void gpu_texture_update_scaled (GPUTexture *tex, uchar *rect, float *rect_float, int full_w, int full_h, int x, int y, int layer, const int *tile_offset, const int *tile_size, int w, int h)
 
static void gpu_texture_update_unscaled (GPUTexture *tex, uchar *rect, float *rect_float, int x, int y, int layer, const int tile_offset[2], int w, int h, int tex_stride, int tex_offset)
 
static void gpu_texture_update_from_ibuf (GPUTexture *tex, Image *ima, ImBuf *ibuf, ImageTile *tile, int x, int y, int w, int h)
 
void BKE_image_update_gputexture (Image *ima, ImageUser *iuser, int x, int y, int w, int h)
 
void BKE_image_update_gputexture_delayed (struct Image *ima, struct ImBuf *ibuf, int x, int y, int w, int h)
 
void BKE_image_paint_set_mipmap (Main *bmain, bool mipmap)
 
Regular gpu texture
static GPUTexture ** get_image_gpu_texture_ptr (Image *ima, eGPUTextureTarget textarget, const int multiview_eye)
 
static GPUTextureimage_gpu_texture_error_create (eGPUTextureTarget textarget)
 
static GPUTextureimage_get_gpu_texture (Image *ima, ImageUser *iuser, ImBuf *ibuf, eGPUTextureTarget textarget)
 
GPUTextureBKE_image_get_gpu_texture (Image *image, ImageUser *iuser, ImBuf *ibuf)
 
GPUTextureBKE_image_get_gpu_tiles (Image *image, ImageUser *iuser, ImBuf *ibuf)
 
GPUTextureBKE_image_get_gpu_tilemap (Image *image, ImageUser *iuser, ImBuf *ibuf)
 

UDIM gpu texture

typedef struct PackTile PackTile
 
static bool is_over_resolution_limit (int w, int h, bool limit_gl_texture_size)
 
static int smaller_power_of_2_limit (int num, bool limit_gl_texture_size)
 
static GPUTexturegpu_texture_create_tile_mapping (Image *ima, const int multiview_eye)
 
static int compare_packtile (const void *a, const void *b)
 
static GPUTexturegpu_texture_create_tile_array (Image *ima, ImBuf *main_ibuf)
 

Delayed GPU texture free

Image datablocks can be deleted by any thread, but there may not be any active OpenGL context. In that case we push them into a queue and free the buffers later.

static LinkNodegpu_texture_free_queue = NULL
 
static ThreadMutex gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER
 
static void gpu_free_unused_buffers (void)
 
void BKE_image_free_unused_gpu_textures ()
 

Macro Definition Documentation

◆ GPU_FLAGS_TO_CHECK

#define GPU_FLAGS_TO_CHECK   (IMA_GPU_MAX_RESOLUTION)

◆ IMA_PARTIAL_REFRESH_TILE_SIZE

#define IMA_PARTIAL_REFRESH_TILE_SIZE   256

Definition at line 56 of file image_gpu.c.

Typedef Documentation

◆ ImagePartialRefresh

◆ PackTile

typedef struct PackTile PackTile

Function Documentation

◆ BKE_image_free_all_gputextures()

void BKE_image_free_all_gputextures ( Main bmain)

◆ BKE_image_free_anim_gputextures()

void BKE_image_free_anim_gputextures ( Main bmain)

◆ BKE_image_free_gputextures()

void BKE_image_free_gputextures ( Image ima)

◆ BKE_image_free_old_gputextures()

void BKE_image_free_old_gputextures ( Main bmain)

◆ BKE_image_free_unused_gpu_textures()

void BKE_image_free_unused_gpu_textures ( void  )

Definition at line 482 of file image_gpu.c.

References BLI_thread_is_main(), and gpu_free_unused_buffers().

Referenced by wm_draw_update(), and WM_exit_ex().

◆ BKE_image_get_gpu_texture()

GPUTexture* BKE_image_get_gpu_texture ( Image image,
ImageUser iuser,
ImBuf ibuf 
)

◆ BKE_image_get_gpu_tilemap()

GPUTexture* BKE_image_get_gpu_tilemap ( Image image,
ImageUser iuser,
ImBuf ibuf 
)

◆ BKE_image_get_gpu_tiles()

GPUTexture* BKE_image_get_gpu_tiles ( Image image,
ImageUser iuser,
ImBuf ibuf 
)

◆ BKE_image_has_gpu_texture_premultiplied_alpha()

bool BKE_image_has_gpu_texture_premultiplied_alpha ( Image image,
ImBuf ibuf 
)

◆ BKE_image_paint_set_mipmap()

void BKE_image_paint_set_mipmap ( Main bmain,
bool  mipmap 
)

◆ BKE_image_update_gputexture()

void BKE_image_update_gputexture ( Image ima,
ImageUser iuser,
int  x,
int  y,
int  w,
int  h 
)

◆ BKE_image_update_gputexture_delayed()

void BKE_image_update_gputexture_delayed ( struct Image ima,
struct ImBuf ibuf,
int  x,
int  y,
int  w,
int  h 
)

◆ compare_packtile()

static int compare_packtile ( const void *  a,
const void *  b 
)
static

Definition at line 146 of file image_gpu.c.

References Freestyle::a, and PackTile::pack_score.

Referenced by gpu_texture_create_tile_array().

◆ get_image_gpu_texture_ptr()

static GPUTexture** get_image_gpu_texture_ptr ( Image ima,
eGPUTextureTarget  textarget,
const int  multiview_eye 
)
static

Definition at line 270 of file image_gpu.c.

References BLI_assert, Image::gputexture, NULL, and TEXTARGET_COUNT.

Referenced by image_get_gpu_texture().

◆ gpu_free_unused_buffers()

static void gpu_free_unused_buffers ( void  )
static

◆ gpu_texture_create_tile_array()

static GPUTexture* gpu_texture_create_tile_array ( Image ima,
ImBuf main_ibuf 
)
static

◆ gpu_texture_create_tile_mapping()

static GPUTexture* gpu_texture_create_tile_mapping ( Image ima,
const int  multiview_eye 
)
static

◆ gpu_texture_update_from_ibuf()

static void gpu_texture_update_from_ibuf ( GPUTexture tex,
Image ima,
ImBuf ibuf,
ImageTile tile,
int  x,
int  y,
int  w,
int  h 
)
static

◆ gpu_texture_update_scaled()

static void gpu_texture_update_scaled ( GPUTexture tex,
uchar rect,
float rect_float,
int  full_w,
int  full_h,
int  x,
int  y,
int  layer,
const int *  tile_offset,
const int *  tile_size,
int  w,
int  h 
)
static

◆ gpu_texture_update_unscaled()

static void gpu_texture_update_unscaled ( GPUTexture tex,
uchar rect,
float rect_float,
int  x,
int  y,
int  layer,
const int  tile_offset[2],
int  w,
int  h,
int  tex_stride,
int  tex_offset 
)
static

◆ image_free_gpu()

static void image_free_gpu ( Image ima,
const bool  immediate 
)
static

◆ image_get_gpu_texture()

static GPUTexture* image_get_gpu_texture ( Image ima,
ImageUser iuser,
ImBuf ibuf,
eGPUTextureTarget  textarget 
)
static

◆ image_gpu_texture_error_create()

static GPUTexture* image_gpu_texture_error_create ( eGPUTextureTarget  textarget)
static

◆ image_update_gputexture_ex()

static void image_update_gputexture_ex ( Image ima,
ImageTile tile,
ImBuf ibuf,
int  x,
int  y,
int  w,
int  h 
)
static

◆ is_over_resolution_limit()

static bool is_over_resolution_limit ( int  w,
int  h,
bool  limit_gl_texture_size 
)
static

Definition at line 89 of file image_gpu.c.

References GPU_texture_size_with_limit(), and w().

Referenced by gpu_texture_create_tile_array().

◆ smaller_power_of_2_limit()

static int smaller_power_of_2_limit ( int  num,
bool  limit_gl_texture_size 
)
static

Definition at line 95 of file image_gpu.c.

References GPU_texture_size_with_limit(), and power_of_2_min_i().

Referenced by gpu_texture_create_tile_array().

◆ update_do_scale()

static ImBuf* update_do_scale ( uchar rect,
float rect_float,
int *  x,
int *  y,
int *  w,
int *  h,
int  limit_w,
int  limit_h,
int  full_w,
int  full_h 
)
static

Definition at line 584 of file image_gpu.c.

References ceil(), float(), IMB_allocFromBuffer(), IMB_scaleImBuf(), w(), x, and y.

Referenced by gpu_texture_update_scaled().

Variable Documentation

◆ gpu_texture_free_queue

LinkNode* gpu_texture_free_queue = NULL
static

Definition at line 463 of file image_gpu.c.

Referenced by gpu_free_unused_buffers(), and image_free_gpu().

◆ gpu_texture_queue_mutex

ThreadMutex gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER
static

Definition at line 464 of file image_gpu.c.

Referenced by gpu_free_unused_buffers(), and image_free_gpu().