Fix #127479: VSE produces blank scene offscreen renders

If conditions are not met for offscreen rendering, render job is used as
fallback. This can be skipped if there is possibility of race condition.
This was only considered for case where `context->for_render` was false,
since this indicates that call is invoked by the job itself.

If scene strip display is set to `OB_RENDER`, it needs to start the
render job. So variable `do_seq_gl` was renamed to `is_preview` and
reused in race avoidance connditon. This was done to convey clearer
meaning and match comments.

This change does make code less safe - race is avoided by UI not
allowing to run F12 render and opengl render at the same time. However,
I don't think, this could be easily resolved on VSE side without
suspending thread or being able to run multiple render jobs.

Pull Request: https://projects.blender.org/blender/blender/pulls/127926
This commit is contained in:
Richard Antalik
2024-09-27 18:41:26 +02:00
committed by Philipp Oeser
parent db0b1c54d2
commit ee4676a6e5
+4 -4
View File
@@ -1522,8 +1522,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
*/
const bool is_rendering = G.is_rendering;
bool do_seq_gl = !context->for_render && (context->scene->r.seq_prev_type) != OB_RENDER &&
BLI_thread_is_main();
bool is_preview = !context->for_render && (context->scene->r.seq_prev_type) != OB_RENDER;
bool have_comp = false;
bool use_gpencil = true;
@@ -1590,7 +1589,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
is_frame_update = (orig_data.timeline_frame != scene->r.cfra) ||
(orig_data.subframe != scene->r.subframe);
if (sequencer_view3d_fn && do_seq_gl && camera) {
if (sequencer_view3d_fn && is_preview && camera && BLI_thread_is_main()) {
char err_out[256] = "unknown";
int width, height;
BKE_render_resolution(&scene->r, false, &width, &height);
@@ -1646,7 +1645,8 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
* When rendering from command line renderer is called from main thread, in this
* case it's always safe to render scene here
*/
if (!context->for_render && (is_rendering && !G.background)) {
if (is_preview && (is_rendering && !G.background)) {
goto finally;
}