diff --git a/core/os/os.h b/core/os/os.h index 4bb177eb77a4..a98303f1cb56 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,13 +69,6 @@ class OS { bool restart_on_exit = false; List restart_commandline; - // for the user interface we keep a record of the current display driver - // so we can retrieve the rendering drivers available - int _display_driver_id = -1; - String _current_rendering_driver_name; - String _current_rendering_method; - bool _is_gles_over_gl = false; - RemoteFilesystemClient default_rfs; // For tracking benchmark data @@ -111,8 +104,6 @@ class OS { virtual void initialize() = 0; virtual void initialize_joypads() = 0; - void set_display_driver_id(int p_display_driver_id) { _display_driver_id = p_display_driver_id; } - virtual void set_main_loop(MainLoop *p_main_loop) = 0; virtual void delete_main_loop() = 0; @@ -128,16 +119,6 @@ class OS { static OS *get_singleton(); - void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; } - void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; } - void set_gles_over_gl(bool p_enabled) { _is_gles_over_gl = p_enabled; } - - String get_current_rendering_driver_name() const { return _current_rendering_driver_name; } - String get_current_rendering_method() const { return _current_rendering_method; } - bool get_gles_over_gl() const { return _is_gles_over_gl; } - - int get_display_driver_id() const { return _display_driver_id; } - virtual Vector get_video_adapter_driver_info() const = 0; virtual bool get_user_prefers_integrated_gpu() const { return false; } diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index abda2a5e0628..6eaf319a5b21 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -119,7 +119,7 @@ class RasterizerGLES3 : public RendererCompositor { static void make_current(bool p_gles_over_gl) { gles_over_gl = p_gles_over_gl; - OS::get_singleton()->set_gles_over_gl(gles_over_gl); + RenderingServer::get_singleton()->set_gles_over_gl(gles_over_gl); _create_func = _create_current; low_end = true; } diff --git a/drivers/gles3/storage/config.cpp b/drivers/gles3/storage/config.cpp index 07dd5f58c1af..c43fe316ea51 100644 --- a/drivers/gles3/storage/config.cpp +++ b/drivers/gles3/storage/config.cpp @@ -232,7 +232,7 @@ Config::Config() { disable_transform_feedback_shader_cache = true; } - if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3_angle") { + if (RenderingServer::get_singleton()->get_current_rendering_driver_name() == "opengl3_angle") { polyfill_half2float = false; } #ifdef WEB_ENABLED diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 36b43b7e9b71..9cf625a44530 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4962,8 +4962,8 @@ String EditorNode::_get_system_info() const { // `replace` is necessary, because `capitalize` introduces a whitespace between "x" and "11". display_session_type = OS::get_singleton()->get_environment("XDG_SESSION_TYPE").capitalize().replace(" ", ""); #endif // LINUXBSD_ENABLED - String driver_name = OS::get_singleton()->get_current_rendering_driver_name().to_lower(); - String rendering_method = OS::get_singleton()->get_current_rendering_method().to_lower(); + String driver_name = RenderingServer::get_singleton()->get_current_rendering_driver_name().to_lower(); + String rendering_method = RenderingServer::get_singleton()->get_current_rendering_method().to_lower(); const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); @@ -5009,7 +5009,7 @@ String EditorNode::_get_system_info() const { } else if (driver_name == "opengl3_es") { driver_name = "OpenGL ES 3"; } else if (driver_name == "opengl3") { - if (OS::get_singleton()->get_gles_over_gl()) { + if (RenderingServer::get_singleton()->get_gles_over_gl()) { driver_name = "OpenGL 3"; } else { driver_name = "OpenGL ES 3"; @@ -7457,12 +7457,11 @@ EditorNode::EditorNode() { title_bar->add_child(right_menu_spacer); } - String current_renderer_ps = GLOBAL_GET("rendering/renderer/rendering_method"); - current_renderer_ps = current_renderer_ps.to_lower(); - String current_renderer_os = OS::get_singleton()->get_current_rendering_method().to_lower(); + String current_renderer_ps = String(GLOBAL_GET("rendering/renderer/rendering_method")).to_lower(); + String current_renderer_rs = RenderingServer::get_singleton()->get_current_rendering_method().to_lower(); // Add the renderers name to the UI. - if (current_renderer_ps == current_renderer_os) { + if (current_renderer_ps == current_renderer_rs) { renderer->connect(SceneStringName(item_selected), callable_mp(this, &EditorNode::_renderer_selected)); // As we are doing string comparisons, keep in standard case to prevent problems with capitals // "vulkan" in particular uses lowercase "v" in the code, and uppercase in the UI. @@ -7480,8 +7479,8 @@ EditorNode::EditorNode() { } } else { // It's an CLI-overridden rendering method. - _add_renderer_entry(current_renderer_os, true); - renderer->set_item_metadata(0, current_renderer_os); + _add_renderer_entry(current_renderer_rs, true); + renderer->set_item_metadata(0, current_renderer_rs); renderer->select(0); renderer_current = 0; } diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index b7508e764494..02cf4f895267 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -91,7 +91,7 @@ static String _include_function(const String &p_path, void *userpointer) { Error ResourceImporterShaderFile::import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { /* STEP 1, Read shader code */ - ERR_FAIL_COND_V_EDMSG((OS::get_singleton()->get_current_rendering_method() == "gl_compatibility"), ERR_UNAVAILABLE, "Cannot import custom .glsl shaders when using the gl_compatibility rendering_method. Please switch to the forward_plus or mobile rendering methods to use custom shaders."); + ERR_FAIL_COND_V_EDMSG((RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility"), ERR_UNAVAILABLE, "Cannot import custom .glsl shaders when using the gl_compatibility rendering_method. Please switch to the forward_plus or mobile rendering methods to use custom shaders."); ERR_FAIL_COND_V_EDMSG((DisplayServer::get_singleton()->get_name() == "headless"), ERR_UNAVAILABLE, "Cannot import custom .glsl shaders when running in headless mode."); Error err; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 5afe01025d35..062ed5e5fe39 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -8545,7 +8545,7 @@ void Node3DEditor::_load_default_preview_settings() { environ_sky_color->set_pick_color(Color(0.385, 0.454, 0.55)); environ_ground_color->set_pick_color(Color(0.2, 0.169, 0.133)); environ_energy->set_value(1.0); - if (OS::get_singleton()->get_current_rendering_method() != "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "gl_compatibility") { environ_glow_button->set_pressed(true); } environ_tonemap_button->set_pressed(true); diff --git a/main/main.cpp b/main/main.cpp index fb21ee502f9c..8203791ed212 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2386,8 +2386,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // always convert to lower case for consistency in the code rendering_driver = rendering_driver.to_lower(); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); - OS::get_singleton()->set_current_rendering_method(rendering_method); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method(rendering_method); if (use_custom_res) { if (!force_res) { @@ -2943,10 +2943,6 @@ Error Main::setup2(bool p_show_boot_logo) { } } - // Store this in a globally accessible place, so we can retrieve the rendering drivers - // list from the display driver for the editor UI. - OS::get_singleton()->set_display_driver_id(display_driver_idx); - Vector2i *window_position = nullptr; Vector2i position = init_custom_pos; if (init_use_custom_pos) { diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 38f6931c8a86..98479f75ce40 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -656,8 +656,8 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis if (fallback_to_opengl3 && rendering_driver != "opengl3") { WARN_PRINT("Your device seem not to support Vulkan, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else #endif { diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index 5d9179bd9a79..45bdf697a362 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -116,8 +116,8 @@ if (fallback_to_opengl3 && rendering_driver != "opengl3") { WARN_PRINT("Your device seem not to support MoltenVK or Metal, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else #endif { diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp index fe359532bb03..90eb6e40ba46 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.cpp +++ b/platform/linuxbsd/wayland/display_server_wayland.cpp @@ -1362,8 +1362,8 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win if (fallback_to_opengl3 && rendering_driver != "opengl3") { WARN_PRINT("Your video card drivers seem not to support the required Vulkan version, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else #endif // GLES3_ENABLED { @@ -1450,7 +1450,7 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win if (fallback) { WARN_PRINT("Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES."); rendering_driver = "opengl3_es"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index a9c94bd8238e..9dbd17398852 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -6174,8 +6174,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (fallback_to_opengl3 && rendering_driver != "opengl3") { WARN_PRINT("Your video card drivers seem not to support the required Vulkan version, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else #endif // GLES3_ENABLED { @@ -6251,7 +6251,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (fallback) { WARN_PRINT("Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES."); rendering_driver = "opengl3_es"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index f1078d9868fd..895ead48393d 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3645,8 +3645,8 @@ if (fallback_to_opengl3 && rendering_driver != "opengl3") { WARN_PRINT("Your device seem not to support MoltenVK or Metal, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else #endif { @@ -3671,7 +3671,7 @@ WARN_PRINT("Your video card drivers seem not to support GLES3 / ANGLE or ANGLE dynamic libraries (libEGL.dylib and libGLESv2.dylib) are missing, switching to native OpenGL."); #endif rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Could not initialize ANGLE OpenGL."); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index a6eab1bd2963..c3500ec5610d 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -6210,7 +6210,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (rendering_context->initialize() == OK) { WARN_PRINT("Your video card drivers seem not to support Direct3D 12, switching to Vulkan."); rendering_driver = "vulkan"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); failed = false; } } @@ -6224,7 +6224,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (rendering_context->initialize() == OK) { WARN_PRINT("Your video card drivers seem not to support Vulkan, switching to Direct3D 12."); rendering_driver = "d3d12"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); failed = false; } } @@ -6237,8 +6237,8 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win tested_drivers.set_flag(DRIVER_ID_COMPAT_OPENGL3); WARN_PRINT("Your video card drivers seem not to support Direct3D 12 or Vulkan, switching to OpenGL 3."); rendering_driver = "opengl3"; - OS::get_singleton()->set_current_rendering_method("gl_compatibility"); - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_method("gl_compatibility"); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); failed = false; } #endif @@ -6316,7 +6316,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } } rendering_driver = "opengl3_angle"; - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + RenderingServer::get_singleton()->set_current_rendering_driver_name(rendering_driver); } } diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index b50881cb8933..a633848bb6f5 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -344,11 +344,11 @@ PackedStringArray GPUParticles2D::get_configuration_warnings() const { } } - if (trail_enabled && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (trail_enabled && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Particle trails are only available when using the Forward+ or Mobile rendering backends.")); } - if (sub_emitter != NodePath() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (sub_emitter != NodePath() && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Particle sub-emitters are not available when using the GL Compatibility rendering backend.")); } diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index 8702b1d3da0d..e6ce8dc7bd5c 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -165,7 +165,7 @@ void Decal::_validate_property(PropertyInfo &p_property) const { PackedStringArray Decal::get_configuration_warnings() const { PackedStringArray warnings = VisualInstance3D::get_configuration_warnings(); - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Decals are only available when using the Forward+ or Mobile rendering backends.")); return warnings; } diff --git a/scene/3d/fog_volume.cpp b/scene/3d/fog_volume.cpp index 195074ba2f7b..c878094d6186 100644 --- a/scene/3d/fog_volume.cpp +++ b/scene/3d/fog_volume.cpp @@ -120,7 +120,7 @@ PackedStringArray FogVolume::get_configuration_warnings() const { Ref environment = get_viewport()->find_world_3d()->get_environment(); - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus") { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus") { warnings.push_back(RTR("Fog Volumes are only visible when using the Forward+ backend.")); return warnings; } diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index b48a3a87c706..161a8bf2371b 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -384,12 +384,12 @@ PackedStringArray GPUParticles3D::get_configuration_warnings() const { if ((dp_count || !skin.is_null()) && (missing_trails || no_materials)) { warnings.push_back(RTR("Trails enabled, but one or more mesh materials are either missing or not set for trails rendering.")); } - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Particle trails are only available when using the Forward+ or Mobile rendering backends.")); } } - if (sub_emitter != NodePath() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (sub_emitter != NodePath() && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Particle sub-emitters are only available when using the Forward+ or Mobile rendering backends.")); } diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 2d18e62b1029..b3a7e4ad808e 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -616,7 +616,7 @@ PackedStringArray OmniLight3D::get_configuration_warnings() const { warnings.push_back(RTR("Projector texture only works with shadows active.")); } - if (get_projector().is_valid() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (get_projector().is_valid() && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Projector textures are not supported when using the GL Compatibility backend yet. Support will be added in a future release.")); } @@ -652,7 +652,7 @@ PackedStringArray SpotLight3D::get_configuration_warnings() const { warnings.push_back(RTR("Projector texture only works with shadows active.")); } - if (get_projector().is_valid() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (get_projector().is_valid() && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("Projector textures are not supported when using the GL Compatibility backend yet. Support will be added in a future release.")); } diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index a59754c8cc4e..49246a735d00 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -511,11 +511,11 @@ PackedStringArray GeometryInstance3D::get_configuration_warnings() const { warnings.push_back(RTR("The GeometryInstance3D is configured to fade out smoothly over distance, but the fade transition distance is set to 0.\nTo resolve this, increase Visibility Range End Margin above 0.")); } - if (!Math::is_zero_approx(transparency) && OS::get_singleton()->get_current_rendering_method() != "forward_plus") { + if (!Math::is_zero_approx(transparency) && RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus") { warnings.push_back(RTR("GeometryInstance3D transparency is only available when using the Forward+ rendering method.")); } - if ((visibility_range_fade_mode == VISIBILITY_RANGE_FADE_SELF || visibility_range_fade_mode == VISIBILITY_RANGE_FADE_DEPENDENCIES) && OS::get_singleton()->get_current_rendering_method() != "forward_plus") { + if ((visibility_range_fade_mode == VISIBILITY_RANGE_FADE_SELF || visibility_range_fade_mode == VISIBILITY_RANGE_FADE_DEPENDENCIES) && RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus") { warnings.push_back(RTR("GeometryInstance3D visibility range transparency fade is only available when using the Forward+ rendering method.")); } diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index 80ff176a98d0..802205521735 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -520,7 +520,7 @@ AABB VoxelGI::get_aabb() const { PackedStringArray VoxelGI::get_configuration_warnings() const { PackedStringArray warnings = VisualInstance3D::get_configuration_warnings(); - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { warnings.push_back(RTR("VoxelGI nodes are not supported when using the GL Compatibility backend yet. Support will be added in a future release.")); } else if (probe_data.is_null()) { warnings.push_back(RTR("No VoxelGI data set, so this node is disabled. Bake static objects to enable GI.")); diff --git a/scene/resources/camera_attributes.cpp b/scene/resources/camera_attributes.cpp index 3a0c207a5dab..9702c058e20f 100644 --- a/scene/resources/camera_attributes.cpp +++ b/scene/resources/camera_attributes.cpp @@ -395,7 +395,7 @@ void CameraAttributesPhysical::_update_frustum() { bool use_far = (depth_far < frustum_far) && (depth_far > 0.0); bool use_near = depth_near > frustum_near; #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { // Force disable DoF in editor builds to suppress warnings. use_far = false; use_near = false; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index b5e23e983216..a63cd724a5cc 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1128,7 +1128,7 @@ void Environment::_validate_property(PropertyInfo &p_property) const { p_property.usage = PROPERTY_USAGE_NO_EDITOR; } - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { // Hide glow properties we do not support in GL Compatibility. if (p_property.name.begins_with("glow_levels") || p_property.name == "glow_normalized" || p_property.name == "glow_strength" || p_property.name == "glow_mix" || p_property.name == "glow_blend_mode" || p_property.name == "glow_map_strength" || p_property.name == "glow_map") { p_property.usage = PROPERTY_USAGE_NO_EDITOR; diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 3db1ab93380f..6f8e90a2c385 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -3804,7 +3804,7 @@ String VisualShaderNodeDerivativeFunc::generate_code(Shader::Mode p_mode, Visual }; String code; - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { code += " " + p_output_vars[0] + " = " + String(functions[func]).replace_first("$", "").replace_first("$", p_input_vars[0]) + ";\n"; return code; } @@ -3814,7 +3814,7 @@ String VisualShaderNodeDerivativeFunc::generate_code(Shader::Mode p_mode, Visual } String VisualShaderNodeDerivativeFunc::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { - if (precision != PRECISION_NONE && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (precision != PRECISION_NONE && RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { String precision_str; switch (precision) { case PRECISION_COARSE: { @@ -7672,7 +7672,7 @@ String VisualShaderNodeMultiplyAdd::get_output_port_name(int p_port) const { } String VisualShaderNodeMultiplyAdd::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { return " " + p_output_vars[0] + " = (" + p_input_vars[0] + " * " + p_input_vars[1] + ") + " + p_input_vars[2] + ";\n"; } return " " + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index ba47508700fa..8c2c72a0a67c 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -325,7 +325,7 @@ RendererCompositorRD::RendererCompositorRD() { fog = memnew(RendererRD::Fog); canvas = memnew(RendererCanvasRenderRD()); - String rendering_method = OS::get_singleton()->get_current_rendering_method(); + String rendering_method = RenderingServer::get_singleton()->get_current_rendering_method(); uint64_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE); if (rendering_method == "mobile" || textures_per_stage < 48) { diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index 6234cddee393..84a07865a16f 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -204,7 +204,7 @@ void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, c builder.append("#define NO_IMAGE_ATOMICS\n"); #endif - builder.append(String("#define RENDER_DRIVER_") + OS::get_singleton()->get_current_rendering_driver_name().to_upper() + "\n"); + builder.append(String("#define RENDER_DRIVER_") + RenderingServer::get_singleton()->get_current_rendering_driver_name().to_upper() + "\n"); builder.append("#define samplerExternalOES sampler2D\n"); builder.append("#define textureExternalOES texture2D\n"); } break; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 4d6435f48a53..4a323eb3d10d 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -275,7 +275,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { timestamp_vp_map[rt_id] = p_viewport->self; } - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility") { // 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); } @@ -800,7 +800,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { // commit our eyes Vector blits = xr_interface->post_draw_viewport(vp->render_target, vp->viewport_to_screen_rect); if (vp->viewport_to_screen != DisplayServer::INVALID_WINDOW_ID) { - if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { + if (RenderingServer::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { if (blits.size() > 0) { RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blits.ptr(), blits.size()); RSG::rasterizer->gl_end_frame(p_swap_buffers); @@ -840,7 +840,7 @@ void RendererViewport::draw_viewports(bool p_swap_buffers) { blits = &blit_to_screen_list.insert(vp->viewport_to_screen, Vector())->value; } - if (OS::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { + if (RenderingServer::get_singleton()->get_current_rendering_driver_name().begins_with("opengl3")) { Vector blit_to_screen_vec; blit_to_screen_vec.push_back(blit); RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1); @@ -917,8 +917,8 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) { void RendererViewport::viewport_set_scaling_3d_mode(RID p_viewport, RS::ViewportScaling3DMode p_mode) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_NULL(viewport); - ERR_FAIL_COND_EDMSG(p_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR && OS::get_singleton()->get_current_rendering_method() != "forward_plus", "FSR1 is only available when using the Forward+ renderer."); - ERR_FAIL_COND_EDMSG(p_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2 && OS::get_singleton()->get_current_rendering_method() != "forward_plus", "FSR2 is only available when using the Forward+ renderer."); + ERR_FAIL_COND_EDMSG(p_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR && RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus", "FSR1 is only available when using the Forward+ renderer."); + ERR_FAIL_COND_EDMSG(p_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR2 && RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus", "FSR2 is only available when using the Forward+ renderer."); if (viewport->scaling_3d_mode == p_mode) { return; @@ -1310,7 +1310,7 @@ void RendererViewport::viewport_set_screen_space_aa(RID p_viewport, RS::Viewport void RendererViewport::viewport_set_use_taa(RID p_viewport, bool p_use_taa) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_NULL(viewport); - ERR_FAIL_COND_EDMSG(OS::get_singleton()->get_current_rendering_method() != "forward_plus", "TAA is only available when using the Forward+ renderer."); + ERR_FAIL_COND_EDMSG(RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus", "TAA is only available when using the Forward+ renderer."); if (viewport->use_taa == p_use_taa) { return; diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index cc67873b2424..098f3028c585 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -6101,7 +6101,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ if (is_main_instance) { // Only the singleton instance with a display should print this information. String rendering_method; - if (OS::get_singleton()->get_current_rendering_method() == "mobile") { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "mobile") { rendering_method = "Forward Mobile"; } else { rendering_method = "Forward+"; @@ -6247,7 +6247,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ if (is_main_instance && project_pipeline_cache_enable) { // Only the instance that is not a local device and is also the singleton is allowed to manage a pipeline cache. pipeline_cache_file_path = vformat("user://vulkan/pipelines.%s.%s", - OS::get_singleton()->get_current_rendering_method(), + RenderingServer::get_singleton()->get_current_rendering_method(), device.name.validate_filename().replace(" ", "_").to_lower()); if (Engine::get_singleton()->is_editor_hint()) { pipeline_cache_file_path += ".editor"; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 7c4128b0e378..a00bd0e7ade7 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -9685,7 +9685,7 @@ Error ShaderLanguage::_parse_shader(const HashMap &p_f new_hint = ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE; --texture_uniforms; --texture_binding; - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus") { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus") { _set_error(RTR("'hint_normal_roughness_texture' is only available when using the Forward+ backend.")); return ERR_PARSE_ERROR; } diff --git a/servers/rendering/shader_preprocessor.cpp b/servers/rendering/shader_preprocessor.cpp index 88ea74cdfcd5..6ab92c0c2dcf 100644 --- a/servers/rendering/shader_preprocessor.cpp +++ b/servers/rendering/shader_preprocessor.cpp @@ -1335,7 +1335,7 @@ Error ShaderPreprocessor::preprocess(const String &p_code, const String &p_filen static HashMap defines; if (defines.is_empty()) { - const String rendering_method = OS::get_singleton()->get_current_rendering_method(); + const String rendering_method = RenderingServer::get_singleton()->get_current_rendering_method(); if (rendering_method == "forward_plus") { defines["CURRENT_RENDERER"] = _MKSTR(2); diff --git a/servers/rendering/storage/camera_attributes_storage.cpp b/servers/rendering/storage/camera_attributes_storage.cpp index 2fece3ce0f57..396020515c15 100644 --- a/servers/rendering/storage/camera_attributes_storage.cpp +++ b/servers/rendering/storage/camera_attributes_storage.cpp @@ -66,7 +66,7 @@ void RendererCameraAttributes::camera_attributes_set_dof_blur(RID p_camera_attri CameraAttributes *cam_attributes = camera_attributes_owner.get_or_null(p_camera_attributes); ERR_FAIL_NULL(cam_attributes); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && (p_far_enable || p_near_enable)) { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility" && (p_far_enable || p_near_enable)) { WARN_PRINT_ONCE_ED("DoF blur is only available when using the Forward+ or Mobile rendering backends."); } #endif @@ -144,7 +144,7 @@ void RendererCameraAttributes::camera_attributes_set_auto_exposure(RID p_camera_ cam_attributes->auto_exposure_version = ++auto_exposure_counter; } #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() == "gl_compatibility" && p_enable) { WARN_PRINT_ONCE_ED("Auto exposure is only available when using the Forward+ or Mobile rendering backends."); } #endif diff --git a/servers/rendering/storage/environment_storage.cpp b/servers/rendering/storage/environment_storage.cpp index e7556f90008e..a28ce2bf952d 100644 --- a/servers/rendering/storage/environment_storage.cpp +++ b/servers/rendering/storage/environment_storage.cpp @@ -340,7 +340,7 @@ void RendererEnvironmentStorage::environment_set_volumetric_fog(RID p_env, bool Environment *env = environment_owner.get_or_null(p_env); ERR_FAIL_NULL(env); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { WARN_PRINT_ONCE_ED("Volumetric fog can only be enabled when using the Forward+ rendering backend."); } #endif @@ -535,7 +535,7 @@ void RendererEnvironmentStorage::environment_set_ssr(RID p_env, bool p_enable, i Environment *env = environment_owner.get_or_null(p_env); ERR_FAIL_NULL(env); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { WARN_PRINT_ONCE_ED("Screen-space reflections (SSR) can only be enabled when using the Forward+ rendering backend."); } #endif @@ -582,7 +582,7 @@ void RendererEnvironmentStorage::environment_set_ssao(RID p_env, bool p_enable, Environment *env = environment_owner.get_or_null(p_env); ERR_FAIL_NULL(env); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { WARN_PRINT_ONCE_ED("Screen-space ambient occlusion (SSAO) can only be enabled when using the Forward+ rendering backend."); } #endif @@ -657,7 +657,7 @@ void RendererEnvironmentStorage::environment_set_ssil(RID p_env, bool p_enable, Environment *env = environment_owner.get_or_null(p_env); ERR_FAIL_NULL(env); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { WARN_PRINT_ONCE_ED("Screen-space indirect lighting (SSIL) can only be enabled when using the Forward+ rendering backend."); } #endif @@ -704,7 +704,7 @@ void RendererEnvironmentStorage::environment_set_sdfgi(RID p_env, bool p_enable, Environment *env = environment_owner.get_or_null(p_env); ERR_FAIL_NULL(env); #ifdef DEBUG_ENABLED - if (OS::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { + if (RenderingServer::get_singleton()->get_current_rendering_method() != "forward_plus" && p_enable) { WARN_PRINT_ONCE_ED("SDFGI can only be enabled when using the Forward+ rendering backend."); } #endif diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index c0c6f1e9048b..3207be418696 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2067,16 +2067,6 @@ void RenderingServer::_particles_set_trail_bind_poses(RID p_particles, const Typ particles_set_trail_bind_poses(p_particles, tbposes); } -String RenderingServer::get_current_rendering_driver_name() const { - // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here. - return ::OS::get_singleton()->get_current_rendering_driver_name(); -} - -String RenderingServer::get_current_rendering_method() const { - // Needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here. - return ::OS::get_singleton()->get_current_rendering_method(); -} - Vector _convert_surface_version_1_to_surface_version_2(uint64_t p_format, Vector p_vertex_data, uint32_t p_vertex_count, uint32_t p_old_stride, uint32_t p_vertex_size, uint32_t p_normal_size, uint32_t p_position_stride, uint32_t p_normal_tangent_stride) { Vector new_vertex_data; new_vertex_data.resize(p_vertex_data.size()); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 6de934aaeb16..c2dc4b07d32c 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -68,6 +68,11 @@ class RenderingServer : public Object { int mm_policy = 0; bool render_loop_enabled = true; + String _current_rendering_driver_name; + String _current_rendering_method; + + bool _is_gles_over_gl = false; + Array _get_array_from_surface(uint64_t p_format, Vector p_vertex_data, Vector p_attrib_data, Vector p_skin_data, int p_vertex_len, Vector p_index_data, int p_index_len, const AABB &p_aabb, const Vector4 &p_uv_scale) const; const Vector2 SMALL_VEC2 = Vector2(CMP_EPSILON, CMP_EPSILON); @@ -1774,6 +1779,14 @@ class RenderingServer : public Object { virtual bool is_low_end() const = 0; + void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; } + void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; } + String get_current_rendering_driver_name() const { return _current_rendering_driver_name; } + String get_current_rendering_method() const { return _current_rendering_method; } + + void set_gles_over_gl(bool p_enabled) { _is_gles_over_gl = p_enabled; } + bool get_gles_over_gl() const { return _is_gles_over_gl; } + virtual void set_print_gpu_profile(bool p_enable) = 0; virtual Size2i get_maximum_viewport_size() const = 0; @@ -1787,9 +1800,6 @@ class RenderingServer : public Object { virtual bool is_on_render_thread() = 0; virtual void call_on_render_thread(const Callable &p_callable) = 0; - String get_current_rendering_driver_name() const; - String get_current_rendering_method() const; - #ifdef TOOLS_ENABLED virtual void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const override; #endif