diff options
-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 0aaf0ca9f24..0c638ef15c2 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -474,6 +474,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 77b771a9110..a2367c687b5 100644 --- a/source/blender/draw/engines/image/image_instance_data.hh +++ b/source/blender/draw/engines/image/image_instance_data.hh @@ -40,6 +40,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; @@ -108,6 +110,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) |