diff options
author | Jeroen Bakker <jbakker> | 2022-01-28 10:37:12 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-28 10:37:45 +0300 |
commit | bdd74e1e9338b18e4f80458f284d0c6a4d100f30 (patch) | |
tree | 86daecf79b6a9d0896482d7fe8d85da9a6becc81 /source/blender/draw/engines/image/image_space_image.hh | |
parent | 0a32ac02e976a4723802ed09bed64c0625e889a2 (diff) |
DrawManager: Image engine support huge images.
Adding better support for drawing huge images in the image/uv editor. Also solved tearing artifacts.
The approach is that for each image/uv editor a screen space gpu texture is created that only contains
the visible pixels. When zooming or panning the gpu texture is rebuild.
Although the solution isn't memory intensive other parts of blender memory usage scales together with
the image size.
* Due to complexity we didn't implement partial updates when drawing images tiled (wrap repeat).
This could be added, but is complicated as a change in the source could mean many different
changes on the GPU texture. The work around for now is to tag all gpu textures to be dirty when
changes are detected.
Original plan was to have 4 screen space images to support panning without gpu texture creation.
For now we don't see the need to implement it as the solution is already fast. Especially when
GPU memory is shared with CPU ram.
Reviewed By: fclem
Maniphest Tasks: T92525, T92903
Differential Revision: https://developer.blender.org/D13424
Diffstat (limited to 'source/blender/draw/engines/image/image_space_image.hh')
-rw-r--r-- | source/blender/draw/engines/image/image_space_image.hh | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/draw/engines/image/image_space_image.hh b/source/blender/draw/engines/image/image_space_image.hh index 7728a963254..900ac57c652 100644 --- a/source/blender/draw/engines/image/image_space_image.hh +++ b/source/blender/draw/engines/image/image_space_image.hh @@ -61,7 +61,6 @@ class SpaceImageAccessor : public AbstractSpaceAccessor { const int sima_flag = sima->flag & ED_space_image_get_display_channel_mask(image_buffer); const bool do_repeat = (!is_tiled) && ((sima->flag & SI_DRAW_TILE) != 0); SET_FLAG_FROM_TEST(r_shader_parameters.flags, do_repeat, IMAGE_DRAW_FLAG_DO_REPEAT); - SET_FLAG_FROM_TEST(r_shader_parameters.flags, is_tiled, IMAGE_DRAW_FLAG_USE_WORLD_POS); if ((sima_flag & SI_USE_ALPHA) != 0) { /* Show RGBA */ r_shader_parameters.flags |= IMAGE_DRAW_FLAG_SHOW_ALPHA | IMAGE_DRAW_FLAG_APPLY_ALPHA; @@ -102,15 +101,6 @@ class SpaceImageAccessor : public AbstractSpaceAccessor { } } - bool has_view_override() const override - { - return false; - } - DRWView *create_view_override(const ARegion *UNUSED(region)) override - { - return nullptr; - } - void get_gpu_textures(Image *image, ImageUser *iuser, ImBuf *image_buffer, @@ -171,11 +161,25 @@ class SpaceImageAccessor : public AbstractSpaceAccessor { } } - void get_image_mat(const ImBuf *UNUSED(image_buffer), - const ARegion *UNUSED(region), - float r_mat[4][4]) const override + bool use_tile_drawing() const override + { + return (sima->flag & SI_DRAW_TILE) != 0; + } + + void init_ss_to_texture_matrix(const ARegion *region, + const float UNUSED(image_resolution[2]), + float r_uv_to_texture[4][4]) const override { - unit_m4(r_mat); + unit_m4(r_uv_to_texture); + float scale_x = 1.0 / BLI_rctf_size_x(®ion->v2d.cur); + float scale_y = 1.0 / BLI_rctf_size_y(®ion->v2d.cur); + float translate_x = scale_x * -region->v2d.cur.xmin; + float translate_y = scale_y * -region->v2d.cur.ymin; + + r_uv_to_texture[0][0] = scale_x; + r_uv_to_texture[1][1] = scale_y; + r_uv_to_texture[3][0] = translate_x; + r_uv_to_texture[3][1] = translate_y; } }; |