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 <jeroen@blender.org>2022-01-28 10:05:31 +0300
committerJeroen Bakker <jeroen@blender.org>2022-01-28 10:06:19 +0300
commit0a32ac02e976a4723802ed09bed64c0625e889a2 (patch)
treeb452db75593f8adbce4c49e6449530ab0bdf9b1d /source/blender/blenkernel/BKE_image.h
parent1e0758333d3a8c929772250b67b61f42b6e18882 (diff)
Image: Partial Update Redesign.
This patch reimplements the image partial updates. Biggest design motivation for the redesign is that currently GPUTextures must be owned by the image. This reduces flexibility and adds complexity to a single component especially when we want to have different structures. The new design is not limited to GPUTextures and can also be used by reducing overhead in image operations like scaling. Or partial image updating in Cycles. The usecase in hand is that we want to support virtual images in the image editor so we can work with images that don't fit in a single GPUTexture. Using `BKE_image_partial_update_mark_region` or `BKE_image_partial_update_mark_full_update` a part of an image can be marked as dirty. These regions are stored per ImageTile (UDIM). When a part of the code wants to receive partial changes it needs to construct a `PartialUpdateUser` by calling `BKE_image_partial_update_create`. As long as this instance is kept alive the changes can be received. When a user wants to update its own data it will call `BKE_image_partial_update_collect_changes` This will collect the changes since the last time the user called this function. When the partial changes are available the partial change can be read by calling `BKE_image_partial_update_get_next_change` It can happen that the introduced mechanism doesn't have the data anymore to construct the changes since the last time a PartialUpdateUser requested it. In this case it will get a request to perform a full update. Maniphest Tasks: T92613 Differential Revision: https://developer.blender.org/D13238
Diffstat (limited to 'source/blender/blenkernel/BKE_image.h')
-rw-r--r--source/blender/blenkernel/BKE_image.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 80c6b155be0..598818ba3c0 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -24,6 +24,8 @@
#include "BLI_utildefines.h"
+#include "BLI_rect.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -561,19 +563,27 @@ struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image,
* 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
@@ -591,6 +601,32 @@ bool BKE_image_remove_renderslot(struct Image *ima, struct ImageUser *iuser, int
struct RenderSlot *BKE_image_get_renderslot(struct Image *ima, int index);
bool BKE_image_clear_renderslot(struct Image *ima, struct ImageUser *iuser, int slot);
+/* --- image_partial_update.cc --- */
+/** Image partial updates. */
+struct PartialUpdateUser;
+
+/**
+ * \brief Create a new PartialUpdateUser. An Object that contains data to use partial updates.
+ */
+struct PartialUpdateUser *BKE_image_partial_update_create(const struct Image *image);
+
+/**
+ * \brief free a partial update user.
+ */
+void BKE_image_partial_update_free(struct PartialUpdateUser *user);
+
+/* --- partial updater (image side) --- */
+struct PartialUpdateRegister;
+
+void BKE_image_partial_update_register_free(struct Image *image);
+/** \brief Mark a region of the image to update. */
+void BKE_image_partial_update_mark_region(struct Image *image,
+ const struct ImageTile *image_tile,
+ const struct ImBuf *image_buffer,
+ const rcti *updated_region);
+/** \brief Mark the whole image to be updated. */
+void BKE_image_partial_update_mark_full_update(struct Image *image);
+
#ifdef __cplusplus
}
#endif