diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-02-14 13:00:30 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-02-14 13:00:30 +0300 |
commit | 48e2bf3638e1d96d8cbfbc74d29c347ccfcad576 (patch) | |
tree | d40cb6b120a2a0718f68199556760c4398461fd2 /source/blender/draw/engines/image | |
parent | efac4db166292229e4e2ab7afa6034d637893bd6 (diff) | |
parent | 1236d2aea8d55c7d98409fc76968bad297a53007 (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source/blender/draw/engines/image')
-rw-r--r-- | source/blender/draw/engines/image/image_drawing_mode.hh | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/image/image_instance_data.hh | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index d0dbc799c31..b3d6c3abd18 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -458,6 +458,9 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD method.update_screen_space_bounds(region); method.update_screen_uv_bounds(); + /* Check for changes in the image user compared to the last time. */ + instance_data->update_image_user(iuser); + /* Step: Update the GPU textures based on the changes in the image. */ instance_data->update_gpu_texture_allocations(); update_textures(*instance_data, image, iuser); diff --git a/source/blender/draw/engines/image/image_instance_data.hh b/source/blender/draw/engines/image/image_instance_data.hh index dde313d63f8..ec6290ae8de 100644 --- a/source/blender/draw/engines/image/image_instance_data.hh +++ b/source/blender/draw/engines/image/image_instance_data.hh @@ -25,6 +25,8 @@ constexpr int SCREEN_SPACE_DRAWING_MODE_TEXTURE_LEN = 1; struct IMAGE_InstanceData { struct Image *image; + /** Copy of the last image user to detect iuser differences that require a full update. */ + struct ImageUser last_image_user; PartialImageUpdater partial_update; @@ -93,6 +95,27 @@ struct IMAGE_InstanceData { } } + void update_image_user(const ImageUser *image_user) + { + short requested_pass = image_user ? image_user->pass : 0; + short requested_layer = image_user ? image_user->layer : 0; + short requested_view = image_user ? image_user->multi_index : 0; + /* There is room for 2 multiview textures. When a higher number is requested we should always + * target the first view slot. This is fine as multi view images aren't used together. */ + if (requested_view < 2) { + requested_view = 0; + } + + if (last_image_user.pass != requested_pass || last_image_user.layer != requested_layer || + last_image_user.multi_index != requested_view) { + + last_image_user.pass = requested_pass; + last_image_user.layer = requested_layer; + last_image_user.multi_index = requested_view; + reset_dirty_flag(true); + } + } + private: /** \brief Set dirty flag of all texture slots to the given value. */ void reset_dirty_flag(bool new_value) |