65 rctf new_clipping_bounds;
66 BLI_rctf_init(&new_clipping_bounds, min_uv[0], max_uv[0], min_uv[1], max_uv[1]);
80 DRWPass *create_image_pass()
const
87 DRWPass *create_depth_pass()
const
107 float image_mat[4][4];
133 float image_mat[4][4];
138 tile_user = *image_user;
157 if (tile_buffer !=
nullptr) {
161 float4 min_max_uv(tile_x, tile_y, tile_x + 1, tile_y + 1);
185 case ePartialUpdateCollectResult::FullUpdateNeeded:
189 case ePartialUpdateCollectResult::NoChangesDetected:
191 case ePartialUpdateCollectResult::PartialChangesDetected:
198 do_partial_update(changes, instance_data);
202 do_full_update_for_dirty_textures(instance_data, image_user);
208 void do_partial_update_float_buffer(
223 rcti clipped_update_region;
236 while (iterator.
get_next_change() == ePartialUpdateIterResult::ChangeAvailable) {
238 if (iterator.
tile_data.tile_buffer ==
nullptr) {
241 ImBuf *tile_buffer = ensure_float_buffer(instance_data, iterator.
tile_data.tile_buffer);
242 if (tile_buffer != iterator.
tile_data.tile_buffer) {
243 do_partial_update_float_buffer(tile_buffer, iterator);
246 const float tile_width =
static_cast<float>(iterator.
tile_data.tile_buffer->x);
247 const float tile_height =
static_cast<float>(iterator.
tile_data.tile_buffer->y);
266 rctf changed_region_in_uv_space;
268 static_cast<float>(changed_region_in_texel_space->
xmin) /
269 static_cast<float>(iterator.
tile_data.tile_buffer->x) +
271 static_cast<float>(changed_region_in_texel_space->
xmax) /
272 static_cast<float>(iterator.
tile_data.tile_buffer->x) +
274 static_cast<float>(changed_region_in_texel_space->
ymin) /
275 static_cast<float>(iterator.
tile_data.tile_buffer->y) +
277 static_cast<float>(changed_region_in_texel_space->
ymax) /
278 static_cast<float>(iterator.
tile_data.tile_buffer->y) +
280 rctf changed_overlapping_region_in_uv_space;
282 &changed_region_in_uv_space,
283 &changed_overlapping_region_in_uv_space);
284 if (!region_overlap) {
290 rcti gpu_texture_region_to_update;
292 &gpu_texture_region_to_update,
302 rcti tile_region_to_extract;
304 &tile_region_to_extract,
305 floor((changed_overlapping_region_in_uv_space.
xmin - tile_offset_x) * tile_width),
306 floor((changed_overlapping_region_in_uv_space.
xmax - tile_offset_x) * tile_width),
307 ceil((changed_overlapping_region_in_uv_space.
ymin - tile_offset_y) * tile_height),
308 ceil((changed_overlapping_region_in_uv_space.
ymax - tile_offset_y) * tile_height));
312 const int texture_region_width =
BLI_rcti_size_x(&gpu_texture_region_to_update);
313 const int texture_region_height =
BLI_rcti_size_y(&gpu_texture_region_to_update);
315 ImBuf extracted_buffer;
317 &extracted_buffer, texture_region_width, texture_region_height, 32,
IB_rectfloat);
320 for (
int y = gpu_texture_region_to_update.
ymin;
y < gpu_texture_region_to_update.
ymax;
322 float yf =
y / (
float)texture_height;
325 for (
int x = gpu_texture_region_to_update.
xmin;
x < gpu_texture_region_to_update.
xmax;
327 float xf =
x / (
float)texture_width;
343 gpu_texture_region_to_update.
xmin,
344 gpu_texture_region_to_update.
ymin,
365 do_full_update_gpu_texture(info, instance_data, image_user);
373 ImBuf texture_buffer;
379 tile_user = *image_user;
390 if (tile_buffer !=
nullptr) {
391 do_full_update_texture_slot(instance_data, info, texture_buffer, *tile_buffer, image_tile);
415 ImBuf &texture_buffer,
419 const int texture_width = texture_buffer.
x;
420 const int texture_height = texture_buffer.
y;
421 ImBuf *float_tile_buffer = ensure_float_buffer(instance_data, &tile_buffer);
426 float uv_to_texel[4][4];
428 float scale[3] = {
static_cast<float>(texture_width) /
static_cast<float>(tile_buffer.
x),
429 static_cast<float>(texture_height) /
static_cast<float>(tile_buffer.
y),
436 uv_to_texel[3][0] *= texture_width;
437 uv_to_texel[3][1] *= texture_height;
441 rctf *crop_rect_ptr =
nullptr;
448 crop_rect_ptr = &crop_rect;
472 TextureMethod method(instance_data);
481 method.update_screen_space_bounds(region);
482 method.update_screen_uv_bounds();
489 update_textures(*instance_data,
image, iuser);
494 add_depth_shgroups(*instance_data,
image, iuser);
496 add_shgroups(instance_data);
512 static float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
514 GPU_framebuffer_clear_color_depth(dfbl->
default_fb, clear_col, clear_depth);
typedef float(TangentPoint)[2]
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
#define LISTBASE_FOREACH(type, var, list)
bool invert_m4(float R[4][4])
void unit_m4(float m[4][4])
void rescale_m4(float mat[4][4], const float scale[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float 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)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
void BLI_rctf_init_minmax(struct rctf *rect)
@ DRW_STATE_DEPTH_LESS_EQUAL
@ DRW_STATE_BLEND_ALPHA_PREMUL
#define DRW_shgroup_call_obmat(shgroup, geom, obmat)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_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
struct GPUShader GPUShader
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)
int GPU_texture_height(const GPUTexture *tex)
struct GPUTexture GPUTexture
int GPU_texture_width(const GPUTexture *tex)
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
eIMBTransformMode
Transform modes to use for IMB_transform function.
@ IMB_TRANSFORM_MODE_WRAP_REPEAT
Wrap repeat the source buffer. Only supported in with nearest filtering.
@ IMB_TRANSFORM_MODE_CROP_SRC
Crop the source buffer.
bool IMB_initImBuf(struct ImBuf *ibuf, unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void imb_freerectImbuf_all(struct ImBuf *ibuf)
void IMB_float_from_rect_ex(struct ImBuf *dst, const struct ImBuf *src, const struct rcti *region_to_update)
void IMB_gpu_clamp_half_float(struct ImBuf *image_buffer)
void IMB_transform(const struct ImBuf *src, struct ImBuf *dst, eIMBTransformMode mode, eIMBInterpolationFilterMode filter, const float transform_matrix[4][4], const struct rctf *src_crop)
Transform source image buffer onto destination image buffer using a transform matrix.
void nearest_interpolation_color(const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
Contains defines and structs used throughout the imbuf module.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void cache_init(IMAGE_Data *vedata) const override
void draw_finish(IMAGE_Data *vedata) const override
void draw_scene(IMAGE_Data *vedata) const override
void cache_image(IMAGE_Data *vedata, Image *image, ImageUser *iuser) const override
SyclQueue void void * src
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
const DRWContextState * DRW_context_state_get(void)
DefaultTextureList * DRW_viewport_texture_list_get(void)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, eGPUSamplerState sampler_state)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
DRWPass * DRW_pass_create(const char *name, DRWState state)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_draw_pass(DRWPass *pass)
void DRW_view_set_active(const DRWView *view)
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
constexpr int SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN
max allowed textures to use by the ScreenSpaceDrawingMode.
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_device_inline float3 ceil(const float3 &a)
GPUShader * IMAGE_shader_image_get()
constexpr float EPSILON_UV_BOUNDS
GPUShader * IMAGE_shader_depth_get()
vec_base< float, 3 > float3
struct GPUFrameBuffer * default_fb
struct GPUFrameBuffer * color_only_fb
struct GPUTexture * depth
void remove_unused_buffers()
ImBuf * ensure_float_buffer(ImBuf *image_buffer)
void mark_used(const ImBuf *image_buffer)
ShaderParameters sh_params
void mark_all_texture_slots_dirty()
void update_gpu_texture_allocations()
struct IMAGE_InstanceData::@223 passes
void update_image_usage(const ImageUser *image_user)
bool do_tile_drawing
should we perform tiled drawing (wrap repeat).
FloatBufferCache float_buffers
float ss_to_texture[4][4]
Transform matrix to convert a normalized screen space coordinates to texture space.
TextureInfo texture_infos[SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN]
PartialImageUpdater partial_update
struct IMAGE_InstanceData::@222 flags
struct PartialUpdateUser * user
void ensure_image(const Image *new_image)
Ensure that there is a partial update user for the given image.
GPUTexture * texture
GPU Texture for a partial region of the image editor.
bool dirty
does this texture need a full update.
GPUBatch * batch
Batch to draw the associated text on the screen.
rctf clipping_uv_bounds
uv area of the texture in screen space.
rctf clipping_bounds
area of the texture in screen space.
bool visible
Is the texture clipped.
int get_tile_number() const
int get_tile_y_offset() const
int get_tile_x_offset() const
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.
IMAGE_InstanceData * instance_data
Screen space method using a single texture spawning the whole screen.
IMAGE_InstanceData * instance_data
void update_screen_uv_bounds()
OneTextureMethod(IMAGE_InstanceData *instance_data)
void update_screen_uv_bounds(TextureInfo &info)
void update_screen_space_bounds(const ARegion *region)
Update the texture slot uv and screen space bounds.
float4x4 inverted() const