Fix T95725: Changing render slot doesn't update displayed image.

Fixed by checking the requested pass, layer and view against the
previous used one.
This commit is contained in:
Jeroen Bakker 2022-02-14 10:54:21 +01:00
parent ab71d833c7
commit d23cf42ba7
Notes: blender-bot 2023-02-14 03:03:03 +01:00
Referenced by issue #95791, Changing steroscopic view does not result in image viewer update
Referenced by issue #95798, changing the selected render slot's pass results in other render slots randomly changing to something different making it impossible to A/B
Referenced by issue #95725, Changing render slot doesn't update displayed image
2 changed files with 26 additions and 0 deletions

View File

@ -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);

View File

@ -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)