83 if (tilearray ==
nullptr) {
96 int width = max_tile + 1;
98 for (
int i = 0;
i < width;
i++) {
102 int i =
tile->tile_number - 1001;
106 float *tile_info = &
data[4 * width + 4 *
i];
138 int arraywidth = 0, arrayheight = 0;
173 BLI_assert(arraywidth > 0 && arrayheight > 0);
178 while (boxes.
first !=
nullptr) {
189 tileoffset[0] = packtile->boxpack.x;
190 tileoffset[1] = packtile->boxpack.y;
191 tilesize[0] = packtile->boxpack.w;
192 tilesize[1] = packtile->boxpack.h;
201 const bool use_grayscale = planes <= 8;
218 if (tilesize[0] == 0 || tilesize[1] == 0) {
236 store_premultiplied);
264 const int multiview_eye)
266 const bool in_range = (int(textarget) >= 0) && (textarget <
TEXTARGET_COUNT);
271 return &(ima->
gputexture[textarget][multiview_eye]);
278 fprintf(stderr,
"GPUTexture: Blender Texture Not Loaded!\n");
298 &buffer_rect, 0, changes.
tile_data.tile_buffer->x, 0, changes.
tile_data.tile_buffer->y);
299 rcti clipped_update_region;
309 clipped_update_region.
xmin,
310 clipped_update_region.
ymin,
356 const bool use_viewers,
357 const bool use_tile_mapping,
362 if (ima ==
nullptr) {
373 short requested_pass = iuser ? iuser->
pass : 0;
374 short requested_layer = iuser ? iuser->
layer : 0;
375 short requested_view = iuser ? iuser->
multi_index : 0;
378 if (requested_view < 2) {
391#undef GPU_FLAGS_TO_CHECK
393 if (ima->
runtime->partial_update_user ==
nullptr) {
409 if (current_view >= 2) {
430 if (
tile ==
nullptr) {
441 if (ibuf ==
nullptr) {
461 ima->
id.
name + 2, ibuf, use_high_bitdepth, store_premultiplied);
498 const bool use_tile_mapping)
505 const bool use_tile_mapping)
551 for (
int eye = 0; eye < 2; eye++) {
597 static int lasttime = 0;
604 if (
U.textimeout == 0 || ctime %
U.texcollectrate || ctime == lasttime) {
609 if (
G.is_rendering) {
616 if ((ima->flag &
IMA_NOCOLLECT) == 0 && ctime - ima->lastused >
U.textimeout) {
621 ima->lastused = ctime;
638 const float *rect_float,
649 float xratio = limit_w / float(full_w);
650 float yratio = limit_h / float(full_h);
652 int part_w = *
w, part_h = *h;
658 *
w = int(
ceil(xratio * (*
w)));
659 *h = int(
ceil(yratio * (*h)));
662 if (*
x + *
w > limit_w) {
665 if (*
y + *h > limit_h) {
678 const float *rect_float,
684 const int *tile_offset,
685 const int *tile_size,
692 rect, rect_float, &
x, &
y, &
w, &h, tile_size[0], tile_size[1], full_w, full_h);
703 ibuf =
update_do_scale(rect, rect_float, &
x, &
y, &
w, &h, limit_w, limit_h, full_w, full_h);
721 const int tile_offset[2],
733 void *
data = (rect_float) ? (
void *)(rect_float + tex_offset) : (
void *)(rect + tex_offset);
749 if (
tile !=
nullptr) {
752 scaled = (ibuf->
x != tilesize[0]) || (ibuf->
y != tilesize[1]);
772 int tex_stride = ibuf->
x;
773 int tex_offset = ibuf->
channels * (
y * ibuf->
x +
x);
782 if (rect_float ==
nullptr) {
790 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
805 if (rect ==
nullptr) {
819 if (rect_float ==
nullptr) {
827 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
833 if (
tile !=
nullptr) {
839 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, tilelayer, tileoffset, tilesize,
w, h);
843 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, -1,
nullptr,
nullptr,
w, h);
848 if (
tile !=
nullptr) {
853 tex, rect, rect_float,
x,
y, tilelayer, tileoffset,
w, h, tex_stride, tex_offset);
857 tex, rect, rect_float,
x,
y, -1,
nullptr,
w, h, tex_stride, tex_offset);
891 if (tex !=
nullptr) {
927 for (
int eye = 0; eye < 2; eye++) {
928 GPUTexture *tex = ima->gputexture[a][eye];
929 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)
@ IMA_GPU_MIPMAP_COMPLETE
int GPU_texture_size_with_limit(int res)
bool GPU_mipmap_enabled()
int GPU_texture_height(const GPUTexture *texture)
void GPU_texture_free(GPUTexture *texture)
int GPU_texture_width(const GPUTexture *texture)
void GPU_texture_unbind(GPUTexture *texture)
GPUTexture * GPU_texture_create_error(int dimension, bool array)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
void GPU_texture_update_sub(GPUTexture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_update_mipmap_chain(GPUTexture *texture)
GPUTexture * GPU_texture_create_1d_array(const char *name, int width, int layer_len, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_unpack_row_length_set(uint len)
void GPU_texture_original_size_set(GPUTexture *texture, int width, int height)
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)
ImBuf * IMB_allocFromBuffer(const uint8_t *byte_buffer, const float *float_buffer, unsigned int w, unsigned int h, unsigned int channels)
GPUTexture * IMB_touch_gpu_texture(const char *name, ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth, bool use_grayscale)
void IMB_update_gpu_texture_sub(GPUTexture *tex, ImBuf *ibuf, int x, int y, int z, int w, int h, bool use_high_bitdepth, bool use_grayscale, bool use_premult)
void IMB_freeImBuf(ImBuf *ibuf)
GPUTexture * IMB_create_gpu_texture(const char *name, ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
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.
#define IMAGE_GPU_PASS_NONE
#define IMAGE_GPU_LAYER_NONE
#define IMAGE_GPU_VIEW_NONE
static ImageGPUTextures image_get_gpu_texture(Image *ima, ImageUser *iuser, const bool use_viewers, const bool use_tile_mapping, bool try_only)
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)
static GPUTexture * gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
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)
static void gpu_texture_update_from_ibuf(GPUTexture *tex, Image *ima, ImBuf *ibuf, ImageTile *tile, int x, int y, int w, int h)
GPUTexture * BKE_image_get_gpu_viewer_texture(Image *image, ImageUser *iuser)
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)
static GPUTexture * image_gpu_texture_error_create(eGPUTextureTarget textarget)
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 bool is_over_resolution_limit(int w, int h)
GPUTexture * BKE_image_get_gpu_texture(Image *image, ImageUser *iuser)
void BKE_image_paint_set_mipmap(Main *bmain, bool mipmap)
static GPUTexture ** get_image_gpu_texture_ptr(Image *ima, eGPUTextureTarget textarget, const int multiview_eye)
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 int smaller_power_of_2_limit(int num)
static GPUTexture * gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
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)
static LinkNode * gpu_texture_free_queue
static void gpu_texture_update_scaled(GPUTexture *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)
void BKE_image_free_all_gputextures(Main *bmain)
void BKE_image_free_unused_gpu_textures()
static blender::Mutex gpu_texture_queue_mutex
void BKE_image_free_old_gputextures(Main *bmain)
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
struct 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