virtualx-engine/drivers/gles2
lawnjelly 451c3fc0fb GLES2 2D batching - item reordering, light joining and light modulate fix
Although 2D draws in painters order with strict ordering, in certain circumstances items can be reordered to increase batching / decrease state changes, without affecting the end result. This can be determined by an overlap test.

In situation with item:
A-B-A
providing the third item does not overlap the second, they can be reordered:
A-A-B

Items already contain an AABB which can be used for this overlap test.

1)
To utilise this, I have implemented item reordering (only for single rects for now), with the lookahead adjustable in project settings. This can increase performance in situations where items may not be grouped in the scene tree by texture. It can also be switched off (by setting lookahead to 0).

2)
This same trick can be used to help join items that are lit. Lit items previously would prevent joining completely, thus missing out on performance gains other than multi-command items such as tilemaps.

In this PR, lights are assigned as bits in a bitfield (up to 64, the optimization is disabled above this), and on each try_item (for joining), the bitfield for lights and shadows is constructed and compared with the previous items. If these match the 2 items can potentially be joined. However, this can only be done without changing the rendered result if an overlap test is successful.

This overlap test can be adjusted to join items up to a specific number of item references, selectable in project settings, or turned off.

3)
The legacy uniform single rect drawing routine seems to have been identified as the source of flicker, particularly on nvidia. However, it can also be up to 2x as fast. Because of the speed the batching contains a fallback where it can use the legacy single rect method, but I have now added a project setting to make this switchable. In most cases with batching it should not be necessary (as single rects are drawn less frequently) and thus the flickering can be totally avoided.

4)
This PR also fixes a color modulate bug when drawing light passes, in certain situations (particularly custom _draw routines with multiple rects).

5)
This PR also fixes #38291, a bug in the legacy renderer where light passes could draw rects in wrong position.
2020-05-01 07:47:33 +01:00
..
shaders Fix array constructor for lightmaps 2020-01-15 17:41:46 -08:00
rasterizer_array_gles2.h GLES2 2d Batch rendering (across items) 2020-04-04 17:13:58 +01:00
rasterizer_canvas_base_gles2.cpp GLES2 2d Batch rendering (across items) 2020-04-04 17:13:58 +01:00
rasterizer_canvas_base_gles2.h GLES2 2d Batch rendering (across items) 2020-04-04 17:13:58 +01:00
rasterizer_canvas_gles2.cpp GLES2 2D batching - item reordering, light joining and light modulate fix 2020-05-01 07:47:33 +01:00
rasterizer_canvas_gles2.h GLES2 2D batching - item reordering, light joining and light modulate fix 2020-05-01 07:47:33 +01:00
rasterizer_gles2.cpp Add VisualServer methods to get the video adapter name and vendor 2020-01-06 00:37:56 +01:00
rasterizer_gles2.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
rasterizer_scene_gles2.cpp Merge pull request #38099 from clayjohn/GLES2-skeleton-rebind 2020-04-22 08:23:43 +02:00
rasterizer_scene_gles2.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
rasterizer_storage_gles2.cpp Restrict GL_TEXTURE_EXTERNAL_OES to Android platform 2020-04-27 10:18:31 -07:00
rasterizer_storage_gles2.h Items and draw calls added to IDE Monitor in '2d' section 2020-04-16 11:52:22 +01:00
SCsub SCons: Build thirdparty code in own env, disable warnings 2018-09-28 14:07:39 +02:00
shader_compiler_gles2.cpp Avoid duplicating shader defines in GLES2 2020-04-26 23:28:24 -07:00
shader_compiler_gles2.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
shader_gles2.cpp Add support for opengl external textures as defined by https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt 2020-03-05 13:09:49 -08:00
shader_gles2.h Add support for opengl external textures as defined by https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt 2020-03-05 13:09:49 -08:00