[Bf-blender-cvs] [1d30d3d57eb] temp-gpu-image-engine: Merge branch 'master' into temp-gpu-image-engine

Jeroen Bakker noreply at git.blender.org
Tue Dec 7 10:51:26 CET 2021


Commit: 1d30d3d57eb7c5899759e0067898048a00e550ae
Author: Jeroen Bakker
Date:   Tue Dec 7 10:51:16 2021 +0100
Branches: temp-gpu-image-engine
https://developer.blender.org/rB1d30d3d57eb7c5899759e0067898048a00e550ae

Merge branch 'master' into temp-gpu-image-engine

===================================================================



===================================================================

diff --cc source/blender/blenkernel/BKE_image.h
index cc61f87e259,4db6da4b3ea..0d1ebbf0dc9
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@@ -377,19 -505,33 +507,40 @@@ struct GPUTexture *BKE_image_get_gpu_ti
  struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image,
                                               struct ImageUser *iuser,
                                               struct ImBuf *ibuf);
+ /**
+  * Is the alpha of the `GPUTexture` for a given image/ibuf premultiplied.
+  */
  bool BKE_image_has_gpu_texture_premultiplied_alpha(struct Image *image, struct ImBuf *ibuf);
++
+ /**
+  * Partial update of texture for texture painting.
+  * This is often much quicker than fully updating the texture for high resolution images.
+  */
  void BKE_image_update_gputexture(
      struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
+ /**
+  * Mark areas on the #GPUTexture that needs to be updated. The areas are marked in chunks.
+  * The next time the #GPUTexture is used these tiles will be refreshes. This saves time
+  * when writing to the same place multiple times This happens for during foreground rendering.
+  */
 -void BKE_image_update_gputexture_delayed(
 -    struct Image *ima, struct ImBuf *ibuf, int x, int y, int w, int h);
 +void BKE_image_update_gputexture_delayed(struct Image *ima,
 +                                         struct ImageTile *image_tile,
 +                                         struct ImBuf *ibuf,
 +                                         int x,
 +                                         int y,
 +                                         int w,
 +                                         int h);
++
+ /**
+  * Called on entering and exiting texture paint mode,
+  * temporary disabling/enabling mipmapping on all images for quick texture
+  * updates with glTexSubImage2D. images that didn't change don't have to be re-uploaded to OpenGL.
+  */
  void BKE_image_paint_set_mipmap(struct Main *bmain, bool mipmap);
  
- /* Delayed free of OpenGL buffers by main thread */
+ /**
+  * Delayed free of OpenGL buffers by main thread.
+  */
  void BKE_image_free_unused_gpu_textures(void);
  
  struct RenderSlot *BKE_image_add_renderslot(struct Image *ima, const char *name);
diff --cc source/blender/blenkernel/intern/image_gpu.cc
index 070b6eb2a89,8b1441f812c..07e6ec90843
--- a/source/blender/blenkernel/intern/image_gpu.cc
+++ b/source/blender/blenkernel/intern/image_gpu.cc
@@@ -58,7 -53,14 +58,6 @@@ static void image_free_gpu_limited_scal
  static void image_update_gputexture_ex(
      Image *ima, ImageTile *tile, ImBuf *ibuf, int x, int y, int w, int h);
  
- /* Is the alpha of the `GPUTexture` for a given image/ibuf premultiplied. */
 -/* Internal structs. */
 -#define IMA_PARTIAL_REFRESH_TILE_SIZE 256
 -struct ImagePartialRefresh {
 -  struct ImagePartialRefresh *next, *prev;
 -  int tile_x;
 -  int tile_y;
 -};
 -
  bool BKE_image_has_gpu_texture_premultiplied_alpha(Image *image, ImBuf *ibuf)
  {
    if (image) {
@@@ -928,13 -899,16 +926,11 @@@ static void image_update_gputexture_ex
    }
  }
  
- /* Partial update of texture for texture painting. This is often much
-  * quicker than fully updating the texture for high resolution images. */
  void BKE_image_update_gputexture(Image *ima, ImageUser *iuser, int x, int y, int w, int h)
  {
 +  ImageTile *image_tile = BKE_image_get_tile_from_iuser(ima, iuser);
    ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, nullptr);
 -  ImageTile *tile = BKE_image_get_tile_from_iuser(ima, iuser);
 -
 -  if ((ibuf == nullptr) || (w == 0) || (h == 0)) {
 -    /* Full reload of texture. */
 -    BKE_image_free_gputextures(ima);
 -  }
 -  image_update_gputexture_ex(ima, tile, ibuf, x, y, w, h);
 +  BKE_image_update_gputexture_delayed(ima, image_tile, ibuf, x, y, w, h);
    BKE_image_release_ibuf(ima, ibuf, nullptr);
  }



More information about the Bf-blender-cvs mailing list