Merge branch 'blender-v3.1-release'

This commit is contained in:
Jeroen Bakker 2022-02-18 08:29:32 +01:00
commit 5c6eefa850
4 changed files with 70 additions and 23 deletions

View File

@ -90,11 +90,10 @@ void CompositorOperation::deinit_execution()
re = nullptr;
}
Image *image = BKE_image_ensure_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result");
BKE_image_partial_update_mark_full_update(image);
BLI_thread_lock(LOCK_DRAW_IMAGE);
BKE_image_signal(G.main,
BKE_image_ensure_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"),
nullptr,
IMA_SIGNAL_FREE);
BKE_image_signal(G.main, image, nullptr, IMA_SIGNAL_FREE);
BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
else {

View File

@ -459,7 +459,7 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD
method.update_screen_uv_bounds();
/* Check for changes in the image user compared to the last time. */
instance_data->update_image_user(iuser);
instance_data->update_image_usage(iuser);
/* Step: Update the GPU textures based on the changes in the image. */
instance_data->update_gpu_texture_allocations();

View File

@ -12,6 +12,7 @@
#include "image_private.hh"
#include "image_shader_params.hh"
#include "image_texture_info.hh"
#include "image_usage.hh"
#include "image_wrappers.hh"
#include "DRW_render.h"
@ -25,8 +26,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;
/** Usage data of the previous time, to identify changes that require a full update. */
ImageUsage last_usage;
PartialImageUpdater partial_update;
@ -95,23 +96,11 @@ struct IMAGE_InstanceData {
}
}
void update_image_user(const ImageUser *image_user)
void update_image_usage(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 > 1) {
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;
ImageUsage usage(image, image_user);
if (last_usage != usage) {
last_usage = usage;
reset_dirty_flag(true);
}
}

View File

@ -0,0 +1,59 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright 2022, Blender Foundation.
*/
/** \file
* \ingroup draw_engine
*/
#pragma once
/**
* ImageUsage contains data of the image and image user to identify changes that require a rebuild
* of the texture slots.
*/
struct ImageUsage {
/** Render pass of the image that is used. */
short pass = 0;
/** Layer of the image that is used.*/
short layer = 0;
/** View of the image that is used. */
short view = 0;
ColorManagedColorspaceSettings colorspace_settings;
/** IMA_ALPHA_* */
char alpha_mode;
ImageUsage() = default;
ImageUsage(const struct Image *image, const struct ImageUser *image_user)
{
pass = image_user ? image_user->pass : 0;
layer = image_user ? image_user->layer : 0;
view = image_user ? image_user->multi_index : 0;
colorspace_settings = image->colorspace_settings;
alpha_mode = image->alpha_mode;
}
bool operator==(const ImageUsage &other) const
{
return memcmp(this, &other, sizeof(ImageUsage)) == 0;
}
bool operator!=(const ImageUsage &other) const
{
return !(*this == other);
}
};