Skip to content

Commit 413b794

Browse files
committed
Merge pull request godotengine#103026 from bruvzg/drv_names
Always allow selecting any rendering driver in the settings, add "auto" option.
2 parents cbb22ca + dea20c4 commit 413b794

File tree

2 files changed

+79
-65
lines changed

2 files changed

+79
-65
lines changed

doc/classes/ProjectSettings.xml

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,26 +2684,38 @@
26842684
<member name="rendering/environment/volumetric_fog/volume_size" type="int" setter="" getter="" default="64">
26852685
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.
26862686
</member>
2687-
<member name="rendering/gl_compatibility/driver" type="String" setter="" getter="">
2687+
<member name="rendering/gl_compatibility/driver" type="String" setter="" getter="" default="&quot;auto&quot;">
26882688
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.
2689-
</member>
2690-
<member name="rendering/gl_compatibility/driver.android" type="String" setter="" getter="">
2689+
Supported values are:
2690+
- [code]auto[/code], currently defaults to [code]opengl3[/code] on all platforms.
2691+
- [code]opengl3[/code], OpenGL 3.3 on desktop platforms, OpenGL ES 3.0 on mobile platforms, WebGL 2.0 on web.
2692+
- [code]opengl3_angle[/code], OpenGL ES 3.0 over ANGLE compatibility layer, supported on macOS (over native OpenGL) and Windows (over Direct3D 11).
2693+
- [code]opengl3_es[/code], OpenGL ES 3.0 on Linux/BSD.
2694+
[b]Note:[/b] The availability of these options depends on whether the engine was compiled with support for them (determined by SCons options [code]opengl3[/code] and [code]angle_libs[/code]).
2695+
</member>
2696+
<member name="rendering/gl_compatibility/driver.android" type="String" setter="" getter="" default="&quot;auto&quot;">
26912697
Android override for [member rendering/gl_compatibility/driver].
2698+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform.
26922699
</member>
2693-
<member name="rendering/gl_compatibility/driver.ios" type="String" setter="" getter="">
2700+
<member name="rendering/gl_compatibility/driver.ios" type="String" setter="" getter="" default="&quot;auto&quot;">
26942701
iOS override for [member rendering/gl_compatibility/driver].
2702+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform.
26952703
</member>
2696-
<member name="rendering/gl_compatibility/driver.linuxbsd" type="String" setter="" getter="">
2704+
<member name="rendering/gl_compatibility/driver.linuxbsd" type="String" setter="" getter="" default="&quot;auto&quot;">
26972705
LinuxBSD override for [member rendering/gl_compatibility/driver].
2706+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform. [code]opengl3_es[/code] is available as an option, which is also used as a fallback on devices that don't support OpenGL 3.3.
26982707
</member>
2699-
<member name="rendering/gl_compatibility/driver.macos" type="String" setter="" getter="">
2708+
<member name="rendering/gl_compatibility/driver.macos" type="String" setter="" getter="" default="&quot;auto&quot;">
27002709
macOS override for [member rendering/gl_compatibility/driver].
2710+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform. [code]opengl3_angle[/code] is available as an option if ANGLE support was compiled in.
27012711
</member>
2702-
<member name="rendering/gl_compatibility/driver.web" type="String" setter="" getter="">
2712+
<member name="rendering/gl_compatibility/driver.web" type="String" setter="" getter="" default="&quot;auto&quot;">
27032713
Web override for [member rendering/gl_compatibility/driver].
2714+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform.
27042715
</member>
2705-
<member name="rendering/gl_compatibility/driver.windows" type="String" setter="" getter="">
2716+
<member name="rendering/gl_compatibility/driver.windows" type="String" setter="" getter="" default="&quot;auto&quot;">
27062717
Windows override for [member rendering/gl_compatibility/driver].
2718+
The [code]auto[/code] setting is equivalent to [code]opengl3[/code] on this platform. [code]opengl3_angle[/code] is available as an option if ANGLE supported was compiled in. In such case, ANGLE is used preferentially on lower end devices with known problematic native OpenGL drivers (see [member rendering/gl_compatibility/force_angle_on_devices]).
27072719
</member>
27082720
<member name="rendering/gl_compatibility/fallback_to_angle" type="bool" setter="" getter="" default="true">
27092721
If [code]true[/code], the compatibility renderer will fall back to ANGLE if native OpenGL is not supported or the device is listed in [member rendering/gl_compatibility/force_angle_on_devices].
@@ -2969,24 +2981,40 @@
29692981
The number of entries in the sampler descriptors heap the Direct3D 12 rendering driver uses each frame, used for most rendering operations.
29702982
Depending on the complexity of scenes, this value may be lowered or may need to be raised.
29712983
</member>
2972-
<member name="rendering/rendering_device/driver" type="String" setter="" getter="">
2984+
<member name="rendering/rendering_device/driver" type="String" setter="" getter="" default="&quot;auto&quot;">
29732985
Sets the driver to be used by the renderer when using a RenderingDevice-based renderer like the Forward+ or Mobile renderers. This property can't be edited directly. Instead, set the driver using the platform-specific overrides. This can be overridden using the [code]--rendering-driver &lt;driver&gt;[/code] command line argument.
2986+
Supported values are:
2987+
- [code]auto[/code], Metal on Apple Silicon Macs and iOS, Vulkan on other built-in platforms. On Windows, Direct3D 12 is the default if the engine was compiled without Vulkan support.
2988+
- [code]metal[/code], Metal (supported on Apple Silicon Macs and iOS).
2989+
- [code]vulkan[/code], Vulkan (supported on all desktop and mobile platforms).
2990+
- [code]d3d12[/code], Direct3D 12 (supported on Windows).
2991+
[b]Note:[/b] The availability of these options depends on whether the engine was compiled with support for them (determined by SCons options [code]vulkan[/code], [code]metal[/code], and [code]d3d12[/code]).
29742992
[b]Note:[/b] The actual rendering driver may be automatically changed by the engine as a result of a fallback, or a user-specified command line argument. To get the actual rendering driver that is used at runtime, use [method RenderingServer.get_current_rendering_driver_name] instead of reading this project setting's value.
29752993
</member>
2976-
<member name="rendering/rendering_device/driver.android" type="String" setter="" getter="">
2994+
<member name="rendering/rendering_device/driver.android" type="String" setter="" getter="" default="&quot;auto&quot;">
29772995
Android override for [member rendering/rendering_device/driver].
2996+
The [code]auto[/code] setting is equivalent to [code]vulkan[/code] on this platform.
2997+
[b]Note:[/b] If Vulkan was disabled at compile time, there is no alternative RenderingDevice driver.
29782998
</member>
2979-
<member name="rendering/rendering_device/driver.ios" type="String" setter="" getter="">
2999+
<member name="rendering/rendering_device/driver.ios" type="String" setter="" getter="" default="&quot;auto&quot;">
29803000
iOS override for [member rendering/rendering_device/driver].
3001+
The [code]auto[/code] setting is equivalent to [code]metal[/code] on this platform.
3002+
[b]Note:[/b] If Metal was disabled at compile time, the default becomes [code]vulkan[/code]. If both Metal and Vulkan were disabled at compile time, there is no alternative RenderingDevice driver.
29813003
</member>
2982-
<member name="rendering/rendering_device/driver.linuxbsd" type="String" setter="" getter="">
3004+
<member name="rendering/rendering_device/driver.linuxbsd" type="String" setter="" getter="" default="&quot;auto&quot;">
29833005
LinuxBSD override for [member rendering/rendering_device/driver].
3006+
The [code]auto[/code] setting is equivalent to [code]vulkan[/code] on this platform.
3007+
[b]Note:[/b] If Vulkan was disabled at compile time, there is no alternative RenderingDevice driver.
29843008
</member>
2985-
<member name="rendering/rendering_device/driver.macos" type="String" setter="" getter="">
3009+
<member name="rendering/rendering_device/driver.macos" type="String" setter="" getter="" default="&quot;auto&quot;">
29863010
macOS override for [member rendering/rendering_device/driver].
3011+
The [code]auto[/code] setting is equivalent to [code]metal[/code] on Apple Silicon Macs, and [code]vulkan[/code] (MoltenVK) on Intel Macs. Metal isn't supported on Intel Macs, so even if setting [code]metal[/code] explicitly, it will fallback to Vulkan on Intel Macs.
3012+
[b]Note:[/b] If Metal was disabled at compile time, the default becomes [code]vulkan[/code] for both Apple Silicon and Intel Macs. If both Metal and Vulkan were disabled at compile time, there is no alternative RenderingDevice driver.
29873013
</member>
2988-
<member name="rendering/rendering_device/driver.windows" type="String" setter="" getter="">
3014+
<member name="rendering/rendering_device/driver.windows" type="String" setter="" getter="" default="&quot;auto&quot;">
29893015
Windows override for [member rendering/rendering_device/driver].
3016+
The [code]auto[/code] setting is equivalent to [code]vulkan[/code] on this platform.
3017+
[b]Note:[/b] If Vulkan was disabled at compile time, the default becomes [code]d3d12[/code]. If both Vulkan and Direct3D 12 were disabled at compile time, there is no alternative RenderingDevice driver.
29903018
</member>
29913019
<member name="rendering/rendering_device/fallback_to_d3d12" type="bool" setter="" getter="" default="true">
29923020
If [code]true[/code], the forward renderer will fall back to Direct3D 12 if Vulkan is not supported.

