From df4ef8dface5c91ae2697c33e2fa63251659a912 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Thu, 5 Nov 2020 10:41:24 +0000 Subject: [PATCH] Batching - use legacy path for antialiased polys. Antialiased polys work by drawing a smoothed line around the poly after the main drawing. Batching draws polys as a series of triangles with no concept of 'edge', and when 2 polys are joined it becomes impractical to back calculate the edges from the triangles. For this reason batching is disabled for antialiased polys in this PR. --- .../gles_common/rasterizer_canvas_batcher.h | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index c61d856e0d1..4054fcd29c0 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -2160,28 +2160,38 @@ PREAMBLE(bool)::prefill_joined_item(FillState &r_fill_state, int &r_command_star case RasterizerCanvas::Item::Command::TYPE_POLYGON: { - // not using software skinning? - if (!bdata.settings_use_software_skinning && get_this()->state.using_skeleton) { + RasterizerCanvas::Item::CommandPolygon *polygon = static_cast(command); +#ifdef GLES_OVER_GL + // anti aliasing not accelerated .. it is problematic because it requires a 2nd line drawn around the outside of each + // poly, which would require either a second list of indices or a second list of vertices for this step + if (polygon->antialiased) { // not accelerated _prefill_default_batch(r_fill_state, command_num, *p_item); } else { - RasterizerCanvas::Item::CommandPolygon *polygon = static_cast(command); - - // unoptimized - could this be done once per batch / batch texture? - bool send_light_angles = polygon->normal_map != RID(); - - bool buffer_full = false; - - if (send_light_angles) { - // NYI +#endif + // not using software skinning? + if (!bdata.settings_use_software_skinning && get_this()->state.using_skeleton) { + // not accelerated _prefill_default_batch(r_fill_state, command_num, *p_item); - //buffer_full = prefill_polygon(polygon, r_fill_state, r_command_start, command_num, command_count, p_item, multiply_final_modulate); - } else - buffer_full = _prefill_polygon(polygon, r_fill_state, r_command_start, command_num, command_count, p_item, multiply_final_modulate); + } else { + // unoptimized - could this be done once per batch / batch texture? + bool send_light_angles = polygon->normal_map != RID(); - if (buffer_full) - return true; - } // using software skinning path + bool buffer_full = false; + + if (send_light_angles) { + // NYI + _prefill_default_batch(r_fill_state, command_num, *p_item); + //buffer_full = prefill_polygon(polygon, r_fill_state, r_command_start, command_num, command_count, p_item, multiply_final_modulate); + } else + buffer_full = _prefill_polygon(polygon, r_fill_state, r_command_start, command_num, command_count, p_item, multiply_final_modulate); + + if (buffer_full) + return true; + } // if not using hardware skinning path +#ifdef GLES_OVER_GL + } // if not anti-aliased poly +#endif } break; } @@ -2897,18 +2907,19 @@ PREAMBLE(bool)::_detect_item_batch_break(RenderItemState &r_ris, RasterizerCanva } } break; case RasterizerCanvas::Item::Command::TYPE_POLYGON: { - //return true; // only allow polygons to join if they aren't skeleton RasterizerCanvas::Item::CommandPolygon *poly = static_cast(command); - // return true; +#ifdef GLES_OVER_GL + // anti aliasing not accelerated + if (poly->antialiased) + return true; +#endif // light angles not yet implemented, treat as default if (poly->normal_map != RID()) return true; - // we could possibly join polygons that are software skinned? NYI - if (!get_this()->bdata.settings_use_software_skinning && poly->bones.size()) return true;