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>2020-01-27 18:28:55 +0300
committerJeroen Bakker <jeroen@blender.org>2020-01-29 17:07:45 +0300
commit18c88eac171a814f94142d442494ea6f5eeeab02 (patch)
tree9a5fbc81db038a3d322b818e520d93c520e7da1e /source/blender/gpu/intern/gpu_draw.c
parentb683fcb62876f345a49bf66c94781a6fa789b946 (diff)
Fix T73188: RenderResult as Camera BG Image
In blender 2.79 you could use a render result as a camera background image. This is useful during layout/compositing. During Blender 2.80 development there were 2 issues introduced that removed this feature. * to receive a render result the image required a lock. This lock wasn't passed and therefore no image was read from the result. Generating an GPUTexture from an Blender image also didn't do the locking. * the iuser->scene field wasn't set what is required for render results. This change adds an optional `ibuf` parameter to `GPU_texture_from_blender` that can be passed when available. Reviewed By: fclem, brecht Differential Revision: https://developer.blender.org/D6684
Diffstat (limited to 'source/blender/gpu/intern/gpu_draw.c')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index d2008680098..cfeb7f6bedb 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -851,7 +851,11 @@ static void gpu_texture_update_from_ibuf(
GPU_texture_unbind(tex);
}
-GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget)
+/* Get the GPUTexture for a given `Image`.
+ *
+ * `iuser` and `ibuf` are mutual exclusive parameters. The caller can pass the `ibuf` when already
+ * available. It is also required when requesting the GPUTexture for a render result. */
+GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, ImBuf *ibuf, int textarget)
{
if (ima == NULL) {
return NULL;
@@ -882,27 +886,33 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
}
/* check if we have a valid image buffer */
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if (ibuf == NULL) {
- *tex = GPU_texture_from_bindcode(textarget, bindcode);
- return *tex;
+ ImBuf *ibuf_intern = ibuf;
+ if (ibuf_intern == NULL) {
+ ibuf_intern = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ if (ibuf_intern == NULL) {
+ *tex = GPU_texture_from_bindcode(textarget, bindcode);
+ return *tex;
+ }
}
if (textarget == GL_TEXTURE_2D_ARRAY) {
- bindcode = gpu_texture_create_tile_array(ima, ibuf);
+ bindcode = gpu_texture_create_tile_array(ima, ibuf_intern);
}
else if (textarget == GL_TEXTURE_1D_ARRAY) {
bindcode = gpu_texture_create_tile_mapping(ima);
}
else {
- bindcode = gpu_texture_create_from_ibuf(ima, ibuf, textarget);
+ bindcode = gpu_texture_create_from_ibuf(ima, ibuf_intern, textarget);
}
- BKE_image_release_ibuf(ima, ibuf, NULL);
+ /* if `ibuf` was given, we don't own the `ibuf_intern` */
+ if (ibuf == NULL) {
+ BKE_image_release_ibuf(ima, ibuf_intern, NULL);
+ }
*tex = GPU_texture_from_bindcode(textarget, bindcode);
- GPU_texture_orig_size_set(*tex, ibuf->x, ibuf->y);
+ GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
return *tex;
}