main/main.cpp

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,65 +2031,27 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
20312031
Logger::set_flush_stdout_on_print(GLOBAL_GET("application/run/flush_stdout_on_print"));
20322032

20332033
{
2034-
String driver_hints = "";
2035-
String driver_hints_with_d3d12 = "";
2036-
String driver_hints_with_metal = "";
2037-
2038-
{
2039-
Vector<String> driver_hints_arr;
2040-
#ifdef VULKAN_ENABLED
2041-
driver_hints_arr.push_back("vulkan");
2042-
#endif
2043-
driver_hints = String(",").join(driver_hints_arr);
2044-
2045-
#ifdef D3D12_ENABLED
2046-
driver_hints_arr.push_back("d3d12");
2047-
#endif
2048-
driver_hints_with_d3d12 = String(",").join(driver_hints_arr);
2049-
2050-
#ifdef METAL_ENABLED
2051-
// Make metal the preferred and default driver.
2052-
driver_hints_arr.insert(0, "metal");
2053-
#endif
2054-
driver_hints_with_metal = String(",").join(driver_hints_arr);
2055-
}
2056-
2057-
String default_driver = driver_hints.get_slice(",", 0);
2058-
String default_driver_with_d3d12 = driver_hints_with_d3d12.get_slice(",", 0);
2059-
String default_driver_with_metal = driver_hints_with_metal.get_slice(",", 0);
2060-
20612034
// For now everything defaults to vulkan when available. This can change in future updates.
2062-
GLOBAL_DEF_RST_NOVAL("rendering/rendering_device/driver", default_driver);
2063-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, driver_hints_with_d3d12), default_driver_with_d3d12);
2064-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints), default_driver);
2065-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, driver_hints), default_driver);
2066-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, driver_hints_with_metal), default_driver_with_metal);
2067-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, driver_hints_with_metal), default_driver_with_metal);
2035+
GLOBAL_DEF_RST("rendering/rendering_device/driver", "auto");
2036+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, "auto,vulkan,d3d12"), "auto");
2037+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, "auto,vulkan"), "auto");
2038+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, "auto,vulkan"), "auto");
2039+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, "auto,metal,vulkan"), "auto");
2040+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, "auto,metal,vulkan"), "auto");
20682041

