diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-31 18:30:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-31 18:30:38 +0100 |
commit | 16dc607f8ad2055c8dec543bcd427fe74e5d6059 (patch) | |
tree | c99e99c1fd63fdb3d60b0c6d6ec632647e65619a /servers | |
parent | d6f972fad45d28222b1437a047241dd74f0d5b90 (diff) | |
parent | 8a10bb7d0dd0cc03353bb751af25a0eca1357c9d (diff) |
Merge pull request #54307 from Calinou/add-opengl-renderer-squash
Add OpenGL renderer (squashed)
Diffstat (limited to 'servers')
-rw-r--r-- | servers/display_server.cpp | 4 | ||||
-rw-r--r-- | servers/display_server.h | 3 | ||||
-rw-r--r-- | servers/rendering/renderer_scene_cull.cpp | 4 | ||||
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 7 | ||||
-rw-r--r-- | servers/rendering_server.cpp | 37 |
5 files changed, 54 insertions, 1 deletions
diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 3fb47e8f05..7bf5673663 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -208,6 +208,10 @@ void DisplayServer::window_set_mouse_passthrough(const Vector<Vector2> &p_region ERR_FAIL_MSG("Mouse passthrough not supported by this display server."); } +void DisplayServer::gl_window_make_current(DisplayServer::WindowID p_window_id) { + // noop except in gles +} + void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) { WARN_PRINT("IME not supported by this display server."); } diff --git a/servers/display_server.h b/servers/display_server.h index 2595cf2eb8..2d837dbef9 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -298,6 +298,9 @@ public: virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID); + // necessary for GL focus, may be able to use one of the existing functions for this, not sure yet + virtual void gl_window_make_current(DisplayServer::WindowID p_window_id); + virtual Point2i ime_get_selection() const; virtual String ime_get_text() const; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 8421938507..e338e526a0 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -3855,6 +3855,10 @@ void RendererSceneCull::update() { } bool RendererSceneCull::free(RID p_rid) { + if (p_rid.is_null()) { + return true; + } + if (scene_render->free(p_rid)) { return true; } diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 347238cdaa..c3d57a13ad 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -129,6 +129,11 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { timestamp_vp_map[rt_id] = p_viewport->self; } + if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3") { + // This is currently needed for GLES to keep the current window being rendered to up to date + DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen); + } + /* Camera should always be BEFORE any other 3D */ bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front @@ -747,7 +752,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_ ERR_FAIL_COND(!viewport); if (p_screen != DisplayServer::INVALID_WINDOW_ID) { - // If using GLES2 we can optimize this operation by rendering directly to system_fbo + // If using OpenGL we can optimize this operation by rendering directly to system_fbo // instead of rendering to fbo and copying to system_fbo after if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y, viewport->get_view_count()); diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index f43b9352b4..1b16949768 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2957,6 +2957,43 @@ RenderingServer::RenderingServer() { ProjectSettings::get_singleton()->set_custom_property_info("rendering/limits/cluster_builder/max_clustered_elements", PropertyInfo(Variant::FLOAT, "rendering/limits/cluster_builder/max_clustered_elements", PROPERTY_HINT_RANGE, "32,8192,1")); GLOBAL_DEF_RST("rendering/xr/enabled", false); + + GLOBAL_DEF_RST("rendering/2d/options/use_software_skinning", true); + GLOBAL_DEF_RST("rendering/2d/options/ninepatch_mode", 1); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/options/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/2d/options/ninepatch_mode", PROPERTY_HINT_ENUM, "Fixed,Scaling")); + + GLOBAL_DEF_RST("rendering/2d/opengl/batching_send_null", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_send_null", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_send_null", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/batching_stream", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/batching_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/batching_stream", PROPERTY_HINT_ENUM, "Default (Off),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/legacy_orphan_buffers", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_orphan_buffers", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_orphan_buffers", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + GLOBAL_DEF_RST("rendering/2d/opengl/legacy_stream", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/opengl/legacy_stream", PropertyInfo(Variant::INT, "rendering/2d/opengl/legacy_stream", PROPERTY_HINT_ENUM, "Default (On),Off,On")); + + GLOBAL_DEF("rendering/batching/options/use_batching", false); + GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", false); + GLOBAL_DEF("rendering/batching/options/single_rect_fallback", false); + GLOBAL_DEF("rendering/batching/parameters/max_join_item_commands", 16); + GLOBAL_DEF("rendering/batching/parameters/colored_vertex_format_threshold", 0.25f); + GLOBAL_DEF("rendering/batching/lights/scissor_area_threshold", 1.0f); + GLOBAL_DEF("rendering/batching/lights/max_join_items", 32); + GLOBAL_DEF("rendering/batching/parameters/batch_buffer_size", 16384); + GLOBAL_DEF("rendering/batching/parameters/item_reordering_lookahead", 4); + GLOBAL_DEF("rendering/batching/debug/flash_batching", false); + GLOBAL_DEF("rendering/batching/debug/diagnose_frame", false); + GLOBAL_DEF("rendering/gles2/compatibility/disable_half_float", false); + GLOBAL_DEF("rendering/gles2/compatibility/enable_high_float.Android", false); + GLOBAL_DEF("rendering/batching/precision/uv_contract", false); + GLOBAL_DEF("rendering/batching/precision/uv_contract_amount", 100); + + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/batching/parameters/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/colored_vertex_format_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/parameters/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/scissor_area_threshold", PropertyInfo(Variant::FLOAT, "rendering/batching/lights/scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/max_join_items", PropertyInfo(Variant::INT, "rendering/batching/lights/max_join_items", PROPERTY_HINT_RANGE, "0,512")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/item_reordering_lookahead", PropertyInfo(Variant::INT, "rendering/batching/parameters/item_reordering_lookahead", PROPERTY_HINT_RANGE, "0,256")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/precision/uv_contract_amount", PropertyInfo(Variant::INT, "rendering/batching/precision/uv_contract_amount", PROPERTY_HINT_RANGE, "0,10000")); } RenderingServer::~RenderingServer() { |