|
Blender
V2.93
|
#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 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 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 GPUTexture * | image_gpu_texture_error_create (eGPUTextureTarget textarget) |
| static GPUTexture * | image_get_gpu_texture (Image *ima, ImageUser *iuser, ImBuf *ibuf, eGPUTextureTarget textarget) |
| GPUTexture * | BKE_image_get_gpu_texture (Image *image, ImageUser *iuser, ImBuf *ibuf) |
| GPUTexture * | BKE_image_get_gpu_tiles (Image *image, ImageUser *iuser, ImBuf *ibuf) |
| GPUTexture * | BKE_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 GPUTexture * | gpu_texture_create_tile_mapping (Image *ima, const int multiview_eye) |
| static int | compare_packtile (const void *a, const void *b) |
| static GPUTexture * | gpu_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 LinkNode * | gpu_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 () |
| #define GPU_FLAGS_TO_CHECK (IMA_GPU_MAX_RESOLUTION) |
| #define IMA_PARTIAL_REFRESH_TILE_SIZE 256 |
Definition at line 56 of file image_gpu.c.
| typedef struct ImagePartialRefresh ImagePartialRefresh |
| void BKE_image_free_all_gputextures | ( | Main * | bmain | ) |
Definition at line 522 of file image_gpu.c.
References BKE_image_free_gputextures(), Main::images, and LISTBASE_FOREACH.
Referenced by ED_object_texture_paint_mode_enter_ex(), and ED_object_texture_paint_mode_exit_ex().
| void BKE_image_free_anim_gputextures | ( | Main * | bmain | ) |
Definition at line 532 of file image_gpu.c.
References BKE_image_free_gputextures(), BKE_image_is_animated(), Main::images, and LISTBASE_FOREACH.
Referenced by ED_view3d_draw_offscreen().
| void BKE_image_free_gputextures | ( | Image * | ima | ) |
Definition at line 517 of file image_gpu.c.
References BLI_thread_is_main(), and image_free_gpu().
Referenced by bake_targets_refresh(), BKE_image_free_all_gputextures(), BKE_image_free_anim_gputextures(), BKE_image_free_buffers_ex(), BKE_image_free_old_gputextures(), BKE_image_paint_set_mipmap(), BKE_image_update_gputexture(), image_flip_exec(), image_invert_exec(), image_scale_exec(), multiresbake_freejob(), paint_2d_redraw(), ptile_restore_runtime_list(), texture_paint_camera_project_exec(), and uhandle_restore_list().
| void BKE_image_free_old_gputextures | ( | Main * | bmain | ) |
Definition at line 543 of file image_gpu.c.
References BKE_image_free_buffers, BKE_image_free_gputextures(), BKE_image_has_opengl_texture(), G, IMA_NOCOLLECT, Main::images, LISTBASE_FOREACH, and PIL_check_seconds_timer().
Referenced by view3d_main_region_draw().
| 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().
| GPUTexture* BKE_image_get_gpu_texture | ( | Image * | image, |
| ImageUser * | iuser, | ||
| ImBuf * | ibuf | ||
| ) |
Definition at line 439 of file image_gpu.c.
References image_get_gpu_texture(), and TEXTARGET_2D.
Referenced by DRW_shgroup_add_material_resources(), gpencil_image_texture_get(), image_camera_background_texture_get(), OVERLAY_edit_uv_cache_init(), OVERLAY_image_empty_cache_populate(), OVERLAY_paint_cache_init(), space_image_gpu_texture_get(), space_node_gpu_texture_get(), and workbench_image_setup_ex().
| GPUTexture* BKE_image_get_gpu_tilemap | ( | Image * | image, |
| ImageUser * | iuser, | ||
| ImBuf * | ibuf | ||
| ) |
Definition at line 449 of file image_gpu.c.
References image_get_gpu_texture(), and TEXTARGET_TILE_MAPPING.
Referenced by DRW_shgroup_add_material_resources(), space_image_gpu_texture_get(), and workbench_image_setup_ex().
| GPUTexture* BKE_image_get_gpu_tiles | ( | Image * | image, |
| ImageUser * | iuser, | ||
| ImBuf * | ibuf | ||
| ) |
Definition at line 444 of file image_gpu.c.
References image_get_gpu_texture(), and TEXTARGET_2D_ARRAY.
Referenced by DRW_shgroup_add_material_resources(), space_image_gpu_texture_get(), and workbench_image_setup_ex().
Definition at line 64 of file image_gpu.c.
References Image::alpha_mode, ELEM, IMA_ALPHA_PREMUL, IMA_ALPHA_STRAIGHT, IMA_TYPE_COMPOSITE, IMA_TYPE_R_RESULT, IMA_TYPE_UV_TEST, NULL, ImBuf::rect_float, and Image::type.
Referenced by gpu_texture_create_tile_array(), gpu_texture_update_from_ibuf(), image_cache_image(), and image_get_gpu_texture().
| void BKE_image_paint_set_mipmap | ( | Main * | bmain, |
| bool | mipmap | ||
| ) |
Definition at line 914 of file image_gpu.c.
References Freestyle::a, BKE_image_free_gputextures(), BKE_image_has_opengl_texture(), ELEM, GPU_texture_mipmap_mode(), IMA_GPU_MIPMAP_COMPLETE, Main::images, LISTBASE_FOREACH, NULL, tex, TEXTARGET_2D, TEXTARGET_2D_ARRAY, and TEXTARGET_COUNT.
Referenced by ED_object_texture_paint_mode_enter_ex(), and ED_object_texture_paint_mode_exit_ex().
Definition at line 821 of file image_gpu.c.
References BKE_image_acquire_ibuf(), BKE_image_free_gputextures(), BKE_image_get_tile_from_iuser, BKE_image_release_ibuf(), image_update_gputexture_ex(), NULL, w(), x, and y.
Referenced by imapaint_image_update().
| void BKE_image_update_gputexture_delayed | ( | struct Image * | ima, |
| struct ImBuf * | ibuf, | ||
| int | x, | ||
| int | y, | ||
| int | w, | ||
| int | h | ||
| ) |
Definition at line 838 of file image_gpu.c.
References blender::compositor::area(), BLI_addtail(), BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_NEW_ALLOCA, BLI_BITMAP_SIZE, BLI_BITMAP_TEST_BOOL, BLI_freelistN(), Image::gpu_refresh_areas, Image::gpuflag, IMA_GPU_PARTIAL_REFRESH, IMA_GPU_REFRESH, IMA_PARTIAL_REFRESH_TILE_SIZE, LISTBASE_FOREACH, MEM_freeN, MEM_mallocN, NULL, w(), x, ImBuf::x, y, and ImBuf::y.
Referenced by image_rect_update().
|
static |
Definition at line 146 of file image_gpu.c.
References Freestyle::a, and PackTile::pack_score.
Referenced by gpu_texture_create_tile_array().
|
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().
|
static |
Definition at line 466 of file image_gpu.c.
References BLI_linklist_pop(), BLI_mutex_lock(), BLI_mutex_unlock(), GPU_texture_free(), gpu_texture_free_queue, gpu_texture_queue_mutex, NULL, and tex.
Referenced by BKE_image_free_unused_gpu_textures(), and image_get_gpu_texture().
|
static |
Definition at line 154 of file image_gpu.c.
References BKE_image_acquire_ibuf(), BKE_image_has_gpu_texture_premultiplied_alpha(), BKE_image_release_ibuf(), BKE_imageuser_default(), BLI_addtail(), BLI_assert, BLI_box_pack_2d_fixedarea(), BLI_freelistN(), BLI_listbase_sort(), PackTile::boxpack, compare_packtile(), ListBase::first, Image::flag, GPU_mipmap_enabled(), GPU_texture_generate_mipmap(), GPU_texture_mipmap_mode(), Image::gpuflag, FixedSizeBoxPack::h, Image::id, IMA_GPU_MAX_RESOLUTION, IMA_GPU_MIPMAP_COMPLETE, IMA_HIGH_BITDEPTH, IMB_touch_gpu_texture(), IMB_update_gpu_texture_sub(), is_over_resolution_limit(), LISTBASE_FOREACH, max_ff(), max_ii(), MEM_callocN, min_ff(), ID::name, NULL, PackTile::pack_score, ImageTile::runtime, smaller_power_of_2_limit(), tex, PackTile::tile, ImageUser::tile, ImageTile_Runtime::tilearray_layer, ImageTile_Runtime::tilearray_offset, ImageTile_Runtime::tilearray_size, Image::tiles, UNPACK2, w(), FixedSizeBoxPack::w, ImBuf::x, and ImBuf::y.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 100 of file image_gpu.c.
References data, GPU_RGBA32F, GPU_texture_create_1d_array(), GPU_texture_height(), GPU_texture_mipmap_mode(), GPU_texture_width(), Image::gputexture, Image::id, ListBase::last, LISTBASE_FOREACH, MEM_callocN, MEM_freeN, ID::name, NULL, tex, TEXTARGET_2D_ARRAY, ImageTile::tile_number, Image::tiles, and width.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 691 of file image_gpu.c.
References BKE_image_has_gpu_texture_premultiplied_alpha(), ImBuf::channels, GPU_mipmap_enabled(), GPU_texture_generate_mipmap(), GPU_texture_height(), GPU_texture_unbind(), gpu_texture_update_scaled(), gpu_texture_update_unscaled(), GPU_texture_width(), Image::gpuflag, IMA_GPU_MIPMAP_COMPLETE, IMB_colormanagement_imbuf_to_byte_texture(), IMB_colormanagement_imbuf_to_float_texture(), IMB_colormanagement_space_is_data(), IMB_colormanagement_space_is_scene_linear(), max_ii(), MEM_freeN, MEM_mallocN, min_ii(), NULL, padding(), ImBuf::rect, ImBuf::rect_colorspace, ImBuf::rect_float, ImageTile::runtime, scaled(), tex, ImageTile_Runtime::tilearray_layer, ImageTile_Runtime::tilearray_offset, ImageTile_Runtime::tilearray_size, w(), x, ImBuf::x, y, and ImBuf::y.
Referenced by image_update_gputexture_ex().
|
static |
Definition at line 623 of file image_gpu.c.
References data, GPU_DATA_FLOAT, GPU_DATA_UBYTE, GPU_texture_height(), GPU_texture_update_sub(), GPU_texture_width(), IMB_freeImBuf(), ImBuf::rect, ImBuf::rect_float, tex, update_do_scale(), w(), x, and y.
Referenced by gpu_texture_update_from_ibuf().
|
static |
Definition at line 661 of file image_gpu.c.
References data, GPU_DATA_FLOAT, GPU_DATA_UBYTE, GPU_texture_update_sub(), GPU_unpack_row_length_set(), tex, w(), x, and y.
Referenced by gpu_texture_update_from_ibuf().
|
static |
Definition at line 495 of file image_gpu.c.
References BLI_linklist_prepend(), BLI_mutex_lock(), BLI_mutex_unlock(), GPU_texture_free(), gpu_texture_free_queue, gpu_texture_queue_mutex, Image::gpuflag, Image::gputexture, IMA_GPU_MIPMAP_COMPLETE, NULL, and TEXTARGET_COUNT.
Referenced by BKE_image_free_gputextures(), and image_get_gpu_texture().
|
static |
Definition at line 298 of file image_gpu.c.
References BKE_image_acquire_ibuf(), BKE_image_get_tile, BKE_image_has_gpu_texture_premultiplied_alpha(), BKE_image_release_ibuf(), BKE_image_tag_time(), BLI_assert, BLI_freelistN(), BLI_pophead(), ImageUser::flag, Image::flag, get_image_gpu_texture_ptr(), GPU_FLAGS_TO_CHECK, gpu_free_unused_buffers(), Image::gpu_layer, GPU_mipmap_enabled(), Image::gpu_pass, Image::gpu_refresh_areas, gpu_texture_create_tile_array(), gpu_texture_create_tile_mapping(), GPU_texture_generate_mipmap(), GPU_texture_mipmap_mode(), GPU_texture_orig_size_set(), GPU_texture_wrap_mode(), Image::gpu_view, Image::gpuflag, Image::id, IMA_GPU_MAX_RESOLUTION, IMA_GPU_MIPMAP_COMPLETE, IMA_GPU_PARTIAL_REFRESH, IMA_GPU_REFRESH, IMA_HIGH_BITDEPTH, IMA_PARTIAL_REFRESH_TILE_SIZE, IMA_SHOW_MAX_RESOLUTION, image_free_gpu(), image_gpu_texture_error_create(), image_update_gputexture_ex(), IMB_create_gpu_texture(), ImageUser::layer, MEM_freeN, MIN2, ImageUser::multi_index, ImageUser::multiview_eye, ID::name, NULL, ImageTile::ok, ImageUser::pass, tex, TEXTARGET_2D_ARRAY, TEXTARGET_TILE_MAPPING, ImagePartialRefresh::tile_x, ImagePartialRefresh::tile_y, ImBuf::x, and ImBuf::y.
Referenced by BKE_image_get_gpu_texture(), BKE_image_get_gpu_tilemap(), and BKE_image_get_gpu_tiles().
|
static |
Definition at line 284 of file image_gpu.c.
References GPU_texture_create_error(), TEXTARGET_2D, TEXTARGET_2D_ARRAY, and TEXTARGET_TILE_MAPPING.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 803 of file image_gpu.c.
References ListBase::first, gpu_texture_update_from_ibuf(), Image::gputexture, NULL, tex, TEXTARGET_2D, TEXTARGET_2D_ARRAY, Image::tiles, w(), x, and y.
Referenced by BKE_image_update_gputexture(), and image_get_gpu_texture().
|
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().
|
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().
|
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().
Definition at line 463 of file image_gpu.c.
Referenced by gpu_free_unused_buffers(), and image_free_gpu().
|
static |
Definition at line 464 of file image_gpu.c.
Referenced by gpu_free_unused_buffers(), and image_free_gpu().