From 4f9e21bdc9772603acc0ba6727da9dd67287ac0f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 18 Dec 2020 09:15:55 +0100 Subject: 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 --- source/blender/blenkernel/BKE_image.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/BKE_image.h') diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 303945dbf64..c51a5f7e5e1 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -382,6 +382,8 @@ struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image, bool BKE_image_has_gpu_texture_premultiplied_alpha(struct Image *image, struct ImBuf *ibuf); void BKE_image_update_gputexture( struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h); +void BKE_image_update_gputexture_delayed( + struct Image *ima, struct ImBuf *ibuf, int x, int y, int w, int h); void BKE_image_paint_set_mipmap(struct Main *bmain, bool mipmap); /* Delayed free of OpenGL buffers by main thread */ -- cgit v1.2.3