Fix #113280: Incorrect display of Cycles border render while rendering

A regression since d579ac2b3f.

Cycles delays allocation of the render buffers, which makes it impossible
to access effective render resolution during rendering. This was making the
drawing code to fall-back to the full scene resolution with only percentage
and crop accounted for.

This change makes it so an empty ImBuf is used to communicate the render
result resolution. It does not have any pixel buffer associated with it,
which actually matches the behaivor prior to the offending commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/113282
This commit is contained in:
Sergey Sharybin
2023-10-05 15:16:15 +02:00
committed by Sergey Sharybin
parent 730bb2ee3e
commit ba767610cf

View File

@@ -4385,13 +4385,18 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
}
}
/* Put an empty image buffer to the cache so that the Image.has_data detects that some data
* has been loaded for this Image data-block.
/* Put an empty image buffer to the cache. This allows to achieve the following:
*
* 1. It makes it so the generic logic in the #BKE_image_has_loaded_ibuf proeprly detects that
* an Image used to dusplay render result has loaded image buffer.
*
* Surely there are all the design questions about scene-dependent Render Result image
* data-block, and the behavior of the flag dependent on whether the Render Result image was ever
* shown on screen. The purpose of this code is to preserve the Python API behavior to the level
* prior to the #RenderResult refactor to use #ImBuf which happened for Blender 4.0. */
* prior to the #RenderResult refactor to use #ImBuf which happened for Blender 4.0.
*
* 2. Provides an image buffer which can be used to communicate the render resolution (with
* possible border render applied to it) prior to the actual pixels storage is allocated. */
if (ima->cache == nullptr) {
ImBuf *empty_ibuf = IMB_allocImBuf(0, 0, 0, 0);
image_assign_ibuf(ima, empty_ibuf, IMA_NO_INDEX, 0);
@@ -4411,6 +4416,15 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
IMB_refImBuf(pass_ibuf);
}
else {
pass_ibuf = image_get_cached_ibuf_for_index_entry(ima, IMA_NO_INDEX, 0, nullptr);
/* Assign the current render resolution to the image buffer.
* The actual storage is still empty. The intended use is to merely communicate the actual
* render resolution prior to render border is "un-cropped". */
pass_ibuf->x = rres.rectx;
pass_ibuf->y = rres.recty;
}
return pass_ibuf;
}