20692042
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_vulkan", true);
20702043
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_d3d12", true);
20712044
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_opengl3", true);
20722045
}
20732046

20742047
{
2075-
String driver_hints = "";
2076-
String driver_hints_angle = "";
2077-
String driver_hints_egl = "";
2078-
#ifdef GLES3_ENABLED
2079-
driver_hints = "opengl3";
2080-
driver_hints_angle = "opengl3,opengl3_angle"; // macOS, Windows.
2081-
driver_hints_egl = "opengl3,opengl3_es"; // Linux.
2082-
#endif
2083-
2084-
String default_driver = driver_hints.get_slice(",", 0);
2085-
2086-
GLOBAL_DEF_RST_NOVAL("rendering/gl_compatibility/driver", default_driver);
2087-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.windows", PROPERTY_HINT_ENUM, driver_hints_angle), default_driver);
2088-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints_egl), default_driver);
2089-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.web", PROPERTY_HINT_ENUM, driver_hints), default_driver);
2090-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.android", PROPERTY_HINT_ENUM, driver_hints), default_driver);
2091-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.ios", PROPERTY_HINT_ENUM, driver_hints), default_driver);
2092-
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.macos", PROPERTY_HINT_ENUM, driver_hints_angle), default_driver);
2048+
GLOBAL_DEF_RST("rendering/gl_compatibility/driver", "auto");
2049+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.windows", PROPERTY_HINT_ENUM, "auto,opengl3,opengl3_angle"), "auto");
2050+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.linuxbsd", PROPERTY_HINT_ENUM, "auto,opengl3,opengl3_es"), "auto");
2051+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.web", PROPERTY_HINT_ENUM, "auto,opengl3"), "auto");
2052+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.android", PROPERTY_HINT_ENUM, "auto,opengl3"), "auto");
2053+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.ios", PROPERTY_HINT_ENUM, "auto,opengl3"), "auto");
2054+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.macos", PROPERTY_HINT_ENUM, "auto,opengl3,opengl3_angle"), "auto");
20932055

20942056
GLOBAL_DEF_RST("rendering/gl_compatibility/nvidia_disable_threaded_optimization", true);
20952057
GLOBAL_DEF_RST("rendering/gl_compatibility/fallback_to_angle", true);
@@ -2423,6 +2385,30 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
24232385
// always convert to lower case for consistency in the code
24242386
rendering_driver = rendering_driver.to_lower();
24252387

2388+
if (rendering_method == "gl_compatibility") {
2389+
#ifdef GLES3_ENABLED
2390+
if (rendering_driver == "auto") {
2391+
rendering_driver = "opengl3";
2392+
}
2393+
#endif
2394+
} else {
2395+
#ifdef METAL_ENABLED
2396+
if (rendering_driver == "auto") {
2397+
rendering_driver = "metal";
2398+
}
2399+
#endif
2400+
#ifdef VULKAN_ENABLED
2401+
if (rendering_driver == "auto") {
2402+
rendering_driver = "vulkan";
2403+
}
2404+
#endif
2405+
#ifdef D3D12_ENABLED
2406+
if (rendering_driver == "auto") {
2407+
rendering_driver = "d3d12";
2408+
}
2409+
#endif
2410+
}
2411+
24262412
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
24272413
OS::get_singleton()->set_current_rendering_method(rendering_method);
24282414

0 commit comments

Comments
 (0)