diff options
43 files changed, 409 insertions, 243 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index d03337cfa0..15f807017f 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -101,10 +101,15 @@ const PackedStringArray ProjectSettings::_get_supported_features() { features.append(VERSION_BRANCH "." _MKSTR(VERSION_PATCH)); features.append(VERSION_FULL_CONFIG); features.append(VERSION_FULL_BUILD); - // For now, assume Vulkan is always supported. - // This should be removed if it's possible to build the editor without Vulkan. - features.append("Vulkan Clustered"); - features.append("Vulkan Mobile"); + +#ifdef VULKAN_ENABLED + features.append("Forward Plus"); + features.append("Mobile"); +#endif + +#ifdef GLES3_ENABLED + features.append("GL Compatibility"); +#endif return features; } @@ -909,7 +914,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust project_features = ProjectSettings::get_required_features(); } // Check the rendering API. - const String rendering_api = has_setting("rendering/quality/driver/driver_name") ? (String)get_setting("rendering/quality/driver/driver_name") : String(); + const String rendering_api = has_setting("rendering/renderer/rendering_method") ? (String)get_setting("rendering/renderer/rendering_method") : String(); if (!rendering_api.is_empty()) { // Add the rendering API as a project feature if it doesn't already exist. if (!project_features.has(rendering_api)) { diff --git a/core/os/os.h b/core/os/os.h index 6944d29eeb..0f79ff1a23 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,6 +69,7 @@ class OS { // so we can retrieve the rendering drivers available int _display_driver_id = -1; String _current_rendering_driver_name; + String _current_rendering_method; protected: void _set_logger(CompositeLogger *p_logger); @@ -98,6 +99,8 @@ protected: virtual void initialize_joypads() = 0; void set_current_rendering_driver_name(String p_driver_name) { _current_rendering_driver_name = p_driver_name; } + void set_current_rendering_method(String p_name) { _current_rendering_method = p_name; } + 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; @@ -116,6 +119,8 @@ public: static OS *get_singleton(); String get_current_rendering_driver_name() const { return _current_rendering_driver_name; } + String get_current_rendering_method() const { return _current_rendering_method; } + int get_display_driver_id() const { return _display_driver_id; } void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, Logger::ErrorType p_type = Logger::ERR_ERROR); diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 7c0ce656ab..4c2cf330af 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1714,13 +1714,6 @@ If [code]true[/code], performs a previous depth pass before rendering 3D materials. This increases performance significantly in scenes with high overdraw, when complex materials and lighting are used. However, in scenes with few occluded surfaces, the depth prepass may reduce performance. If your game is viewed from a fixed angle that makes it easy to avoid overdraw (such as top-down or side-scrolling perspective), consider disabling the depth prepass to improve performance. This setting can be changed at run-time to optimize performance depending on the scene currently being viewed. [b]Note:[/b] Only supported when using the Vulkan Clustered backend or the OpenGL backend. When using Vulkan Mobile there is no depth prepass performed. </member> - <member name="rendering/driver/driver_name" type="String" setter="" getter="" default=""vulkan""> - The video driver to use. - [b]Note:[/b] OpenGL support is currently incomplete. Only basic rendering is supported. - [b]Note:[/b] The backend in use can be overridden at runtime via the [code]--rendering-driver[/code] command line argument. - [b]FIXME:[/b] No longer valid after DisplayServer split: - In such cases, this property is not updated, so use [code]OS.get_current_video_driver[/code] to query it at run-time. - </member> <member name="rendering/driver/threads/thread_model" type="int" setter="" getter="" default="1"> Thread model for rendering. Rendering on a thread can vastly improve performance, but synchronizing to the main thread can cause a bit more jitter. </member> @@ -1796,6 +1789,27 @@ <member name="rendering/environment/volumetric_fog/volume_size" type="int" setter="" getter="" default="64"> Base size used to determine size of froxel buffer in the camera X-axis and Y-axis. The final size is scaled by the aspect ratio of the screen, so actual values may differ from what is set. Set a larger size for more detailed fog, set a smaller size for better performance. </member> + <member name="rendering/gl_compatibility/driver" type="String" setter="" getter="" default=""opengl3""> + Sets the driver to be used by the renderer when using the Compatibility renderer. This property can not be edited directly, instead, set the driver using the platform-specific overrides. + </member> + <member name="rendering/gl_compatibility/driver.android" type="String" setter="" getter="" default=""opengl3""> + Android override for [member rendering/gl_compatibility/driver]. + </member> + <member name="rendering/gl_compatibility/driver.ios" type="String" setter="" getter="" default=""opengl3""> + iOS override for [member rendering/gl_compatibility/driver]. + </member> + <member name="rendering/gl_compatibility/driver.linuxbsd" type="String" setter="" getter="" default=""opengl3""> + LinuxBSD override for [member rendering/gl_compatibility/driver]. + </member> + <member name="rendering/gl_compatibility/driver.macos" type="String" setter="" getter="" default=""opengl3""> + macOS override for [member rendering/gl_compatibility/driver]. + </member> + <member name="rendering/gl_compatibility/driver.web" type="String" setter="" getter="" default=""opengl3""> + Web override for [member rendering/gl_compatibility/driver]. + </member> + <member name="rendering/gl_compatibility/driver.windows" type="String" setter="" getter="" default=""opengl3""> + Windows override for [member rendering/gl_compatibility/driver]. + </member> <member name="rendering/global_illumination/gi/use_half_resolution" type="bool" setter="" getter="" default="false"> If [code]true[/code], renders [VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) buffers at halved resolution (e.g. 960×540 when the viewport size is 1920×1080). This improves performance significantly when VoxelGI or SDFGI is enabled, at the cost of artifacts that may be visible on polygon edges. The loss in quality becomes less noticeable as the viewport resolution increases. [LightmapGI] rendering is not affected by this setting. [b]Note:[/b] This property is only read when the project starts. To set half-resolution GI at run-time, call [method RenderingServer.gi_set_use_half_resolution] instead. @@ -1956,6 +1970,44 @@ <member name="rendering/reflections/sky_reflections/texture_array_reflections.mobile" type="bool" setter="" getter="" default="false"> Lower-end override for [member rendering/reflections/sky_reflections/texture_array_reflections] on mobile devices, due to performance concerns or driver support. </member> + <member name="rendering/renderer/rendering_method" type="String" setter="" getter="" default=""forward_plus""> + Sets the renderer that will be used by the project. Options are: + [b]Clustered[/b]: High-end renderer designed for Desktop devices. Has a higher base overhead, but scales well with complex scenes. Not suitable for older devices or mobile. + [b]Mobile[/b]: Modern renderer designed for mobile devices. Has a lower base overhead than Clustered, but does not scale as well to large scenes with many elements. + [b]Compatibility[/b]: Low-end renderer designed for older devices. Based on the limitations of the OpenGL 3.3/ OpenGL ES 3.0 / WebGL 2 APIs. + </member> + <member name="rendering/renderer/rendering_method.mobile" type="String" setter="" getter="" default=""forward_plus""> + Override for [member rendering/renderer/rendering_method] on mobile devices. + </member> + <member name="rendering/renderer/rendering_method.web" type="String" setter="" getter="" default=""gl_compatibility""> + Override for [member rendering/renderer/rendering_method] on web. + </member> + <member name="rendering/rendering_device/descriptor_pools/max_descriptors_per_pool" type="int" setter="" getter="" default="64"> + </member> + <member name="rendering/rendering_device/driver" type="String" setter="" getter="" default=""vulkan""> + Sets the driver to be used by the renderer when using a RenderingDevice-based renderer like the clustered renderer or the mobile renderer. This property can not be edited directly, instead, set the driver using the platform-specific overrides. + </member> + <member name="rendering/rendering_device/driver.android" type="String" setter="" getter="" default=""vulkan""> + Android override for [member rendering/rendering_device/driver]. + </member> + <member name="rendering/rendering_device/driver.ios" type="String" setter="" getter="" default=""vulkan""> + iOS override for [member rendering/rendering_device/driver]. + </member> + <member name="rendering/rendering_device/driver.linuxbsd" type="String" setter="" getter="" default=""vulkan""> + LinuxBSD override for [member rendering/rendering_device/driver]. + </member> + <member name="rendering/rendering_device/driver.macos" type="String" setter="" getter="" default=""vulkan""> + macOS override for [member rendering/rendering_device/driver]. + </member> + <member name="rendering/rendering_device/driver.windows" type="String" setter="" getter="" default=""vulkan""> + Windows override for [member rendering/rendering_device/driver]. + </member> + <member name="rendering/rendering_device/staging_buffer/block_size_kb" type="int" setter="" getter="" default="256"> + </member> + <member name="rendering/rendering_device/staging_buffer/max_size_mb" type="int" setter="" getter="" default="128"> + </member> + <member name="rendering/rendering_device/staging_buffer/texture_upload_region_size_px" type="int" setter="" getter="" default="64"> + </member> <member name="rendering/scaling_3d/fsr_sharpness" type="float" setter="" getter="" default="0.2"> Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference. </member> @@ -2037,18 +2089,6 @@ <member name="rendering/vrs/texture" type="String" setter="" getter="" default=""""> If [member rendering/vrs/mode] is set to texture, this is the path to default texture loaded as the VRS image. </member> - <member name="rendering/vulkan/descriptor_pools/max_descriptors_per_pool" type="int" setter="" getter="" default="64"> - </member> - <member name="rendering/vulkan/rendering/back_end" type="int" setter="" getter="" default="0"> - </member> - <member name="rendering/vulkan/rendering/back_end.mobile" type="int" setter="" getter="" default="1"> - </member> - <member name="rendering/vulkan/staging_buffer/block_size_kb" type="int" setter="" getter="" default="256"> - </member> - <member name="rendering/vulkan/staging_buffer/max_size_mb" type="int" setter="" getter="" default="128"> - </member> - <member name="rendering/vulkan/staging_buffer/texture_upload_region_size_px" type="int" setter="" getter="" default="64"> - </member> <member name="threading/worker_pool/low_priority_thread_ratio" type="float" setter="" getter="" default="0.3"> </member> <member name="threading/worker_pool/max_threads" type="int" setter="" getter="" default="-1"> diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 1952efff0e..85b35639ec 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1719,7 +1719,7 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b glBindBuffer(GL_UNIFORM_BUFFER, 0); } -void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_render_info) { +void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RenderingMethod::RenderInfo *r_render_info) { GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton(); GLES3::Config *config = GLES3::Config::get_singleton(); RENDER_TIMESTAMP("Setup 3D Scene"); @@ -2481,7 +2481,7 @@ RasterizerSceneGLES3::RasterizerSceneGLES3() { scene_globals.default_shader = material_storage->shader_allocate(); material_storage->shader_initialize(scene_globals.default_shader); material_storage->shader_set_code(scene_globals.default_shader, R"( -// Default 3D material shader (clustered). +// Default 3D material shader. shader_type spatial; diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index d264284ef7..f0dc972678 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -124,7 +124,7 @@ struct RenderDataGLES3 { uint32_t spot_light_count = 0; uint32_t omni_light_count = 0; - RendererScene::RenderInfo *render_info = nullptr; + RenderingMethod::RenderInfo *render_info = nullptr; }; class RasterizerCanvasGLES3; @@ -712,7 +712,7 @@ public: void voxel_gi_set_quality(RS::VoxelGIQuality) override; - void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) override; + void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingMethod::RenderInfo *r_render_info = nullptr) override; void render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override; void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<RenderGeometryInstance *> &p_instances) override; diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 73ae108961..53e9146f85 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -9367,10 +9367,10 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de // NOTE: If adding new project settings here, also duplicate their definition in // rendering_server.cpp for headless doctool. - staging_buffer_block_size = GLOBAL_DEF("rendering/vulkan/staging_buffer/block_size_kb", 256); + staging_buffer_block_size = GLOBAL_DEF("rendering/rendering_device/staging_buffer/block_size_kb", 256); staging_buffer_block_size = MAX(4u, staging_buffer_block_size); staging_buffer_block_size *= 1024; // Kb -> bytes. - staging_buffer_max_size = GLOBAL_DEF("rendering/vulkan/staging_buffer/max_size_mb", 128); + staging_buffer_max_size = GLOBAL_DEF("rendering/rendering_device/staging_buffer/max_size_mb", 128); staging_buffer_max_size = MAX(1u, staging_buffer_max_size); staging_buffer_max_size *= 1024 * 1024; @@ -9378,7 +9378,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de // Validate enough blocks. staging_buffer_max_size = staging_buffer_block_size * 4; } - texture_upload_region_size_px = GLOBAL_DEF("rendering/vulkan/staging_buffer/texture_upload_region_size_px", 64); + texture_upload_region_size_px = GLOBAL_DEF("rendering/rendering_device/staging_buffer/texture_upload_region_size_px", 64); texture_upload_region_size_px = nearest_power_of_2_templated(texture_upload_region_size_px); frames_drawn = frame_count; // Start from frame count, so everything else is immediately old. @@ -9393,7 +9393,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de ERR_CONTINUE(err != OK); } - max_descriptors_per_pool = GLOBAL_DEF("rendering/vulkan/descriptor_pools/max_descriptors_per_pool", 64); + max_descriptors_per_pool = GLOBAL_DEF("rendering/rendering_device/descriptor_pools/max_descriptors_per_pool", 64); // Check to make sure DescriptorPoolKey is good. static_assert(sizeof(uint64_t) * 3 >= UNIFORM_TYPE_MAX * sizeof(uint16_t)); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e79619e57b..6701fec541 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3069,8 +3069,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_SUPPORT_GODOT_DEVELOPMENT: { OS::get_singleton()->shell_open("https://godotengine.org/donate"); } break; - case SET_RENDERING_DRIVER_SAVE_AND_RESTART: { - ProjectSettings::get_singleton()->set("rendering/driver/driver_name", rendering_driver_request); + case SET_RENDERER_NAME_SAVE_AND_RESTART: { + ProjectSettings::get_singleton()->set("rendering/renderer/rendering_method", renderer_request); ProjectSettings::get_singleton()->save(); save_all_scenes(); @@ -5880,27 +5880,27 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) { top_split->set_visible(!p_pressed); } -void EditorNode::_update_rendering_driver_color() { - if (rendering_driver->get_text() == "opengl3") { - rendering_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); - } else if (rendering_driver->get_text() == "vulkan") { - rendering_driver->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); +void EditorNode::_update_renderer_color() { + if (renderer->get_text() == "gl_compatibility") { + renderer->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); + } else if (renderer->get_text() == "forward_plus" || renderer->get_text() == "mobile") { + renderer->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); } } -void EditorNode::_rendering_driver_selected(int p_which) { - String driver = rendering_driver->get_item_metadata(p_which); +void EditorNode::_renderer_selected(int p_which) { + String rendering_method = renderer->get_item_metadata(p_which); - String current_driver = OS::get_singleton()->get_current_rendering_driver_name(); + String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method"); - if (driver == current_driver) { + if (rendering_method == current_renderer) { return; } - rendering_driver_request = driver; + renderer_request = rendering_method; video_restart_dialog->popup_centered(); - rendering_driver->select(rendering_driver_current); - _update_rendering_driver_color(); + renderer->select(renderer_current); + _update_renderer_color(); } void EditorNode::_resource_saved(Ref<Resource> p_resource, const String &p_path) { @@ -6950,19 +6950,17 @@ EditorNode::EditorNode() { HBoxContainer *right_menu_hb = memnew(HBoxContainer); menu_hb->add_child(right_menu_hb); - rendering_driver = memnew(OptionButton); - + renderer = memnew(OptionButton); // Hide the renderer selection dropdown until OpenGL support is more mature. // The renderer can still be changed in the project settings or using `--rendering-driver opengl3`. - rendering_driver->set_visible(false); - - rendering_driver->set_flat(true); - rendering_driver->set_focus_mode(Control::FOCUS_NONE); - rendering_driver->connect("item_selected", callable_mp(this, &EditorNode::_rendering_driver_selected)); - rendering_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); - rendering_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); + renderer->set_visible(false); + renderer->set_flat(true); + renderer->set_focus_mode(Control::FOCUS_NONE); + renderer->connect("item_selected", callable_mp(this, &EditorNode::_renderer_selected)); + renderer->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + renderer->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); - right_menu_hb->add_child(rendering_driver); + right_menu_hb->add_child(renderer); if (can_expand) { // Add spacer to avoid other controls under the window minimize/maximize/close buttons (right side). @@ -6972,36 +6970,35 @@ EditorNode::EditorNode() { menu_hb->add_child(menu_spacer); } - // Only display the render drivers that are available for this display driver. - int display_driver_idx = OS::get_singleton()->get_display_driver_id(); - Vector<String> render_drivers = DisplayServer::get_create_function_rendering_drivers(display_driver_idx); - String current_rendering_driver = OS::get_singleton()->get_current_rendering_driver_name(); + String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method"); + + PackedStringArray renderers = ProjectSettings::get_singleton()->get_custom_property_info().get(StringName("rendering/renderer/rendering_method")).hint_string.split(",", false); // 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. - current_rendering_driver = current_rendering_driver.to_lower(); + current_renderer = current_renderer.to_lower(); - for (int i = 0; i < render_drivers.size(); i++) { - String driver = render_drivers[i]; + for (int i = 0; i < renderers.size(); i++) { + String rendering_method = renderers[i]; - // Add the driver to the UI. - rendering_driver->add_item(driver); - rendering_driver->set_item_metadata(i, driver); + // Add the renderers name to the UI. + renderer->add_item(rendering_method); + renderer->set_item_metadata(i, rendering_method); // Lowercase for standard comparison. - driver = driver.to_lower(); + rendering_method = rendering_method.to_lower(); - if (current_rendering_driver == driver) { - rendering_driver->select(i); - rendering_driver_current = i; + if (current_renderer == rendering_method) { + renderer->select(i); + renderer_current = i; } } - _update_rendering_driver_color(); + _update_renderer_color(); video_restart_dialog = memnew(ConfirmationDialog); - video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor.")); + video_restart_dialog->set_text(TTR("Changing the renderer requires restarting the editor.")); video_restart_dialog->set_ok_button_text(TTR("Save & Restart")); - video_restart_dialog->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind(SET_RENDERING_DRIVER_SAVE_AND_RESTART)); + video_restart_dialog->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind(SET_RENDERER_NAME_SAVE_AND_RESTART)); gui_base->add_child(video_restart_dialog); progress_hb = memnew(BackgroundProgress); diff --git a/editor/editor_node.h b/editor/editor_node.h index ac79b2d13a..14dab11358 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -224,7 +224,7 @@ private: HELP_ABOUT, HELP_SUPPORT_GODOT_DEVELOPMENT, - SET_RENDERING_DRIVER_SAVE_AND_RESTART, + SET_RENDERER_NAME_SAVE_AND_RESTART, GLOBAL_NEW_WINDOW, GLOBAL_SCENE, @@ -286,12 +286,12 @@ private: Control *theme_base = nullptr; Control *gui_base = nullptr; VBoxContainer *main_vbox = nullptr; - OptionButton *rendering_driver = nullptr; + OptionButton *renderer = nullptr; ConfirmationDialog *video_restart_dialog = nullptr; - int rendering_driver_current = 0; - String rendering_driver_request; + int renderer_current = 0; + String renderer_request; // Split containers. HSplitContainer *left_l_hsplit = nullptr; @@ -597,8 +597,8 @@ private: void _update_from_settings(); - void _rendering_driver_selected(int); - void _update_rendering_driver_color(); + void _renderer_selected(int); + void _update_renderer_color(); void _exit_editor(int p_exit_code); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index ee8148f00a..7c4326cde1 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1358,7 +1358,7 @@ void VisualShaderEditor::_update_options_menu() { Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); - static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl3"; + static bool low_driver = ProjectSettings::get_singleton()->get("rendering/renderer/rendering_method") == "gl_compatibility"; HashMap<String, TreeItem *> folders; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 69a2670418..673da8872d 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -92,9 +92,9 @@ private: Container *name_container; Container *path_container; Container *install_path_container; - Container *rasterizer_container; + Container *renderer_container; HBoxContainer *default_files_container; - Ref<ButtonGroup> rasterizer_button_group; + Ref<ButtonGroup> renderer_button_group; Label *msg; LineEdit *project_path; LineEdit *project_name; @@ -473,16 +473,19 @@ private: } PackedStringArray project_features = ProjectSettings::get_required_features(); ProjectSettings::CustomMap initial_settings; + // Be sure to change this code if/when renderers are changed. - int renderer_type = rasterizer_button_group->get_pressed_button()->get_meta(SNAME("driver_name")); - initial_settings["rendering/vulkan/rendering/back_end"] = renderer_type; - if (renderer_type == 0) { - project_features.push_back("Vulkan Clustered"); - } else if (renderer_type == 1) { - project_features.push_back("Vulkan Mobile"); + String renderer_type = renderer_button_group->get_pressed_button()->get_meta(SNAME("rendering_method")); + initial_settings["rendering/renderer/rendering_method"] = renderer_type; + + if (renderer_type == "forward_plus") { + project_features.push_back("Forward Plus"); + } else if (renderer_type == "mobile") { + project_features.push_back("Mobile"); } else { WARN_PRINT("Unknown renderer type. Please report this as a bug on GitHub."); } + project_features.sort(); initial_settings["application/config/features"] = project_features; initial_settings["application/config/name"] = project_name->get_text().strip_edges(); @@ -684,7 +687,7 @@ public: msg->hide(); install_path_container->hide(); install_status_rect->hide(); - rasterizer_container->hide(); + renderer_container->hide(); default_files_container->hide(); get_ok_button()->set_disabled(false); @@ -735,7 +738,7 @@ public: set_ok_button_text(TTR("Import & Edit")); name_container->hide(); install_path_container->hide(); - rasterizer_container->hide(); + renderer_container->hide(); default_files_container->hide(); project_path->grab_focus(); @@ -744,7 +747,7 @@ public: set_ok_button_text(TTR("Create & Edit")); name_container->show(); install_path_container->hide(); - rasterizer_container->show(); + renderer_container->show(); default_files_container->show(); project_name->call_deferred(SNAME("grab_focus")); project_name->call_deferred(SNAME("select_all")); @@ -755,7 +758,7 @@ public: project_name->set_text(zip_title); name_container->show(); install_path_container->hide(); - rasterizer_container->hide(); + renderer_container->hide(); default_files_container->hide(); project_path->grab_focus(); } @@ -843,23 +846,23 @@ public: msg->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); vb->add_child(msg); - // rasterizer selection - rasterizer_container = memnew(VBoxContainer); - vb->add_child(rasterizer_container); + // Renderer selection. + renderer_container = memnew(VBoxContainer); + vb->add_child(renderer_container); l = memnew(Label); l->set_text(TTR("Renderer:")); - rasterizer_container->add_child(l); - Container *rshb = memnew(HBoxContainer); - rasterizer_container->add_child(rshb); - rasterizer_button_group.instantiate(); + renderer_container->add_child(l); + HBoxContainer *rshc = memnew(HBoxContainer); + renderer_container->add_child(rshc); + renderer_button_group.instantiate(); Container *rvb = memnew(VBoxContainer); rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - rshb->add_child(rvb); + rshc->add_child(rvb); Button *rs_button = memnew(CheckBox); - rs_button->set_button_group(rasterizer_button_group); - rs_button->set_text(TTR("Vulkan Clustered")); - rs_button->set_meta(SNAME("driver_name"), 0); // Vulkan backend "Forward Clustered" + rs_button->set_button_group(renderer_button_group); + rs_button->set_text(TTR("Forward+")); + rs_button->set_meta(SNAME("rendering_method"), "forward_plus"); rs_button->set_pressed(true); rvb->add_child(rs_button); l = memnew(Label); @@ -871,15 +874,15 @@ public: l->set_modulate(Color(1, 1, 1, 0.7)); rvb->add_child(l); - rshb->add_child(memnew(VSeparator)); + rshc->add_child(memnew(VSeparator)); rvb = memnew(VBoxContainer); rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - rshb->add_child(rvb); + rshc->add_child(rvb); rs_button = memnew(CheckBox); - rs_button->set_button_group(rasterizer_button_group); - rs_button->set_text(TTR("Vulkan Mobile")); - rs_button->set_meta(SNAME("driver_name"), 1); // Vulkan backend "Forward Mobile" + rs_button->set_button_group(renderer_button_group); + rs_button->set_text(TTR("Mobile")); + rs_button->set_meta(SNAME("rendering_method"), "mobile"); rvb->add_child(rs_button); l = memnew(Label); l->set_text( @@ -897,7 +900,7 @@ public: l->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); l->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); l->set_modulate(Color(1, 1, 1, 0.7)); - rasterizer_container->add_child(l); + renderer_container->add_child(l); default_files_container = memnew(HBoxContainer); vb->add_child(default_files_container); diff --git a/main/main.cpp b/main/main.cpp index a338b71154..5fd3786af9 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -141,6 +141,7 @@ static bool _start_success = false; String tablet_driver = ""; String text_driver = ""; String rendering_driver = ""; +String rendering_method = ""; static int text_driver_idx = -1; static int display_driver_idx = -1; static int audio_driver_idx = -1; @@ -353,6 +354,7 @@ void Main::print_help(const char *p_binary) { } OS::get_singleton()->print("].\n"); + OS::get_singleton()->print(" --rendering-method <renderer> Renderer name. Requires driver support.\n"); OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n"); OS::get_singleton()->print(" --gpu-index <device_index> Use a specific GPU (run with --verbose to get available device list).\n"); OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n"); @@ -757,6 +759,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } if (I->get() == "--audio-driver" || I->get() == "--display-driver" || + I->get() == "--rendering-method" || I->get() == "--rendering-driver") { if (I->next()) { forwardable_cli_arguments[CLI_SCOPE_TOOL].push_back(I->get()); @@ -866,43 +869,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->print("Missing display driver argument, aborting.\n"); goto error; } + } else if (I->get() == "--rendering-method") { + if (I->next()) { + rendering_method = I->next()->get(); + N = I->next()->next(); + } else { + OS::get_singleton()->print("Missing renderer name argument, aborting.\n"); + goto error; + } } else if (I->get() == "--rendering-driver") { if (I->next()) { rendering_driver = I->next()->get(); - - // as the rendering drivers available may depend on the display driver selected, - // we can't do an exhaustive check here, but we can look through all the options in - // all the display drivers for a match - - bool found = false; - for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { - Vector<String> r_drivers = DisplayServer::get_create_function_rendering_drivers(i); - - for (int d = 0; d < r_drivers.size(); d++) { - if (rendering_driver == r_drivers[d]) { - found = true; - break; - } - } - } - - if (!found) { - OS::get_singleton()->print("Unknown rendering driver '%s', aborting.\nValid options are ", - rendering_driver.utf8().get_data()); - - for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { - Vector<String> r_drivers = DisplayServer::get_create_function_rendering_drivers(i); - - for (int d = 0; d < r_drivers.size(); d++) { - OS::get_singleton()->print("'%s', ", r_drivers[d].utf8().get_data()); - } - } - - OS::get_singleton()->print(".\n"); - - goto error; - } - N = I->next()->next(); } else { OS::get_singleton()->print("Missing rendering driver argument, aborting.\n"); @@ -1485,45 +1462,188 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_cmdline(execpath, main_args, user_args); - // possibly be worth changing the default from vulkan to something lower spec, - // for the project manager, depending on how smooth the fallback is. + { + String driver_hints = ""; +#ifdef VULKAN_ENABLED + driver_hints = "vulkan"; +#endif - // this list is hard coded, which makes it more difficult to add new backends. - // can potentially be changed to more of a plugin system at a later date. + String default_driver = driver_hints.get_slice(",", 0); + + // For now everything defaults to vulkan when available. This can change in future updates. + GLOBAL_DEF("rendering/rendering_device/driver", default_driver); + GLOBAL_DEF("rendering/rendering_device/driver.windows", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/rendering_device/driver.windows", + PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/rendering_device/driver.linuxbsd", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/rendering_device/driver.linuxbsd", + PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/rendering_device/driver.android", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/rendering_device/driver.android", + PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/rendering_device/driver.ios", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/rendering_device/driver.ios", + PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/rendering_device/driver.macos", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/rendering_device/driver.macos", + PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, driver_hints)); + + driver_hints = ""; +#ifdef GLES3_ENABLED + driver_hints += "opengl3"; +#endif - // Start with Vulkan, which will be the default if enabled. + default_driver = driver_hints.get_slice(",", 0); + + GLOBAL_DEF("rendering/gl_compatibility/driver", default_driver); + GLOBAL_DEF("rendering/gl_compatibility/driver.windows", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.windows", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.windows", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/gl_compatibility/driver.linuxbsd", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.linuxbsd", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/gl_compatibility/driver.web", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.web", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.web", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/gl_compatibility/driver.android", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.android", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.android", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/gl_compatibility/driver.ios", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.ios", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.ios", PROPERTY_HINT_ENUM, driver_hints)); + GLOBAL_DEF("rendering/gl_compatibility/driver.macos", default_driver); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/gl_compatibility/driver.macos", + PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.macos", PROPERTY_HINT_ENUM, driver_hints)); + } + + // Start with RenderingDevice-based backends. Should be included if any RD driver present. #ifdef VULKAN_ENABLED - renderer_hints = "vulkan"; + renderer_hints = "forward_plus,mobile"; #endif - // And OpenGL3 next, or first if Vulkan is disabled. + // And Compatibility next, or first if Vulkan is disabled. #ifdef GLES3_ENABLED if (!renderer_hints.is_empty()) { renderer_hints += ","; } - renderer_hints += "opengl3"; + renderer_hints += "gl_compatibility"; #endif if (renderer_hints.is_empty()) { - ERR_PRINT("No rendering driver available."); + ERR_PRINT("No renderers available."); + } + + if (!rendering_method.is_empty()) { + if (rendering_method != "forward_plus" && + rendering_method != "mobile" && + rendering_method != "gl_compatibility") { + OS::get_singleton()->print("Unknown renderer name '%s', aborting. Valid options are: %s\n", rendering_method.utf8().get_data(), renderer_hints.utf8().get_data()); + goto error; + } + } + + if (!rendering_driver.is_empty()) { + // As the rendering drivers available may depend on the display driver and renderer + // selected, we can't do an exhaustive check here, but we can look through all + // the options in all the display drivers for a match. + + bool found = false; + for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { + Vector<String> r_drivers = DisplayServer::get_create_function_rendering_drivers(i); + + for (int d = 0; d < r_drivers.size(); d++) { + if (rendering_driver == r_drivers[d]) { + found = true; + break; + } + } + } + + if (!found) { + OS::get_singleton()->print("Unknown rendering driver '%s', aborting.\nValid options are ", + rendering_driver.utf8().get_data()); + + for (int i = 0; i < DisplayServer::get_create_function_count(); i++) { + Vector<String> r_drivers = DisplayServer::get_create_function_rendering_drivers(i); + + for (int d = 0; d < r_drivers.size(); d++) { + OS::get_singleton()->print("'%s', ", r_drivers[d].utf8().get_data()); + } + } + + OS::get_singleton()->print(".\n"); + + goto error; + } + + // Set a default renderer if none selected. Try to choose one that matches the driver. + if (rendering_method.is_empty()) { + if (rendering_driver == "opengl3") { + rendering_method = "gl_compatibility"; + } else { + rendering_method = "forward_plus"; + } + } + + // Now validate whether the selected driver matches with the renderer. + bool valid_combination = false; + Vector<String> available_drivers; + if (rendering_method == "forward_plus" || rendering_method == "mobile") { + available_drivers.push_back("vulkan"); + } else if (rendering_method == "gl_compatibility") { + available_drivers.push_back("opengl3"); + } else { + OS::get_singleton()->print("Unknown renderer name '%s', aborting.\n", rendering_method.utf8().get_data()); + goto error; + } + + for (int i = 0; i < available_drivers.size(); i++) { + if (rendering_driver == available_drivers[i]) { + valid_combination = true; + break; + } + } + + if (!valid_combination) { + OS::get_singleton()->print("Invalid renderer/driver combination '%s' and '%s', aborting. %s only supports the following drivers ", rendering_method.utf8().get_data(), rendering_driver.utf8().get_data(), rendering_method.utf8().get_data()); + + for (int d = 0; d < available_drivers.size(); d++) { + OS::get_singleton()->print("'%s', ", available_drivers[d].utf8().get_data()); + } + + OS::get_singleton()->print(".\n"); + + goto error; + } } default_renderer = renderer_hints.get_slice(",", 0); - GLOBAL_DEF_RST("rendering/driver/driver_name", default_renderer); + GLOBAL_DEF_RST_BASIC("rendering/renderer/rendering_method", default_renderer); + GLOBAL_DEF_RST_BASIC("rendering/renderer/rendering_method.mobile", default_renderer); + GLOBAL_DEF_RST_BASIC("rendering/renderer/rendering_method.web", "gl_compatibility"); // This is a bit of a hack until we have WebGPU support. - ProjectSettings::get_singleton()->set_custom_property_info("rendering/driver/driver_name", + ProjectSettings::get_singleton()->set_custom_property_info("rendering/renderer/rendering_method", PropertyInfo(Variant::STRING, - "rendering/driver/driver_name", + "rendering/renderer/rendering_method", PROPERTY_HINT_ENUM, renderer_hints)); - // if not set on the command line + // Default to ProjectSettings default if nothing set on the command line. + if (rendering_method.is_empty()) { + rendering_method = GLOBAL_GET("rendering/renderer/rendering_method"); + } + if (rendering_driver.is_empty()) { - rendering_driver = GLOBAL_GET("rendering/driver/driver_name"); + if (rendering_method == "gl_compatibility") { + rendering_driver = GLOBAL_GET("rendering/gl_compatibility/driver"); + } else { + rendering_driver = GLOBAL_GET("rendering/rendering_device/driver"); + } } // note this is the desired rendering driver, it doesn't mean we will get it. // TODO - make sure this is updated in the case of fallbacks, so that the user interface // shows the correct driver string. OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + OS::get_singleton()->set_current_rendering_method(rendering_method); // always convert to lower case for consistency in the code rendering_driver = rendering_driver.to_lower(); diff --git a/misc/dist/shell/_godot.zsh-completion b/misc/dist/shell/_godot.zsh-completion index b17bb6e66b..2bc6fe9317 100644 --- a/misc/dist/shell/_godot.zsh-completion +++ b/misc/dist/shell/_godot.zsh-completion @@ -44,6 +44,7 @@ _arguments \ '--remote-fs-password[password for remote filesystem]:remote filesystem password' \ '--audio-driver[set the audio driver]:audio driver name' \ '--display-driver[set the display driver]:display driver name' \ + "--rendering-method[set the renderer]:renderer name:((forward_plus\:'Desktop renderer' mobile\:'Desktop and mobile renderer' gl_compatibility\:'Desktop, mobile and web renderer'))" \ "--rendering-driver[set the rendering driver]:rendering driver name:((vulkan\:'Vulkan renderer' opengl3\:'OpenGL ES 3.0 renderer' dummy\:'Dummy renderer'))" \ "--gpu-index[use a specific GPU (run with --verbose to get available device list)]:device index" \ '--text-driver[set the text driver]:text driver name' \ diff --git a/misc/dist/shell/godot.bash-completion b/misc/dist/shell/godot.bash-completion index 1ab687e1fc..bc5fa600f5 100644 --- a/misc/dist/shell/godot.bash-completion +++ b/misc/dist/shell/godot.bash-completion @@ -47,6 +47,7 @@ _complete_godot_options() { --remote-fs-password --audio-driver --display-driver +--rendering-method --rendering-driver --gpu-index --text-driver @@ -58,7 +59,6 @@ _complete_godot_options() { --always-on-top --resolution --position ---headless --single-window --debug --breakpoints @@ -112,6 +112,10 @@ _complete_godot_bash() { local IFS=$' \n\t' # shellcheck disable=SC2207 COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur")) + elif [[ $prev == "--rendering-method" ]]; then + local IFS=$' \n\t' + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "forward_plus mobile gl_compatibility" -- "$cur")) elif [[ $prev == "--rendering-driver" ]]; then local IFS=$' \n\t' # shellcheck disable=SC2207 diff --git a/misc/dist/shell/godot.fish b/misc/dist/shell/godot.fish index d58066c135..9ac692eace 100644 --- a/misc/dist/shell/godot.fish +++ b/misc/dist/shell/godot.fish @@ -23,6 +23,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +function godot_rendering_method_args + # Use a function instead of a fixed string to customize the argument descriptions. + echo -e "forward_plus\tHigh-end desktop renderer" + echo -e "mobile\tHigh-end mobile/desktop renderer" + echo -e "gl_compatibility\tLow-end desktop, mobile and web renderer" +end + function godot_rendering_driver_args # Use a function instead of a fixed string to customize the argument descriptions. echo -e "vulkan\tVulkan renderer" @@ -53,6 +60,7 @@ complete -c godot -l remote-fs -d "Use a remote filesystem (<host/IP>[:<port>] a complete -c godot -l remote-fs-password -d "Password for remote filesystem" -x complete -c godot -l audio-driver -d "Set the audio driver" -x complete -c godot -l display-driver -d "Set the display driver" -x +complete -c godot -l rendering-method -d "Set the renderer" -x -a "(godot_rendering_method_args)" complete -c godot -l rendering-driver -d "Set the rendering driver" -x -a "(godot_rendering_driver_args)" complete -c godot -l gpu-index -d "Use a specific GPU (run with --verbose to get available device list)" -x complete -c godot -l text-driver -d "Set the text driver" -x diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index e5656bd00b..366bd1c48c 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1669,14 +1669,7 @@ Vector<String> EditorExportPlatformAndroid::get_enabled_abis(const Ref<EditorExp } void EditorExportPlatformAndroid::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const { - String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); - if (driver == "opengl3") { - r_features->push_back("etc"); - } - // FIXME: Review what texture formats are used for Vulkan. - if (driver == "vulkan") { - r_features->push_back("etc2"); - } + r_features->push_back("etc2"); Vector<String> abis = get_enabled_abis(p_preset); for (int i = 0; i < abis.size(); ++i) { diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index 8d370a31a4..2f53942f76 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -189,9 +189,7 @@ String bool_to_string(bool v) { } String _get_gles_tag() { - bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES3" && - !ProjectSettings::get_singleton()->get("rendering/driver/fallback_to_gles2"); - return min_gles3 ? " <uses-feature android:glEsVersion=\"0x00030000\" android:required=\"true\" />\n" : ""; + return " <uses-feature android:glEsVersion=\"0x00030000\" android:required=\"true\" />\n"; } String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index a75c69484c..92e5e59496 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -274,11 +274,11 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return false; } - final String videoDriver = GodotLib.getGlobal("rendering/driver/driver_name"); - if (videoDriver.equals("vulkan")) { - mRenderView = new GodotVulkanRenderView(activity, this); - } else { + final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method"); + if (renderer.equals("gl_compatibility")) { mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl); + } else { + mRenderView = new GodotVulkanRenderView(activity, this); } View view = mRenderView.getView(); diff --git a/platform/ios/display_layer.mm b/platform/ios/display_layer.mm index 7c83494768..74c760ae9a 100644 --- a/platform/ios/display_layer.mm +++ b/platform/ios/display_layer.mm @@ -89,12 +89,12 @@ // FIXME: Add Vulkan support via MoltenVK. Add fallback code back? - // Create GL ES 2 context - if (GLOBAL_GET("rendering/driver/driver_name") == "opengl3") { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - NSLog(@"Setting up an OpenGL ES 2.0 context."); + // Create GL ES 3 context + if (GLOBAL_GET("rendering/renderer/rendering_method") == "gl_compatibility") { + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; + NSLog(@"Setting up an OpenGL ES 3.0 context."); if (!context) { - NSLog(@"Failed to create OpenGL ES 2.0 context!"); + NSLog(@"Failed to create OpenGL ES 3.0 context!"); return; } } diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index 74d6bc2e97..d3a0f38463 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -62,7 +62,7 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode // Note that we should be checking "opengl3" as the driver, might never enable this seeing OpenGL is deprecated on iOS // We are hardcoding the rendering_driver to "vulkan" down below - if (rendering_driver == "opengl_es") { + if (rendering_driver == "opengl3") { bool gl_initialization_error = false; // FIXME: Add Vulkan support via MoltenVK. Add fallback code back? @@ -163,7 +163,7 @@ Vector<String> DisplayServerIOS::get_rendering_drivers_func() { drivers.push_back("vulkan"); #endif #if defined(GLES3_ENABLED) - drivers.push_back("opengl_es"); + drivers.push_back("opengl3"); #endif return drivers; diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 7aacb2de85..74a57dc614 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -34,7 +34,6 @@ #include "editor/editor_node.h" void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const { - String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); // Vulkan and OpenGL ES 3.0 both mandate ETC2 support. r_features->push_back("etc2"); diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index 9ed219508c..ff90c05b1d 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -74,7 +74,7 @@ static const float earth_gravity = 9.80665; if ([driverName isEqualToString:@"vulkan"]) { layer = [GodotMetalLayer layer]; - } else if ([driverName isEqualToString:@"opengl_es"]) { + } else if ([driverName isEqualToString:@"opengl3"]) { if (@available(iOS 13, *)) { NSLog(@"OpenGL ES is deprecated on iOS 13"); } diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 306453c1eb..1c327fe4b2 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -307,13 +307,7 @@ void EditorExportPlatformWeb::get_preset_features(const Ref<EditorExportPreset> } if (p_preset->get("vram_texture_compression/for_mobile")) { - String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name"); - if (driver == "opengl3") { - r_features->push_back("etc"); - } else if (driver == "vulkan") { - // FIXME: Review if this is correct. - r_features->push_back("etc2"); - } + r_features->push_back("etc2"); } r_features->push_back("wasm32"); } diff --git a/servers/rendering/dummy/rasterizer_scene_dummy.h b/servers/rendering/dummy/rasterizer_scene_dummy.h index 4a2a947b94..e41373ed37 100644 --- a/servers/rendering/dummy/rasterizer_scene_dummy.h +++ b/servers/rendering/dummy/rasterizer_scene_dummy.h @@ -180,7 +180,7 @@ public: void voxel_gi_set_quality(RS::VoxelGIQuality) override {} - void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_info = nullptr) override {} + void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingMethod::RenderInfo *r_info = nullptr) override {} void render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override {} void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<RenderGeometryInstance *> &p_instances) override {} diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index 78d4ded617..8e04191e35 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -34,7 +34,7 @@ #include "servers/rendering/environment/renderer_fog.h" #include "servers/rendering/environment/renderer_gi.h" #include "servers/rendering/renderer_canvas_render.h" -#include "servers/rendering/renderer_scene.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering/storage/camera_attributes_storage.h" #include "servers/rendering/storage/light_storage.h" #include "servers/rendering/storage/material_storage.h" diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 2ad73960a0..63fd10886d 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -1538,7 +1538,7 @@ void RenderForwardClustered::_render_shadow_begin() { scene_state.instance_data[RENDER_LIST_SECONDARY].clear(); } -void RenderForwardClustered::_render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end, RendererScene::RenderInfo *p_render_info) { +void RenderForwardClustered::_render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end, RenderingMethod::RenderInfo *p_render_info) { uint32_t shadow_pass_index = scene_state.shadow_passes.size(); SceneState::ShadowPass shadow_pass; diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index 16f6da34f8..cde241f231 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -564,7 +564,7 @@ protected: virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override; virtual void _render_shadow_begin() override; - virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RendererScene::RenderInfo *p_render_info = nullptr) override; + virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RenderingMethod::RenderInfo *p_render_info = nullptr) override; virtual void _render_shadow_process() override; virtual void _render_shadow_end(uint32_t p_barrier = RD::BARRIER_MASK_ALL) override; diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp index bea31dc927..6c1b69148c 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp @@ -929,7 +929,7 @@ void RenderForwardMobile::_render_shadow_begin() { render_list[RENDER_LIST_SECONDARY].clear(); } -void RenderForwardMobile::_render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end, RendererScene::RenderInfo *p_render_info) { +void RenderForwardMobile::_render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, const Rect2i &p_rect, bool p_flip_y, bool p_clear_region, bool p_begin, bool p_end, RenderingMethod::RenderInfo *p_render_info) { uint32_t shadow_pass_index = scene_state.shadow_passes.size(); SceneState::ShadowPass shadow_pass; diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h index 04b2b3ce18..1b31d2749d 100644 --- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h @@ -209,7 +209,7 @@ protected: virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override; virtual void _render_shadow_begin() override; - virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RendererScene::RenderInfo *p_render_info = nullptr) override; + virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RenderingMethod::RenderInfo *p_render_info = nullptr) override; virtual void _render_shadow_process() override; virtual void _render_shadow_end(uint32_t p_barrier = RD::BARRIER_MASK_ALL) override; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index e7abcf5674..f169692ea0 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -299,14 +299,19 @@ RendererCompositorRD::RendererCompositorRD() { fog = memnew(RendererRD::Fog); canvas = memnew(RendererCanvasRenderRD()); - back_end = (bool)(int)GLOBAL_GET("rendering/vulkan/rendering/back_end"); + String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method"); uint64_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE); - if (back_end || textures_per_stage < 48) { + if (rendering_method == "mobile" || textures_per_stage < 48) { scene = memnew(RendererSceneRenderImplementation::RenderForwardMobile()); - } else { // back_end == false + if (rendering_method == "forward_plus") { + WARN_PRINT_ONCE("Platform supports less than 48 textures per stage which is less than required by the Clustered renderer. Defaulting to Mobile renderer."); + } + } else if (rendering_method == "forward_plus") { // default to our high end renderer scene = memnew(RendererSceneRenderImplementation::RenderForwardClustered()); + } else { + ERR_FAIL_MSG("Cannot instantiate RenderingDevice-based renderer with renderer type " + rendering_method); } scene->init(); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 7841e36244..2190f41603 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -3056,7 +3056,7 @@ void RendererSceneRenderRD::_pre_opaque_render(RenderDataRD *p_render_data, bool } } -void RendererSceneRenderRD::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_render_info) { +void RendererSceneRenderRD::render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RenderingMethod::RenderInfo *r_render_info) { RendererRD::TextureStorage *texture_storage = RendererRD::TextureStorage::get_singleton(); // getting this here now so we can direct call a bunch of things more easily @@ -3297,7 +3297,7 @@ void RendererSceneRenderRD::_debug_draw_cluster(Ref<RenderSceneBuffersRD> p_rend } } -void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, bool p_open_pass, bool p_close_pass, bool p_clear_region, RendererScene::RenderInfo *p_render_info) { +void RendererSceneRenderRD::_render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, const Plane &p_camera_plane, float p_lod_distance_multiplier, float p_screen_mesh_lod_threshold, bool p_open_pass, bool p_close_pass, bool p_clear_region, RenderingMethod::RenderInfo *p_render_info) { LightInstance *light_instance = light_instance_owner.get_or_null(p_light); ERR_FAIL_COND(!light_instance); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index b3a355f42f..82dc2fd09f 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -47,9 +47,9 @@ #include "servers/rendering/renderer_rd/framebuffer_cache_rd.h" #include "servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h" #include "servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h" -#include "servers/rendering/renderer_scene.h" #include "servers/rendering/renderer_scene_render.h" #include "servers/rendering/rendering_device.h" +#include "servers/rendering/rendering_method.h" struct RenderDataRD { Ref<RenderSceneBuffersRD> render_buffers; @@ -76,7 +76,7 @@ struct RenderDataRD { uint32_t directional_light_count = 0; bool directional_light_soft_shadows = false; - RendererScene::RenderInfo *render_info = nullptr; + RenderingMethod::RenderInfo *render_info = nullptr; }; class RendererSceneRenderRD : public RendererSceneRender { @@ -101,7 +101,7 @@ protected: virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_color) = 0; virtual void _render_shadow_begin() = 0; - virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RendererScene::RenderInfo *p_render_info = nullptr) = 0; + virtual void _render_shadow_append(RID p_framebuffer, const PagedArray<RenderGeometryInstance *> &p_instances, const Projection &p_projection, const Transform3D &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0.0, float p_screen_mesh_lod_threshold = 0.0, const Rect2i &p_rect = Rect2i(), bool p_flip_y = false, bool p_clear_region = true, bool p_begin = true, bool p_end = true, RenderingMethod::RenderInfo *p_render_info = nullptr) = 0; virtual void _render_shadow_process() = 0; virtual void _render_shadow_end(uint32_t p_barrier = RD::BARRIER_MASK_ALL) = 0; @@ -580,7 +580,7 @@ private: uint32_t max_cluster_elements = 512; - void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0, float p_screen_mesh_lod_threshold = 0.0, bool p_open_pass = true, bool p_close_pass = true, bool p_clear_region = true, RendererScene::RenderInfo *p_render_info = nullptr); + void _render_shadow_pass(RID p_light, RID p_shadow_atlas, int p_pass, const PagedArray<RenderGeometryInstance *> &p_instances, const Plane &p_camera_plane = Plane(), float p_lod_distance_multiplier = 0, float p_screen_mesh_lod_threshold = 0.0, bool p_open_pass = true, bool p_close_pass = true, bool p_clear_region = true, RenderingMethod::RenderInfo *p_render_info = nullptr); /* Volumetric Fog */ @@ -946,7 +946,7 @@ public: virtual void update_uniform_sets(){}; - virtual void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) override; + virtual void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingMethod::RenderInfo *r_render_info = nullptr) override; virtual void render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override; diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h index adaf075f80..1975eec7b0 100644 --- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h +++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.h @@ -35,8 +35,8 @@ #include "servers/rendering/renderer_rd/effects/vrs.h" #include "servers/rendering/renderer_rd/framebuffer_cache_rd.h" #include "servers/rendering/renderer_rd/storage_rd/render_buffer_custom_data_rd.h" -#include "servers/rendering/renderer_scene.h" #include "servers/rendering/rendering_device.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering/storage/render_scene_buffers.h" // These can be retired in due time diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 04dedc0646..c2dece8b46 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2910,7 +2910,7 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul } } -void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_camera_data, const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, RID p_force_camera_attributes, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, bool p_using_shadows, RendererScene::RenderInfo *r_render_info) { +void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_camera_data, const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, RID p_force_camera_attributes, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, bool p_using_shadows, RenderingMethod::RenderInfo *r_render_info) { Instance *render_reflection_probe = instance_owner.get_or_null(p_reflection_probe); //if null, not rendering to it Scenario *scenario = scenario_owner.get_or_null(p_scenario); diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index c799553f87..fedaac99b1 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -39,13 +39,13 @@ #include "core/templates/pass_func.h" #include "core/templates/rid_owner.h" #include "core/templates/self_list.h" -#include "servers/rendering/renderer_scene.h" #include "servers/rendering/renderer_scene_occlusion_cull.h" #include "servers/rendering/renderer_scene_render.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering/storage/utilities.h" #include "servers/xr/xr_interface.h" -class RendererSceneCull : public RendererScene { +class RendererSceneCull : public RenderingMethod { public: RendererSceneRender *scene_render = nullptr; @@ -1058,7 +1058,7 @@ public: void _render_scene(const RendererSceneRender::CameraData *p_camera_data, const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, RID p_force_camera_attributes, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, bool p_using_shadows = true, RenderInfo *r_render_info = nullptr); void render_empty_scene(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_scenario, RID p_shadow_atlas); - void render_camera(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_camera, RID p_scenario, RID p_viewport, Size2 p_viewport_size, bool p_use_taa, float p_screen_mesh_lod_threshold, RID p_shadow_atlas, Ref<XRInterface> &p_xr_interface, RendererScene::RenderInfo *r_render_info = nullptr); + void render_camera(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_camera, RID p_scenario, RID p_viewport, Size2 p_viewport_size, bool p_use_taa, float p_screen_mesh_lod_threshold, RID p_shadow_atlas, Ref<XRInterface> &p_xr_interface, RenderingMethod::RenderInfo *r_render_info = nullptr); void update_dirty_instances(); void render_particle_colliders(); diff --git a/servers/rendering/renderer_scene_render.h b/servers/rendering/renderer_scene_render.h index 9aa4108412..34f4980f05 100644 --- a/servers/rendering/renderer_scene_render.h +++ b/servers/rendering/renderer_scene_render.h @@ -34,7 +34,7 @@ #include "core/math/projection.h" #include "core/templates/paged_array.h" #include "servers/rendering/renderer_geometry_instance.h" -#include "servers/rendering/renderer_scene.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering/storage/environment_storage.h" #include "storage/render_scene_buffers.h" #include "storage/utilities.h" @@ -320,7 +320,7 @@ public: void set_multiview_camera(uint32_t p_view_count, const Transform3D *p_transforms, const Projection *p_projections, bool p_is_orthogonal, bool p_vaspect); }; - virtual void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) = 0; + virtual void render_scene(const Ref<RenderSceneBuffers> &p_render_buffers, const CameraData *p_camera_data, const CameraData *p_prev_camera_data, const PagedArray<RenderGeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_attributes, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RenderingMethod::RenderInfo *r_render_info = nullptr) = 0; virtual void render_material(const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, const PagedArray<RenderGeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) = 0; virtual void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<RenderGeometryInstance *> &p_instances) = 0; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 54d07dd3e1..2b05e23a96 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -220,7 +220,7 @@ 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") { + if (OS::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); } diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index 08ba6abc74..55058a30b8 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -34,8 +34,8 @@ #include "core/templates/local_vector.h" #include "core/templates/rid_owner.h" #include "core/templates/self_list.h" -#include "servers/rendering/renderer_scene.h" #include "servers/rendering/renderer_scene_render.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering_server.h" #include "servers/xr/xr_interface.h" #include "storage/render_scene_buffers.h" @@ -148,7 +148,7 @@ public: HashMap<RID, CanvasData> canvas_map; - RendererScene::RenderInfo render_info; + RenderingMethod::RenderInfo render_info; Viewport() { view_count = 1; diff --git a/servers/rendering/renderer_scene.cpp b/servers/rendering/rendering_method.cpp index b3fdd88626..16a4e35ad3 100644 --- a/servers/rendering/renderer_scene.cpp +++ b/servers/rendering/rendering_method.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* renderer_scene.cpp */ +/* rendering_method.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "renderer_scene.h" +#include "rendering_method.h" -RendererScene::RendererScene() { +RenderingMethod::RenderingMethod() { } -RendererScene::~RendererScene() { +RenderingMethod::~RenderingMethod() { } diff --git a/servers/rendering/renderer_scene.h b/servers/rendering/rendering_method.h index 29c65fcffb..a178b00424 100644 --- a/servers/rendering/renderer_scene.h +++ b/servers/rendering/rendering_method.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* renderer_scene.h */ +/* rendering_method.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RENDERER_SCENE_H -#define RENDERER_SCENE_H +#ifndef RENDERING_METHOD_H +#define RENDERING_METHOD_H #include "servers/rendering/storage/render_scene_buffers.h" #include "servers/rendering_server.h" #include "servers/xr/xr_interface.h" -class RendererScene { +class RenderingMethod { public: virtual RID camera_allocate() = 0; virtual void camera_initialize(RID p_rid) = 0; @@ -318,8 +318,8 @@ public: virtual bool free(RID p_rid) = 0; - RendererScene(); - virtual ~RendererScene(); + RenderingMethod(); + virtual ~RenderingMethod(); }; -#endif // RENDERER_SCENE_H +#endif // RENDERING_METHOD_H diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index dfe16431bd..5ee29d5e2a 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -550,7 +550,7 @@ public: #undef server_name #undef ServerName //from now on, calls forwarded to this singleton -#define ServerName RendererScene +#define ServerName RenderingMethod #define server_name RSG::scene /* CAMERA API */ @@ -649,7 +649,7 @@ public: #undef server_name #undef ServerName //from now on, calls forwarded to this singleton -#define ServerName RendererScene +#define ServerName RenderingMethod #define server_name RSG::scene FUNC2(directional_shadow_atlas_set_size, int, bool) @@ -739,7 +739,7 @@ public: #undef server_name #undef ServerName -#define ServerName RendererScene +#define ServerName RenderingMethod #define server_name RSG::scene FUNCRIDSPLIT(scenario) diff --git a/servers/rendering/rendering_server_globals.cpp b/servers/rendering/rendering_server_globals.cpp index ce7383a03f..ca24042ef9 100644 --- a/servers/rendering/rendering_server_globals.cpp +++ b/servers/rendering/rendering_server_globals.cpp @@ -46,4 +46,4 @@ RendererCompositor *RenderingServerGlobals::rasterizer = nullptr; RendererCanvasCull *RenderingServerGlobals::canvas = nullptr; RendererViewport *RenderingServerGlobals::viewport = nullptr; -RendererScene *RenderingServerGlobals::scene = nullptr; +RenderingMethod *RenderingServerGlobals::scene = nullptr; diff --git a/servers/rendering/rendering_server_globals.h b/servers/rendering/rendering_server_globals.h index 6c4ab5a26e..23f3810ce8 100644 --- a/servers/rendering/rendering_server_globals.h +++ b/servers/rendering/rendering_server_globals.h @@ -35,7 +35,7 @@ #include "servers/rendering/environment/renderer_gi.h" #include "servers/rendering/renderer_canvas_cull.h" #include "servers/rendering/renderer_canvas_render.h" -#include "servers/rendering/renderer_scene.h" +#include "servers/rendering/rendering_method.h" #include "servers/rendering/storage/camera_attributes_storage.h" #include "servers/rendering/storage/light_storage.h" #include "servers/rendering/storage/material_storage.h" @@ -46,7 +46,7 @@ class RendererCanvasCull; class RendererViewport; -class RendererScene; +class RenderingMethod; class RenderingServerGlobals { public: @@ -66,7 +66,7 @@ public: static RendererCanvasCull *canvas; static RendererViewport *viewport; - static RendererScene *scene; + static RenderingMethod *scene; }; #define RSG RenderingServerGlobals diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index cbcfc8fe49..b9df0ec8ac 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2863,18 +2863,12 @@ void RenderingServer::init() { GLOBAL_DEF("rendering/2d/shadow_atlas/size", 2048); - GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end", 0); - GLOBAL_DEF_RST_BASIC("rendering/vulkan/rendering/back_end.mobile", 1); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/vulkan/rendering/back_end", - PropertyInfo(Variant::INT, - "rendering/vulkan/rendering/back_end", - PROPERTY_HINT_ENUM, "Forward Clustered (Supports Desktop Only),Forward Mobile (Supports Desktop and Mobile)")); // Already defined in RenderingDeviceVulkan::initialize which runs before this code. // We re-define them here just for doctool's sake. Make sure to keep default values in sync. - GLOBAL_DEF("rendering/vulkan/staging_buffer/block_size_kb", 256); - GLOBAL_DEF("rendering/vulkan/staging_buffer/max_size_mb", 128); - GLOBAL_DEF("rendering/vulkan/staging_buffer/texture_upload_region_size_px", 64); - GLOBAL_DEF("rendering/vulkan/descriptor_pools/max_descriptors_per_pool", 64); + GLOBAL_DEF("rendering/rendering_device/staging_buffer/block_size_kb", 256); + GLOBAL_DEF("rendering/rendering_device/staging_buffer/max_size_mb", 128); + GLOBAL_DEF("rendering/rendering_device/staging_buffer/texture_upload_region_size_px", 64); + GLOBAL_DEF("rendering/rendering_device/descriptor_pools/max_descriptors_per_pool", 64); GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true); GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true); |