Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2022-05-06 17:13:57 +0300
committerJeroen Bakker <jeroen@blender.org>2022-05-06 17:17:39 +0300
commita7417ba84527d57391599d26a1872c035c5e2c48 (patch)
treee6d31f888582dd30b97285ee47754ba9c959a79c /source/blender/draw/engines/image
parentacafc7327ec94358d7b9599a153c509989b809ed (diff)
DrawManager: Make instance data persistent.
When resizing a viewport all engine instance data was cleared. This wasn't the intended design and lead to performance regressions in the image engine. This patch makes sure that the instance data isn't cleared when the viewport size changes. When using instance data, draw engines are responsible to update the textures accordingly. This could also reduce flickering/stalling when resizing the viewport in eevee-next. Fixes T95428. Reviewed By: fclem Maniphest Tasks: T95428 Differential Revision: https://developer.blender.org/D14874
Diffstat (limited to 'source/blender/draw/engines/image')
-rw-r--r--source/blender/draw/engines/image/image_instance_data.hh6
-rw-r--r--source/blender/draw/engines/image/image_texture_info.hh2
2 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/draw/engines/image/image_instance_data.hh b/source/blender/draw/engines/image/image_instance_data.hh
index cb84c7f14ad..358e6fd3bd9 100644
--- a/source/blender/draw/engines/image/image_instance_data.hh
+++ b/source/blender/draw/engines/image/image_instance_data.hh
@@ -75,8 +75,10 @@ struct IMAGE_InstanceData {
TextureInfo &info = texture_infos[i];
const bool is_allocated = info.texture != nullptr;
const bool is_visible = info.visible;
- const bool should_be_freed = !is_visible && is_allocated;
- const bool should_be_created = is_visible && !is_allocated;
+ const bool resolution_changed = assign_if_different(info.last_viewport_size,
+ float2(DRW_viewport_size_get()));
+ const bool should_be_freed = is_allocated && (!is_visible || resolution_changed);
+ const bool should_be_created = is_visible && (!is_allocated || resolution_changed);
if (should_be_freed) {
GPU_texture_free(info.texture);
diff --git a/source/blender/draw/engines/image/image_texture_info.hh b/source/blender/draw/engines/image/image_texture_info.hh
index cd51cdaff3c..9a75941c533 100644
--- a/source/blender/draw/engines/image/image_texture_info.hh
+++ b/source/blender/draw/engines/image/image_texture_info.hh
@@ -46,6 +46,8 @@ struct TextureInfo {
*/
GPUTexture *texture;
+ float2 last_viewport_size = float2(0.0f, 0.0f);
+
~TextureInfo()
{
if (batch != nullptr) {