84 if (tilearray ==
nullptr) {
97 int width = max_tile + 1;
99 for (
int i = 0; i <
width; i++) {
103 int i =
tile->tile_number - 1001;
107 float *tile_info = &
data[4 *
width + 4 * i];
138 int arraywidth = 0, arrayheight = 0;
148 PackTile *packtile = MEM_cnew<PackTile>(__func__);
170 BLI_assert(arraywidth > 0 && arrayheight > 0);
175 while (boxes.
first !=
nullptr) {
186 tileoffset[0] = packtile->boxpack.x;
187 tileoffset[1] = packtile->boxpack.y;
188 tilesize[0] = packtile->boxpack.w;
189 tilesize[1] = packtile->boxpack.h;
200 ima->
id.
name + 2, main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth);
209 if (tilesize[0] == 0 || tilesize[1] == 0) {
226 store_premultiplied);
254 const int multiview_eye)
256 const bool in_range = (textarget >= 0) && (textarget <
TEXTARGET_COUNT);
261 return &(ima->
gputexture[textarget][multiview_eye]);
268 fprintf(stderr,
"GPUTexture: Blender Texture Not Loaded!\n");
288 &buffer_rect, 0, changes.
tile_data.tile_buffer->x, 0, changes.
tile_data.tile_buffer->y);
289 rcti clipped_update_region;
299 clipped_update_region.
xmin,
300 clipped_update_region.
ymin,
333 if (ima ==
nullptr) {
344 short requested_pass = iuser ? iuser->
pass : 0;
345 short requested_layer = iuser ? iuser->
layer : 0;
346 short requested_view = iuser ? iuser->
multi_index : 0;
349 if (requested_view < 2) {
358 #undef GPU_FLAGS_TO_CHECK
371 if (current_view >= 2) {
382 if (
tile ==
nullptr) {
388 ImBuf *ibuf_intern = ibuf;
389 if (ibuf_intern ==
nullptr) {
391 if (ibuf_intern ==
nullptr) {
409 ima->
id.
name + 2, ibuf_intern, use_high_bitdepth, store_premultiplied);
431 if (ibuf != ibuf_intern) {
496 for (
int eye = 0; eye < 2; eye++) {
543 static int lasttime = 0;
550 if (
U.textimeout == 0 || ctime %
U.texcollectrate || ctime == lasttime) {
555 if (
G.is_rendering) {
562 if ((ima->flag &
IMA_NOCOLLECT) == 0 && ctime - ima->lastused >
U.textimeout) {
567 ima->lastused = ctime;
595 float xratio = limit_w / (
float)full_w;
596 float yratio = limit_h / (
float)full_h;
598 int part_w = *
w, part_h = *h;
604 *
w = (int)
ceil(xratio * (*
w));
605 *h = (int)
ceil(yratio * (*h));
608 if (*
x + *
w > limit_w) {
611 if (*
y + *h > limit_h) {
630 const int *tile_offset,
631 const int *tile_size,
638 rect, rect_float, &
x, &
y, &
w, &h, tile_size[0], tile_size[1], full_w, full_h);
649 ibuf =
update_do_scale(rect, rect_float, &
x, &
y, &
w, &h, limit_w, limit_h, full_w, full_h);
666 const int tile_offset[2],
678 void *
data = (rect_float) ? (
void *)(rect_float + tex_offset) : (
void *)(rect + tex_offset);
694 if (
tile !=
nullptr) {
697 scaled = (ibuf->
x != tilesize[0]) || (ibuf->
y != tilesize[1]);
717 int tex_stride = ibuf->
x;
718 int tex_offset = ibuf->
channels * (
y * ibuf->
x +
x);
726 rect_float = (
float *)
MEM_mallocN(
sizeof(
float[4]) *
w * h, __func__);
727 if (rect_float ==
nullptr) {
735 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
747 if (rect ==
nullptr) {
760 rect_float = (
float *)
MEM_mallocN(
sizeof(
float[4]) *
w * h, __func__);
761 if (rect_float ==
nullptr) {
769 rect_float,
x,
y,
w, h, ibuf, store_premultiplied);
775 if (
tile !=
nullptr) {
781 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, tilelayer, tileoffset, tilesize,
w, h);
785 tex, rect, rect_float, ibuf->
x, ibuf->
y,
x,
y, -1,
nullptr,
nullptr,
w, h);
790 if (
tile !=
nullptr) {
795 tex, rect, rect_float,
x,
y, tilelayer, tileoffset,
w, h, tex_stride, tex_offset);
799 tex, rect, rect_float,
x,
y, -1,
nullptr,
w, h, tex_stride, tex_offset);
804 if (rect && rect != (
uchar *)ibuf->
rect) {
807 if (rect_float && rect_float != ibuf->
rect_float) {
833 if (
tex !=
nullptr) {
873 for (
int eye = 0; eye < 2; eye++) {
875 if (
tex !=
nullptr) {
typedef float(TangentPoint)[2]
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
void BKE_image_sort_tiles(struct Image *ima)
void BKE_image_partial_update_mark_region(struct Image *image, const struct ImageTile *image_tile, const struct ImBuf *image_buffer, const rcti *updated_region)
Mark a region of the image to update.
bool BKE_image_is_animated(struct Image *image)
struct PartialUpdateUser * BKE_image_partial_update_create(const struct Image *image)
Create a new PartialUpdateUser. An Object that contains data to use partial updates.
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
void BKE_image_partial_update_mark_full_update(struct Image *image)
Mark the whole image to be updated.
bool BKE_image_has_opengl_texture(struct Image *ima)
void BKE_imageuser_default(struct ImageUser *iuser)
void BKE_image_tag_time(struct Image *ima)
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
@ IMA_GPU_MIPMAP_COMPLETE
int GPU_texture_size_with_limit(int res)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
bool GPU_mipmap_enabled(void)
GPUTexture * GPU_texture_create_1d_array(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
void GPU_texture_update_sub(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp)
int GPU_texture_height(const GPUTexture *tex)
struct GPUTexture GPUTexture
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
int GPU_texture_width(const GPUTexture *tex)
void GPU_texture_free(GPUTexture *tex)
void GPU_texture_unbind(GPUTexture *tex)
void GPU_texture_orig_size_set(GPUTexture *tex, int w, int h)
void GPU_unpack_row_length_set(uint len)
GPUTexture * GPU_texture_create_error(int dimension, bool array)
void GPU_texture_generate_mipmap(GPUTexture *tex)
bool IMB_colormanagement_space_is_srgb(struct ColorSpace *colorspace)
bool IMB_colormanagement_space_is_scene_linear(struct ColorSpace *colorspace)
void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, int offset_x, int offset_y, int width, int height, const struct ImBuf *ibuf, bool store_premultiplied)
void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer, int x, int y, int width, int height, const struct ImBuf *ibuf, bool store_premultiplied)
bool IMB_colormanagement_space_is_data(struct ColorSpace *colorspace)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct GPUTexture * IMB_create_gpu_texture(const char *name, struct ImBuf *ibuf, bool use_high_bitdepth, bool use_premult)
struct GPUTexture * IMB_touch_gpu_texture(const char *name, struct ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth)
void IMB_update_gpu_texture_sub(struct GPUTexture *tex, struct ImBuf *ibuf, int x, int y, int z, int w, int h, bool use_high_bitdepth, bool use_premult)
struct ImBuf * IMB_allocFromBuffer(const unsigned int *rect, const float *rectf, unsigned int w, unsigned int h, unsigned int channels)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Platform independent time functions.
btMatrix3x3 scaled(const btVector3 &s) const
Create a scaled copy of the matrix.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
struct GPUTexture * gputexture[3][2]
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
static GPUTexture * image_get_gpu_texture(Image *ima, ImageUser *iuser, ImBuf *ibuf, eGPUTextureTarget textarget)
static int compare_packtile(const void *a, const void *b)
static void gpu_free_unused_buffers()
GPUTexture * BKE_image_get_gpu_texture(Image *image, ImageUser *iuser, ImBuf *ibuf)
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 * image_gpu_texture_error_create(eGPUTextureTarget textarget)
GPUTexture * BKE_image_get_gpu_tilemap(Image *image, ImageUser *iuser, ImBuf *ibuf)
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)
bool BKE_image_has_gpu_texture_premultiplied_alpha(Image *image, ImBuf *ibuf)
static void image_gpu_texture_try_partial_update(Image *image, ImageUser *iuser)
static ThreadMutex gpu_texture_queue_mutex
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 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 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)
void BKE_image_paint_set_mipmap(Main *bmain, bool mipmap)
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 void image_update_gputexture_ex(Image *ima, ImageTile *tile, ImBuf *ibuf, int x, int y, int w, int h)
void BKE_image_update_gputexture_delayed(struct Image *ima, struct ImageTile *image_tile, struct ImBuf *ibuf, int x, int y, int w, int h)
static LinkNode * gpu_texture_free_queue
GPUTexture * BKE_image_get_gpu_tiles(Image *image, ImageUser *iuser, ImBuf *ibuf)
static GPUTexture ** get_image_gpu_texture_ptr(Image *ima, eGPUTextureTarget textarget, const int multiview_eye)
void BKE_image_free_all_gputextures(Main *bmain)
void BKE_image_free_unused_gpu_textures()
void BKE_image_free_old_gputextures(Main *bmain)
static GPUTexture * gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
static GPUTexture * gpu_texture_create_tile_mapping(Image *ima, const int multiview_eye)
void * BKE_image_free_buffers
void * BKE_image_get_tile_from_iuser
void * BKE_image_get_tile
ccl_global const KernelWorkTile * tile
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(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.
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
struct ColorSpace * rect_colorspace
struct PartialUpdateUser * partial_update_user
Partial update user for GPUTextures stored inside the Image.
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.
double PIL_check_seconds_timer(void)