VSE: speedup RE_render_result_rect_from_ibuf by avoiding memory clear

The RE_render_result_rect_from_ibuf function (used only by VSE) was
allocating memory for the render result, clearing it to zero and
immediately overwriting it with the image pixel data. Remove the
"clear to zero" part.

Rendering a 1920x1080 resolution movie with VSE (using float
pixel data), average RE_render_result_rect_from_ibuf time goes from
6.8ms down to 3.8ms

Pull Request: https://projects.blender.org/blender/blender/pulls/135170
This commit is contained in:
Aras Pranckevicius
2025-02-26 16:17:48 +01:00
committed by Aras Pranckevicius
parent 34d4384966
commit d64aa0112f

View File

@@ -1149,7 +1149,8 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr, const ImBuf *ibuf, const
rr->have_combined = true;
if (!rv_ibuf->float_buffer.data) {
float *data = MEM_cnew_array<float>(4 * rr->rectx * rr->recty, "render_seq rectf");
float *data = static_cast<float *>(
MEM_malloc_arrayN(rr->rectx * rr->recty, sizeof(float[4]), "render_seq float"));
IMB_assign_float_buffer(rv_ibuf, data, IB_TAKE_OWNERSHIP);
}
@@ -1165,7 +1166,8 @@ void RE_render_result_rect_from_ibuf(RenderResult *rr, const ImBuf *ibuf, const
rr->have_combined = true;
if (!rv_ibuf->byte_buffer.data) {
uint8_t *data = MEM_cnew_array<uint8_t>(4 * rr->rectx * rr->recty, "render_seq rect");
uint8_t *data = static_cast<uint8_t *>(
MEM_malloc_arrayN(rr->rectx * rr->recty, sizeof(uint8_t[4]), "render_seq byte"));
IMB_assign_byte_buffer(rv_ibuf, data, IB_TAKE_OWNERSHIP);
}