Merge branch 'blender-v3.1-release'

This commit is contained in:
Jeroen Bakker 2022-02-14 11:00:30 +01:00
commit 48e2bf3638
8 changed files with 35 additions and 20 deletions

View File

@ -4361,7 +4361,7 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima)
}
else {
rr = BKE_image_get_renderslot(ima, ima->render_slot)->render;
ima->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(ima);
}
/* set proper views */
@ -5729,7 +5729,7 @@ void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
/* NOTE: a single texture and refresh doesn't really work when
* multiple image users may use different frames, this is to
* be improved with perhaps a GPU texture cache. */
ima->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(ima);
ima->gpuframenr = iuser->framenr;
}

View File

@ -389,18 +389,9 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
ima->gpu_pass = requested_pass;
ima->gpu_layer = requested_layer;
ima->gpu_view = requested_view;
ima->gpuflag |= IMA_GPU_REFRESH;
}
#undef GPU_FLAGS_TO_CHECK
/* TODO(jbakker): We should replace the IMA_GPU_REFRESH flag with a call to
* BKE_image-partial_update_mark_full_update. Although the flag is quicker it leads to double
* administration. */
if ((ima->gpuflag & IMA_GPU_REFRESH) != 0) {
BKE_image_partial_update_mark_full_update(ima);
ima->gpuflag &= ~IMA_GPU_REFRESH;
}
if (ima->runtime.partial_update_user == nullptr) {
ima->runtime.partial_update_user = BKE_image_partial_update_create(ima);
}

View File

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

View File

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

View File

@ -512,7 +512,7 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
}
BKE_image_release_ibuf(oglrender->ima, ibuf, lock);
oglrender->ima->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(oglrender->ima);
if (oglrender->write_still) {
screen_opengl_render_write(oglrender);

View File

@ -388,7 +388,7 @@ bool ED_image_slot_cycle(struct Image *image, int direction)
}
if ((cur != image->render_slot)) {
image->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(image);
}
return (cur != image->render_slot);
}

View File

@ -237,15 +237,13 @@ enum {
/* Image.gpuflag */
enum {
/** GPU texture needs to be refreshed. */
IMA_GPU_REFRESH = (1 << 0),
/** All mipmap levels in OpenGL texture set? */
IMA_GPU_MIPMAP_COMPLETE = (1 << 1),
IMA_GPU_MIPMAP_COMPLETE = (1 << 0),
/* Reuse the max resolution textures as they fit in the limited scale. */
IMA_GPU_REUSE_MAX_RESOLUTION = (1 << 2),
IMA_GPU_REUSE_MAX_RESOLUTION = (1 << 1),
/* Has any limited scale textures been allocated.
* Adds additional checks to reuse max resolution images when they fit inside limited scale. */
IMA_GPU_HAS_LIMITED_SCALE_TEXTURES = (1 << 3),
IMA_GPU_HAS_LIMITED_SCALE_TEXTURES = (1 << 2),
};
/* Image.source, where the image comes from */

View File

@ -594,7 +594,7 @@ static void rna_render_slots_active_set(PointerRNA *ptr,
int index = BLI_findindex(&image->renderslots, slot);
if (index != -1) {
image->render_slot = index;
image->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(image);
}
}
}
@ -610,7 +610,7 @@ static void rna_render_slots_active_index_set(PointerRNA *ptr, int value)
Image *image = (Image *)ptr->owner_id;
int num_slots = BLI_listbase_count(&image->renderslots);
image->render_slot = value;
image->gpuflag |= IMA_GPU_REFRESH;
BKE_image_partial_update_mark_full_update(image);
CLAMP(image->render_slot, 0, num_slots - 1);
}