81 if (tilearray ==
nullptr) {
94 int width = max_tile + 1;
95 float *
data = (
float *)
MEM_callocN(width * 8 *
sizeof(
float), __func__);
96 for (
int i = 0; i < width; i++) {
100 int i =
tile->tile_number - 1001;
104 float *tile_info = &
data[4 * width + 4 * i];
136 int arraywidth = 0, arrayheight = 0;
148 PackTile *packtile = MEM_cnew<PackTile>(__func__);
171 BLI_assert(arraywidth > 0 && arrayheight > 0);
176 while (boxes.
first !=
nullptr) {
187 tileoffset[0] = packtile->boxpack.x;
188 tileoffset[1] = packtile->boxpack.y;
189 tilesize[0] = packtile->boxpack.w;
190 tilesize[1] = packtile->boxpack.h;
199 const bool use_grayscale = planes <= 8;
216 if (tilesize[0] == 0 || tilesize[1] == 0) {
234 store_premultiplied);
262 const int multiview_eye)
269 return &(ima->
gputexture[textarget][multiview_eye]);
276 fprintf(stderr,
"GPUTexture: Blender Texture Not Loaded!\n");
296 &buffer_rect, 0, changes.
tile_data.tile_buffer->x, 0, changes.
tile_data.tile_buffer->y);
297 rcti clipped_update_region;
307 clipped_update_region.
xmin,
308 clipped_update_region.
ymin,
353 const bool use_viewers,
354 const bool use_tile_mapping)
358 if (ima ==
nullptr) {
369 short requested_pass = iuser ? iuser->
pass : 0;
370 short requested_layer = iuser ? iuser->
layer : 0;
371 short requested_view = iuser ? iuser->
multi_index : 0;
374 if (requested_view < 2) {
387#undef GPU_FLAGS_TO_CHECK
405 if (current_view >= 2) {
418 if (
tile ==
nullptr) {
427 if (ibuf ==
nullptr) {
443 result.tile_mapping = *tile_mapping_tex;
488 const bool use_tile_mapping)
536 for (
int eye = 0; eye < 2; eye++) {
583 static int lasttime = 0;
590 if (
U.textimeout == 0 || ctime %
U.texcollectrate || ctime == lasttime) {
595 if (
G.is_rendering) {
602 if ((ima->flag &
IMA_NOCOLLECT) == 0 && ctime - ima->lastused >
U.textimeout) {
607 ima->lastused = ctime;
624 const float *rect_float,
635 float xratio = limit_w /
float(full_w);
636 float yratio = limit_h /
float(full_h);
638 int part_w = *
w, part_h = *h;
648 if (*
x + *
w > limit_w) {
651 if (*
y + *h > limit_h) {
664 const float *rect_float,
670 const int *tile_offset,
671 const int *tile_size,
678 rect, rect_float, &
x, &
y, &
w, &h, tile_size[0], tile_size[1], full_w, full_h);
689 ibuf =
update_do_scale(rect, rect_float, &
x, &
y, &
w, &h, limit_w, limit_h, full_w, full_h);
707 const int tile_offset[2],
719 void *
data = (rect_float) ? (
void *)(rect_float + tex_offset) : (
void *)(rect + tex_offset);
735 if (
tile !=
nullptr) {
738 scaled = (ibuf->
x != tilesize[0]) || (ibuf->
y != tilesize[1]);
758 int tex_stride = ibuf->
x;
759 int tex_offset = ibuf->
channels * (
y * ibuf->
x +
x);
767 rect_float = (
float *)
MEM_mallocN(
sizeof(
float[4]) *
w * h, __func__);
768 if (rect_float ==
nullptr) {
776 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
791 if (rect ==
nullptr) {
804 rect_float = (
float *)
MEM_mallocN(
sizeof(
float[4]) *
w * h, __func__);
805 if (rect_float ==
nullptr) {
813 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
819 if (
tile !=
nullptr) {
825 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, tilelayer, tileoffset, tilesize,
w, h);
829 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, -1,
nullptr,
nullptr,
w, h);
834 if (
tile !=
nullptr) {
839 tex, rect, rect_float,
x,
y, tilelayer, tileoffset,
w, h, tex_stride, tex_offset);
843 tex, rect, rect_float,
x,
y, -1,
nullptr,
w, h, tex_stride, tex_offset);
877 if (tex !=
nullptr) {
913 for (
int eye = 0; eye < 2; eye++) {
914 GPUTexture *tex = ima->gputexture[a][eye];
915 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(struct ListBase *listbase) ATTR_NONNULL(1)
void void BLI_listbase_sort(struct ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) 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)
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)
#define BLI_MUTEX_INITIALIZER
int BLI_thread_is_main(void)
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
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)
bool IMB_colormanagement_space_is_data(ColorSpace *colorspace)
bool IMB_colormanagement_space_is_srgb(ColorSpace *colorspace)
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(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)
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)
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)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
struct ImBuf * IMB_allocFromBuffer(const uint8_t *, const float *, unsigned int, unsigned int, unsigned int)
void IMB_freeImBuf(ImBuf *)
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)
void BKE_image_free_anim_gputextures(Main *bmain)
void BKE_image_ensure_gpu_texture(Image *image, ImageUser *image_user)
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 ThreadMutex gpu_texture_queue_mutex
static GPUTexture * image_gpu_texture_error_create(eGPUTextureTarget textarget)
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 ImageGPUTextures image_get_gpu_texture(Image *ima, ImageUser *iuser, const bool use_viewers, const bool use_tile_mapping)
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()
void BKE_image_free_old_gputextures(Main *bmain)
ccl_global const KernelWorkTile * tile
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float3 ceil(const float3 a)
@ 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.
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct PartialUpdateUser * partial_update_user
Partial update user for GPUTextures stored inside the Image.
struct GPUTexture * gputexture[3][2]
TileData tile_data
Tile specific data.
PartialUpdateRegion changed_region
ePartialUpdateIterResult get_next_change()
Load the next changed region.
const ePartialUpdateCollectResult get_result_code() const
CollectResult collect_changes()
Check for new changes since the last time this method was invoked for this user.
struct 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