87 if (tilearray ==
nullptr) {
100 int width = max_tile + 1;
102 for (
int i = 0;
i < width;
i++) {
106 int i =
tile->tile_number - 1001;
110 float *tile_info = &
data[4 * width + 4 *
i];
122 blender::gpu::TextureFormat::SFLOAT_32_32_32_32,
148 int arraywidth = 0, arrayheight = 0;
183 BLI_assert(arraywidth > 0 && arrayheight > 0);
188 while (boxes.
first !=
nullptr) {
199 tileoffset[0] = packtile->boxpack.x;
200 tileoffset[1] = packtile->boxpack.y;
201 tilesize[0] = packtile->boxpack.w;
202 tilesize[1] = packtile->boxpack.h;
211 const bool use_grayscale = planes <= 8;
228 if (tilesize[0] == 0 || tilesize[1] == 0) {
246 store_premultiplied);
274 const int multiview_eye)
276 const bool in_range = (int(textarget) >= 0) && (textarget <
TEXTARGET_COUNT);
281 return &(ima->
gputexture[textarget][multiview_eye]);
288 CLOG_ERROR(&
LOG,
"Failed to create GPU texture from Blender image");
308 &buffer_rect, 0, changes.
tile_data.tile_buffer->x, 0, changes.
tile_data.tile_buffer->y);
309 rcti clipped_update_region;
319 clipped_update_region.
xmin,
320 clipped_update_region.
ymin,
366 const bool use_viewers,
367 const bool use_tile_mapping,
372 if (ima ==
nullptr) {
383 short requested_pass = iuser ? iuser->
pass : 0;
384 short requested_layer = iuser ? iuser->
layer : 0;
385 short requested_view = iuser ? iuser->
multi_index : 0;
388 if (requested_view < 2) {
401#undef GPU_FLAGS_TO_CHECK
403 if (ima->
runtime->partial_update_user ==
nullptr) {
419 if (current_view >= 2) {
440 if (
tile ==
nullptr) {
451 if (ibuf ==
nullptr) {
471 ima->
id.
name + 2, ibuf, use_high_bitdepth, store_premultiplied);
508 const bool use_tile_mapping)
515 const bool use_tile_mapping)
562 for (
int eye = 0; eye < 2; eye++) {
608 static int lasttime = 0;
615 if (
U.textimeout == 0 || ctime %
U.texcollectrate || ctime == lasttime) {
620 if (
G.is_rendering) {
627 if ((ima->flag &
IMA_NOCOLLECT) == 0 && ctime - ima->lastused >
U.textimeout) {
632 ima->lastused = ctime;
649 const float *rect_float,
660 float xratio = limit_w /
float(full_w);
661 float yratio = limit_h /
float(full_h);
663 int part_w = *
w, part_h = *h;
669 *
w = int(
ceil(xratio * (*
w)));
670 *h = int(
ceil(yratio * (*h)));
673 if (*
x + *
w > limit_w) {
676 if (*
y + *h > limit_h) {
689 const float *rect_float,
695 const int *tile_offset,
696 const int *tile_size,
703 rect, rect_float, &
x, &
y, &
w, &h, tile_size[0], tile_size[1], full_w, full_h);
714 ibuf =
update_do_scale(rect, rect_float, &
x, &
y, &
w, &h, limit_w, limit_h, full_w, full_h);
732 const int tile_offset[2],
744 void *
data = (rect_float) ? (
void *)(rect_float + tex_offset) : (
void *)(rect + tex_offset);
766 if (
tile !=
nullptr) {
769 scaled = (ibuf->
x != tilesize[0]) || (ibuf->
y != tilesize[1]);
789 int tex_stride = ibuf->
x;
790 int tex_offset = ibuf->
channels * (
y * ibuf->
x +
x);
799 if (rect_float ==
nullptr) {
807 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
822 if (rect ==
nullptr) {
836 if (rect_float ==
nullptr) {
844 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
850 if (
tile !=
nullptr) {
856 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, tilelayer, tileoffset, tilesize,
w, h);
860 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, -1,
nullptr,
nullptr,
w, h);
865 if (
tile !=
nullptr) {
870 tex, rect, rect_float,
x,
y, tilelayer, tileoffset,
w, h, tex_stride, tex_offset);
874 tex, rect, rect_float,
x,
y, -1,
nullptr,
w, h, tex_stride, tex_offset);
908 if (tex !=
nullptr) {
944 for (
int eye = 0; eye < 2; eye++) {
946 if (tex !=
nullptr) {
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_partial_update_mark_region(Image *image, const ImageTile *image_tile, const ImBuf *image_buffer, const rcti *updated_region)
Mark a region of the image to update.
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
void BKE_image_tag_time(Image *ima)
void BKE_image_sort_tiles(Image *ima)
bool BKE_image_has_opengl_texture(Image *ima)
void BKE_imageuser_default(ImageUser *iuser)
PartialUpdateUser * BKE_image_partial_update_create(const Image *image)
Create a new PartialUpdateUser. An Object that contains data to use partial updates.
bool BKE_image_is_animated(Image *image)
void BKE_image_partial_update_mark_full_update(Image *image)
Mark the whole image to be updated.
void BLI_box_pack_2d_fixedarea(struct ListBase *boxes, int width, int height, struct ListBase *packed)
void void void * BLI_linklist_pop(LinkNode **listp) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_linklist_prepend(LinkNode **listp, void *ptr) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
MINLINE int power_of_2_min_i(int n)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
ATTR_WARN_UNUSED_RESULT const size_t num
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
int BLI_thread_is_main(void)
Platform independent time functions.
double BLI_time_now_seconds(void)
#define CLOG_ERROR(clg_ref,...)
@ IMA_GPU_MIPMAP_COMPLETE
#define IMAGE_GPU_PASS_NONE
#define IMAGE_GPU_LAYER_NONE
#define IMAGE_GPU_VIEW_NONE
int GPU_texture_size_with_limit(int res)
bool GPU_mipmap_enabled()
void GPU_texture_update_sub(blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
int GPU_texture_height(const blender::gpu::Texture *texture)
blender::gpu::Texture * GPU_texture_create_1d_array(const char *name, int width, int layer_len, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_update_mipmap_chain(blender::gpu::Texture *texture)
void GPU_texture_unbind(blender::gpu::Texture *texture)
int GPU_texture_width(const blender::gpu::Texture *texture)
void GPU_texture_original_size_set(blender::gpu::Texture *texture, int width, int height)
void GPU_texture_extend_mode(blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_mipmap_mode(blender::gpu::Texture *texture, bool use_mipmap, bool use_filter)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
void GPU_unpack_row_length_set(uint len)
blender::gpu::Texture * GPU_texture_create_error(int dimension, bool array)
void GPU_texture_free(blender::gpu::Texture *texture)
void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer, int offset_x, int offset_y, int width, int height, const ImBuf *ibuf, bool store_premultiplied)
bool IMB_colormanagement_space_is_scene_linear(const ColorSpace *colorspace)
bool IMB_colormanagement_space_is_data(const ColorSpace *colorspace)
void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, int offset_x, int offset_y, int width, int height, const ImBuf *ibuf, bool store_premultiplied)
bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace)
blender::gpu::Texture * IMB_create_gpu_texture(const char *name, ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
ImBuf * IMB_allocFromBuffer(const uint8_t *byte_buffer, const float *float_buffer, unsigned int w, unsigned int h, unsigned int channels)
void IMB_freeImBuf(ImBuf *ibuf)
void IMB_update_gpu_texture_sub(blender::gpu::Texture *tex, ImBuf *ibuf, int x, int y, int z, int w, int h, bool use_high_bitdepth, bool use_grayscale, bool use_premult)
blender::gpu::Texture * IMB_touch_gpu_texture(const char *name, ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth, bool use_grayscale)
bool IMB_scale(ImBuf *ibuf, unsigned int newx, unsigned int newy, IMBScaleFilter filter, bool threaded=true)
Read Guarded memory(de)allocation.
BMesh const char void * data
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static ImageGPUTextures image_get_gpu_texture(Image *ima, ImageUser *iuser, const bool use_viewers, const bool use_tile_mapping, bool try_only)
static void gpu_texture_update_unscaled(blender::gpu::Texture *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_scaled(blender::gpu::Texture *tex, const uchar *rect, const 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 int compare_packtile(const void *a, const void *b)
static void gpu_free_unused_buffers()
static void image_gpu_texture_partial_update_changes_available(Image *image, PartialUpdateChecker< ImageTileData >::CollectResult &changes)
void BKE_image_update_gputexture(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
ImageGPUTextures BKE_image_get_gpu_material_texture_try(Image *image, ImageUser *iuser, const bool use_tile_mapping)
void BKE_image_free_anim_gputextures(Main *bmain)
bool BKE_image_has_gpu_texture_premultiplied_alpha(Image *image, ImBuf *ibuf)
ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping)
static void image_gpu_texture_try_partial_update(Image *image, ImageUser *iuser)
void BKE_image_update_gputexture_delayed(Image *ima, ImageTile *image_tile, ImBuf *ibuf, int x, int y, int w, int h)
blender::gpu::Texture * BKE_image_get_gpu_viewer_texture(Image *image, ImageUser *iuser)
void BKE_image_ensure_gpu_texture(Image *image, ImageUser *iuser)
static void image_free_gpu(Image *ima, const bool immediate)
void BKE_image_free_gputextures(Image *ima)
static blender::gpu::Texture * gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
static blender::gpu::Texture ** get_image_gpu_texture_ptr(Image *ima, eGPUTextureTarget textarget, const int multiview_eye)
static bool is_over_resolution_limit(int w, int h)
void BKE_image_paint_set_mipmap(Main *bmain, bool mipmap)
static int smaller_power_of_2_limit(int num)
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(const uchar *rect, const float *rect_float, int *x, int *y, int *w, int *h, int limit_w, int limit_h, int full_w, int full_h)
blender::gpu::Texture * BKE_image_get_gpu_texture(Image *image, ImageUser *iuser)
static LinkNode * gpu_texture_free_queue
void BKE_image_free_all_gputextures(Main *bmain)
void BKE_image_free_unused_gpu_textures()
static blender::Mutex gpu_texture_queue_mutex
static blender::gpu::Texture * image_gpu_texture_error_create(eGPUTextureTarget textarget)
void BKE_image_free_old_gputextures(Main *bmain)
static blender::gpu::Texture * gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
static void gpu_texture_update_from_ibuf(blender::gpu::Texture *tex, Image *ima, ImBuf *ibuf, ImageTile *tile, int x, int y, int w, int h)
const ccl_global KernelWorkTile * tile
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
@ PartialChangesDetected
Changes detected since the last time requested.
@ FullUpdateNeeded
Unable to construct partial updates. Caller should perform a full update.
@ NoChangesDetected
No changes detected since the last time requested.
@ ChangeAvailable
a chunk was available and has been loaded.
T max(const T &a, const T &b)
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
blender::gpu::Texture ** texture
GPUTexture * gputexture[3][2]
ImageRuntimeHandle * runtime
ePartialUpdateCollectResult get_result_code() const
TileData tile_data
Tile specific data.
PartialUpdateRegion changed_region
ePartialUpdateIterResult get_next_change()
Load the next changed region.
CollectResult collect_changes()
Check for new changes since the last time this method was invoked for this user.
rcti region
region of the image that has been updated. Region can be bigger than actual changes.
void * BKE_image_free_buffers
void * BKE_image_get_tile_from_iuser
void * BKE_image_get_tile