Merge pull request #70924 from clayjohn/canvas-bg-bugs

Always try to clear render target before drawing 3D with Canvas BG mode
This commit is contained in:
Rémi Verschelde 2023-01-05 12:57:39 +01:00
commit 0668b64c32
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -496,6 +496,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
} }
if (scenario_draw_canvas_bg && canvas_map.begin() && canvas_map.begin()->key.get_layer() > scenario_canvas_max_layer) { if (scenario_draw_canvas_bg && canvas_map.begin() && canvas_map.begin()->key.get_layer() > scenario_canvas_max_layer) {
// There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn.
// Clear now otherwise we copy over garbage from the render target.
RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target);
if (!can_draw_3d) { if (!can_draw_3d) {
RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else { } else {
@ -536,6 +539,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
} }
if (scenario_draw_canvas_bg && E.key.get_layer() >= scenario_canvas_max_layer) { if (scenario_draw_canvas_bg && E.key.get_layer() >= scenario_canvas_max_layer) {
// There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn.
// Clear now otherwise we copy over garbage from the render target.
RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target);
if (!can_draw_3d) { if (!can_draw_3d) {
RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else { } else {
@ -547,12 +553,12 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
} }
if (scenario_draw_canvas_bg) { if (scenario_draw_canvas_bg) {
if (!can_draw_3d) {
RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
// There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn. // There may be an outstanding clear request if a clear was requested, but no 2D elements were drawn.
// Clear now otherwise we copy over garbage from the render target. // Clear now otherwise we copy over garbage from the render target.
RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target); RSG::texture_storage->render_target_do_clear_request(p_viewport->render_target);
if (!can_draw_3d) {
RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas);
} else {
_draw_3d(p_viewport); _draw_3d(p_viewport);
} }
} }