Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2022-01-28 10:37:12 +0300
committerJeroen Bakker <jeroen@blender.org>2022-01-28 10:37:45 +0300
commitbdd74e1e9338b18e4f80458f284d0c6a4d100f30 (patch)
tree86daecf79b6a9d0896482d7fe8d85da9a6becc81 /source/blender/draw/engines/image/image_space_node.hh
parent0a32ac02e976a4723802ed09bed64c0625e889a2 (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_node.hh')
-rw-r--r--source/blender/draw/engines/image/image_space_node.hh51
1 files changed, 26 insertions, 25 deletions
diff --git a/source/blender/draw/engines/image/image_space_node.hh b/source/blender/draw/engines/image/image_space_node.hh
index 3ca18eec742..1ce8fdeb0f3 100644
--- a/source/blender/draw/engines/image/image_space_node.hh
+++ b/source/blender/draw/engines/image/image_space_node.hh
@@ -54,20 +54,6 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
BKE_image_release_ibuf(image, ibuf, lock);
}
- bool has_view_override() const override
- {
- return true;
- }
-
- DRWView *create_view_override(const ARegion *region) override
- {
- /* Setup a screen pixel view. The backdrop of the node editor doesn't follow the region. */
- float winmat[4][4], viewmat[4][4];
- orthographic_m4(viewmat, 0.0, region->winx, 0.0, region->winy, 0.0, 1.0);
- unit_m4(winmat);
- return DRW_view_create(viewmat, winmat, nullptr, nullptr, nullptr);
- }
-
void get_shader_parameters(ShaderParameters &r_shader_parameters,
ImBuf *ibuf,
bool UNUSED(is_tiled)) override
@@ -120,18 +106,33 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
*r_tex_tile_data = nullptr;
}
- void get_image_mat(const ImBuf *image_buffer,
- const ARegion *region,
- float r_mat[4][4]) const override
+ bool use_tile_drawing() const override
+ {
+ return false;
+ }
+
+ /**
+ * The backdrop of the node editor isn't drawn in screen space UV space. But is locked with the
+ * screen.
+ */
+ void init_ss_to_texture_matrix(const ARegion *region,
+ const float image_resolution[2],
+ float r_uv_to_texture[4][4]) const override
{
- unit_m4(r_mat);
- const float ibuf_width = image_buffer->x;
- const float ibuf_height = image_buffer->y;
-
- r_mat[0][0] = ibuf_width * snode->zoom;
- r_mat[1][1] = ibuf_height * snode->zoom;
- r_mat[3][0] = (region->winx - snode->zoom * ibuf_width) / 2 + snode->xof;
- r_mat[3][1] = (region->winy - snode->zoom * ibuf_height) / 2 + snode->yof;
+ unit_m4(r_uv_to_texture);
+ float display_resolution[2];
+ mul_v2_v2fl(display_resolution, image_resolution, snode->zoom);
+ const float scale_x = display_resolution[0] / region->winx;
+ const float scale_y = display_resolution[1] / region->winy;
+ const float translate_x = ((region->winx - display_resolution[0]) * 0.5f + snode->xof) /
+ region->winx;
+ const float translate_y = ((region->winy - display_resolution[1]) * 0.5f + snode->yof) /
+ region->winy;
+
+ 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;
}
};