diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-12-18 11:15:55 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-12-18 11:18:44 +0300 |
commit | 4f9e21bdc9772603acc0ba6727da9dd67287ac0f (patch) | |
tree | 4fbfce2561953060be0bca60aed073f71ad1eed2 /source/blender/blenkernel/intern/image.c | |
parent | 095b69361403bacd322172d6293b0faeee40b44e (diff) |
Fix T82591: Performance regression when rendering at very high resolution
This patch introduces a partial update of GPUTexture. When rendering
a large image the GPUTexture could have been scaled. The old implementation
would rescale the image on CPU and create a new GPUTexture. This
resulted in flooding the PCI bus.
The new solution would only scale and upload the parts of the GPUTexture
that has been changed. It does this by keeping track of areas of 256x256
pixels. When something changes the tiles that cover that changes will be
rescaled and uploaded the next time the GPUTexture is requested.
Test situation: Default Cube, 4 samples, 19200x10800 tile size 512.
Blender 2.83.9: 4m27s.
Blender 2.91: 20+m (regression)
This patch: 1m01s.
There is still room for more optimizations:
* Reduce the time that an image is locked.
** Use task scheduling to update the tiles of an image.
** Generic optimization of the ImBuf scale method.
Maniphest Tasks: T82591
Differential Revision: https://developer.blender.org/D9591
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 228aed265cf..d1c6b552d2e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -190,6 +190,7 @@ static void image_free_data(ID *id) BKE_previewimg_free(&image->preview); BLI_freelistN(&image->tiles); + BLI_freelistN(&image->gpu_refresh_areas); } static void image_foreach_cache(ID *id, @@ -298,6 +299,8 @@ static void image_blend_read_data(BlendDataReader *reader, ID *id) LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { tile->ok = IMA_OK; } + ima->gpuflag = 0; + BLI_listbase_clear(&ima->gpu_refresh_areas); } static void image_blend_read_lib(BlendLibReader *UNUSED(reader), ID *id) @@ -3897,6 +3900,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; } /* set proper views */ |