virtualx-engine/drivers
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
..
alsa Adding missing include guards to header files identified by LGTM. 2020-03-25 11:38:54 +01:00
alsamidi ALSA MIDI driver: 2020-01-22 21:41:48 +01:00
coreaudio Revert "Exposes capture methods to AudioServer + documentation" #30468 2020-01-20 13:18:01 +01:00
coremidi Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
dummy Add more extensions to the dummy texture loader 2020-04-27 10:09:17 +02:00
gl_context SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor defines 2019-07-03 09:59:04 +02:00
gles2 GLES2 2D batching - item reordering, light joining and light modulate fix 2020-05-01 07:47:33 +01:00
gles3 Restrict GL_TEXTURE_EXTERNAL_OES to Android platform 2020-04-27 10:18:31 -07:00
png Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
pulseaudio Revert "Exposes capture methods to AudioServer + documentation" #30468 2020-01-20 13:18:01 +01:00
unix Merge pull request #36639 from RandomShaper/imvu/improve_drives_ux_3.2 2020-03-17 16:27:33 +01:00
wasapi Revert "Exposes capture methods to AudioServer + documentation" #30468 2020-01-20 13:18:01 +01:00
windows Fix res:// trimmed to s:// on Windows 2020-04-01 10:22:05 +02:00
winmidi Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
xaudio2 Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
register_driver_types.cpp Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
register_driver_types.h Update copyright statements to 2020 2020-01-01 11:16:22 +01:00
SCsub Remove convex_decomp in drivers/SCsub 2019-12-14 21:41:21 +09:00