1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

GLES2 2d Batch rendering (across items)

2d rendering is currently bottlenecked by drawing primitives one at a time, limiting OpenGL efficiency. This PR batches primitives and renders in fewer drawcalls, resulting in significant performance improvements. This also speeds up text rendering.

This PR batches across canvas items as well as within items.

The code dynamically chooses between a vertex format with and without color, depending on the input data for a frame, in order to optimize throughput and maximize batch size. It also adds an option to use glScissor to reduce fillrate in light passes.
This commit is contained in:
lawnjelly
2020-03-27 09:19:37 +00:00
parent abb70a6165
commit 45b0b8bff8
7 changed files with 4180 additions and 2125 deletions

View File

@@ -2411,6 +2411,19 @@ VisualServer::VisualServer() {
GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
GLOBAL_DEF("rendering/gles2/batching/use_batching", true);
GLOBAL_DEF("rendering/gles2/batching/max_join_item_commands", 16);
GLOBAL_DEF("rendering/gles2/batching/colored_vertex_format_threshold", 0.25f);
GLOBAL_DEF("rendering/gles2/batching/light_scissor_area_threshold", 1.0f);
GLOBAL_DEF("rendering/gles2/batching/batch_buffer_size", 16384);
GLOBAL_DEF("rendering/gles2/debug/flash_batching", false);
GLOBAL_DEF_RST("rendering/gles2/debug/use_batching_in_editor", false);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/gles2/batching/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/colored_vertex_format_threshold", PropertyInfo(Variant::REAL, "rendering/gles2/batching/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/gles2/batching/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/gles2/batching/light_scissor_area_threshold", PropertyInfo(Variant::REAL, "rendering/gles2/batching/light_scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0"));
}
VisualServer::~VisualServer() {