Blender
V3.3
|
#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_image_partial_update.hh"
#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 | PackTile |
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 = nullptr |
static ThreadMutex | gpu_texture_queue_mutex = BLI_MUTEX_INITIALIZER |
static void | gpu_free_unused_buffers () |
void | BKE_image_free_unused_gpu_textures () |
Definition at line 521 of file image_gpu.cc.
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().
Same as above but only free animated images.
Definition at line 530 of file image_gpu.cc.
References BKE_image_free_gputextures(), BKE_image_is_animated(), Main::images, and LISTBASE_FOREACH.
Referenced by ED_view3d_draw_offscreen().
Definition at line 516 of file image_gpu.cc.
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(), paint_2d_redraw(), ptile_restore_runtime_map(), and texture_paint_camera_project_exec().
Definition at line 541 of file image_gpu.cc.
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().
Delayed free of OpenGL buffers by main thread.
Definition at line 481 of file image_gpu.cc.
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 | ( | struct Image * | image, |
struct ImageUser * | iuser, | ||
struct ImBuf * | ibuf | ||
) |
Get the GPUTexture for a given Image
.
iuser
and ibuf
are mutual exclusive parameters. The caller can pass the ibuf
when already available. It is also required when requesting the GPUTexture for a render result.
Definition at line 438 of file image_gpu.cc.
References image(), image_get_gpu_texture(), and TEXTARGET_2D.
Referenced by DRW_shgroup_add_material_resources(), blender::draw::image_engine::SpaceNodeAccessor::get_gpu_textures(), blender::draw::image_engine::SpaceImageAccessor::get_gpu_textures(), gpencil_image_texture_get(), image_camera_background_texture_get(), OVERLAY_edit_uv_cache_init(), OVERLAY_image_empty_cache_populate(), OVERLAY_paint_cache_init(), and workbench_image_setup_ex().
GPUTexture* BKE_image_get_gpu_tilemap | ( | Image * | image, |
ImageUser * | iuser, | ||
ImBuf * | ibuf | ||
) |
Definition at line 448 of file image_gpu.cc.
References image(), image_get_gpu_texture(), and TEXTARGET_TILE_MAPPING.
Referenced by DRW_shgroup_add_material_resources(), blender::draw::image_engine::SpaceImageAccessor::get_gpu_textures(), and workbench_image_setup_ex().
GPUTexture* BKE_image_get_gpu_tiles | ( | Image * | image, |
ImageUser * | iuser, | ||
ImBuf * | ibuf | ||
) |
Definition at line 443 of file image_gpu.cc.
References image(), image_get_gpu_texture(), and TEXTARGET_2D_ARRAY.
Referenced by DRW_shgroup_add_material_resources(), blender::draw::image_engine::SpaceImageAccessor::get_gpu_textures(), and workbench_image_setup_ex().
Is the alpha of the GPUTexture
for a given image/ibuf premultiplied.
Definition at line 44 of file image_gpu.cc.
References ELEM, IMA_ALPHA_PREMUL, IMA_ALPHA_STRAIGHT, IMA_TYPE_COMPOSITE, IMA_TYPE_R_RESULT, IMA_TYPE_UV_TEST, image(), and ImBuf::rect_float.
Referenced by gpu_texture_create_tile_array(), gpu_texture_update_from_ibuf(), image_get_gpu_texture(), and ShaderParameters::update().
Called on entering and exiting texture paint mode, temporary disabling/enabling mipmapping on all images for quick texture updates with glTexSubImage2D. images that didn't change don't have to be re-uploaded to OpenGL.
Definition at line 866 of file image_gpu.cc.
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, 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().
void BKE_image_update_gputexture | ( | struct Image * | ima, |
struct ImageUser * | iuser, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Partial update of texture for texture painting. This is often much quicker than fully updating the texture for high resolution images.
Definition at line 838 of file image_gpu.cc.
References BKE_image_acquire_ibuf(), BKE_image_get_tile_from_iuser, BKE_image_release_ibuf(), BKE_image_update_gputexture_delayed(), w(), x, and y.
Referenced by imapaint_image_update().
void BKE_image_update_gputexture_delayed | ( | struct Image * | ima, |
struct ImageTile * | image_tile, | ||
struct ImBuf * | ibuf, | ||
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Mark areas on the GPUTexture that needs to be updated. The areas are marked in chunks. The next time the GPUTexture is used these tiles will be refreshes. This saves time when writing to the same place multiple times This happens for during foreground rendering.
Definition at line 846 of file image_gpu.cc.
References BKE_image_partial_update_mark_full_update(), BKE_image_partial_update_mark_region(), BLI_rcti_init(), IMA_SRC_TILED, Image::source, w(), x, ImBuf::x, y, and ImBuf::y.
Referenced by BKE_image_update_gputexture(), and image_rect_update().
Definition at line 128 of file image_gpu.cc.
References Freestyle::a, usdtokens::b(), and PackTile::pack_score.
Referenced by gpu_texture_create_tile_array().
|
static |
Definition at line 252 of file image_gpu.cc.
References BLI_assert, ELEM, Image::gputexture, and TEXTARGET_COUNT.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 465 of file image_gpu.cc.
References BLI_linklist_pop(), BLI_mutex_lock(), BLI_mutex_unlock(), GPU_texture_free(), gpu_texture_free_queue, gpu_texture_queue_mutex, and tex.
Referenced by BKE_image_free_unused_gpu_textures(), and image_get_gpu_texture().
|
static |
Definition at line 136 of file image_gpu.cc.
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_MIPMAP_COMPLETE, IMA_HIGH_BITDEPTH, IMB_touch_gpu_texture(), IMB_update_gpu_texture_sub(), is_over_resolution_limit(), LISTBASE_FOREACH, max_ff(), max_ii(), min_ff(), ID::name, PackTile::pack_score, smaller_power_of_2_limit(), tex, tile, 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 80 of file image_gpu.cc.
References BKE_image_sort_tiles(), 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, tex, TEXTARGET_2D_ARRAY, tile, ImageTile::tile_number, ImageTile_Runtime::tilearray_layer, ImageTile_Runtime::tilearray_offset, ImageTile_Runtime::tilearray_size, Image::tiles, and width.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 690 of file image_gpu.cc.
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(), IMB_colormanagement_space_is_srgb(), max_ii(), MEM_freeN, MEM_mallocN, min_ii(), padding(), ImBuf::rect, ImBuf::rect_colorspace, ImBuf::rect_float, scaled(), tex, tile, 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 622 of file image_gpu.cc.
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 660 of file image_gpu.cc.
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().
Definition at line 494 of file image_gpu.cc.
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, and TEXTARGET_COUNT.
Referenced by BKE_image_free_gputextures(), and image_gpu_texture_try_partial_update().
|
static |
Definition at line 328 of file image_gpu.cc.
References BKE_image_acquire_ibuf(), BKE_image_get_tile, BKE_image_has_gpu_texture_premultiplied_alpha(), BKE_image_partial_update_create(), BKE_image_release_ibuf(), BKE_image_tag_time(), Image::flag, get_image_gpu_texture_ptr(), gpu_free_unused_buffers(), Image::gpu_layer, GPU_mipmap_enabled(), Image::gpu_pass, 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_MIPMAP_COMPLETE, IMA_HIGH_BITDEPTH, image_gpu_texture_error_create(), image_gpu_texture_try_partial_update(), IMB_create_gpu_texture(), ImageUser::layer, ImageUser::multi_index, ImageUser::multiview_eye, ID::name, Image_Runtime::partial_update_user, ImageUser::pass, Image::runtime, tex, TEXTARGET_2D_ARRAY, TEXTARGET_TILE_MAPPING, tile, 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 266 of file image_gpu.cc.
References GPU_texture_create_error(), TEXTARGET_2D, TEXTARGET_2D_ARRAY, and TEXTARGET_TILE_MAPPING.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 280 of file image_gpu.cc.
References BLI_rcti_init(), BLI_rcti_isect(), BLI_rcti_size_x(), BLI_rcti_size_y(), blender::bke::image::partial_update::ChangeAvailable, blender::bke::image::partial_update::PartialUpdateChecker< TileData >::CollectResult::changed_region, blender::bke::image::partial_update::PartialUpdateChecker< TileData >::CollectResult::get_next_change(), image(), image_update_gputexture_ex(), blender::bke::image::partial_update::PartialUpdateRegion::region, blender::bke::image::partial_update::PartialUpdateChecker< TileData >::CollectResult::tile_data, rcti::xmin, and rcti::ymin.
Referenced by image_gpu_texture_try_partial_update().
Definition at line 306 of file image_gpu.cc.
References blender::bke::image::partial_update::PartialUpdateChecker< TileData >::collect_changes(), blender::bke::image::partial_update::FullUpdateNeeded, blender::bke::image::partial_update::PartialUpdateChecker< TileData >::CollectResult::get_result_code(), image(), image_free_gpu(), image_gpu_texture_partial_update_changes_available(), blender::bke::image::partial_update::NoChangesDetected, and blender::bke::image::partial_update::PartialChangesDetected.
Referenced by image_get_gpu_texture().
|
static |
Definition at line 821 of file image_gpu.cc.
References ListBase::first, gpu_texture_update_from_ibuf(), Image::gputexture, tex, TEXTARGET_2D, TEXTARGET_2D_ARRAY, tile, Image::tiles, w(), x, and y.
Referenced by image_gpu_texture_partial_update_changes_available().
|
static |
Definition at line 70 of file image_gpu.cc.
References GPU_texture_size_with_limit(), and w().
Referenced by gpu_texture_create_tile_array().
|
static |
Definition at line 75 of file image_gpu.cc.
References GPU_texture_size_with_limit(), and power_of_2_min_i().
Referenced by gpu_texture_create_tile_array().
|
static |
Definition at line 583 of file image_gpu.cc.
References ceil(), float(), IMB_allocFromBuffer(), IMB_scaleImBuf(), w(), x, and y.
Referenced by gpu_texture_update_scaled().
|
static |
Definition at line 462 of file image_gpu.cc.
Referenced by gpu_free_unused_buffers(), and image_free_gpu().
|
static |
Definition at line 463 of file image_gpu.cc.
Referenced by gpu_free_unused_buffers(), and image_free_gpu().