From 0d8038568749f4174ca79bc6480914cbdef0c325 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Wed, 17 Mar 2021 11:36:40 +0000 Subject: [PATCH] Batching - prevent CPU transform for non-rects using large FVF Large FVF which encodes the transform in a vertex attribute is triggered by reading from VERTEX in a custom shader. This means that the local vertex position must be available in the shader, so the only way to batch is to also pass the transform as an attribute. The large FVF path already disabled CPU transform in the case of rects, but not in other primitives, which this PR fixes. Note that large FVF is incompatible with 2d software skinning. So reading from VERTEX in a custom shader when using skinning will not work. --- drivers/gles_common/rasterizer_canvas_batcher.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index 88b6d89530..fce51a7289 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -1310,7 +1310,9 @@ PREAMBLE(bool)::_prefill_line(RasterizerCanvas::Item::CommandLine *p_line, FillS Vector2 from = p_line->from; Vector2 to = p_line->to; - if (r_fill_state.transform_mode != TM_NONE) { + const bool use_large_verts = bdata.use_large_verts; + + if ((r_fill_state.transform_mode != TM_NONE) && (!use_large_verts)) { _software_transform_vertex(from, r_fill_state.transform_combined); _software_transform_vertex(to, r_fill_state.transform_combined); } @@ -1658,13 +1660,15 @@ bool C_PREAMBLE::_prefill_polygon(RasterizerCanvas::Item::CommandPolygon *p_poly if (!_software_skin_poly(p_poly, p_item, bvs, vertex_colors, r_fill_state, precalced_colors)) { + bool software_transform = (r_fill_state.transform_mode != TM_NONE) && (!use_large_verts); + for (int n = 0; n < num_inds; n++) { int ind = p_poly->indices[n]; RAST_DEV_DEBUG_ASSERT(ind < p_poly->points.size()); // this could be moved outside the loop - if (r_fill_state.transform_mode != TM_NONE) { + if (software_transform) { Vector2 pos = p_poly->points[ind]; _software_transform_vertex(pos, r_fill_state.transform_combined); bvs[n].pos.set(pos.x, pos.y);