Merge pull request #26633 from akien-mga/driver-fallback-etc

Disable driver fallback to GLES2 by default
This commit is contained in:
Rémi Verschelde 2019-03-06 00:57:49 +01:00 committed by GitHub
commit b4d5c1ab5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 43 additions and 18 deletions

View File

@ -688,10 +688,13 @@
</member>
<member name="rendering/quality/directional_shadow/size.mobile" type="int" setter="" getter="">
</member>
<member name="rendering/quality/driver/driver_fallback" type="String" setter="" getter="">
Whether to allow falling back to other graphics drivers if the preferred driver is not available. Best means use the best working driver (this is the default). Never means never fall back to another driver even if it does not work. This means the project will not run if the preferred driver does not function.
</member>
<member name="rendering/quality/driver/driver_name" type="String" setter="" getter="">
Name of the configured video driver ("GLES2" or "GLES3").
Note that the backend in use can be overridden at runtime via the [code]--video-driver[/code] command line argument, or by the [member rendering/quality/driver/fallback_to_gles2] option if the target system does not support GLES3 and falls back to GLES2. In such cases, this property is not updated, so use [method OS.get_current_video_driver] to query it at runtime.
</member>
<member name="rendering/quality/driver/fallback_to_gles2" type="bool" setter="" getter="">
Whether to allow falling back to the GLES2 driver if the GLES3 driver is not supported. Default value: [code]false[/code].
Note that the two video drivers are not drop-in replacements for each other, so a game designed for GLES3 might not work properly when falling back to GLES2. In particular, some features of the GLES3 backend are not available in GLES2. Enabling this setting also means that both ETC and ETC2 VRAM-compressed textures will be exported on Android and iOS, increasing the size of the game data pack.
</member>
<member name="rendering/quality/filters/anisotropic_filter_level" type="int" setter="" getter="">
Maximum Anisotropic filter level used for textures when anisotropy enabled.

View File

@ -1163,13 +1163,23 @@ void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, in
String EditorExportPlatform::test_etc2() const {
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
bool driver_fallback = ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc");
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2");
if (driver == "GLES2" && !etc_supported) {
return TTR("Target platform requires 'ETC' texture compression for GLES2. Enable 'rendering/vram_compression/import_etc' in Project Settings.");
} else if (driver == "GLES3" && !etc2_supported) {
return TTR("Target platform requires 'ETC2' texture compression for GLES3. Enable 'rendering/vram_compression/import_etc2' in Project Settings.");
return TTR("Target platform requires 'ETC' texture compression for GLES2. Enable 'Import Etc' in Project Settings.");
} else if (driver == "GLES3") {
String err;
if (!etc2_supported) {
err += TTR("Target platform requires 'ETC2' texture compression for GLES3. Enable 'Import Etc 2' in Project Settings.");
}
if (driver_fallback && !etc_supported) {
if (err != String())
err += "\n";
err += TTR("Target platform requires 'ETC' texture compression for the driver fallback to GLES2.\nEnable 'Import Etc' in Project Settings, or disable 'Driver Fallback Enabled'.");
}
return err;
}
return String();
}

View File

@ -880,8 +880,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
video_driver = GLOBAL_GET("rendering/quality/driver/driver_name");
}
GLOBAL_DEF("rendering/quality/driver/driver_fallback", "Best");
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_fallback", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_fallback", PROPERTY_HINT_ENUM, "Best,Never"));
GLOBAL_DEF("rendering/quality/driver/fallback_to_gles2", false);
// Assigning here even though it's GLES2-specific, to be sure that it appears in docs
GLOBAL_DEF("rendering/quality/2d/gles2_use_nvidia_rect_flicker_workaround", false);

View File

@ -658,6 +658,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
int orientation = p_preset->get("screen/orientation");
bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES3" &&
!ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
bool screen_support_small = p_preset->get("screen/support_small");
bool screen_support_normal = p_preset->get("screen/support_normal");
bool screen_support_large = p_preset->get("screen/support_large");
@ -815,6 +817,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}
if (tname == "uses-feature" && attrname == "glEsVersion") {
encode_uint32(min_gles3 ? 0x00030000 : 0x00020000, &p_manifest.write[iofs + 16]);
}
iofs += 20;
}
@ -1119,6 +1126,9 @@ public:
r_features->push_back("etc");
} else if (driver == "GLES3") {
r_features->push_back("etc2");
if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
r_features->push_back("etc");
}
}
Vector<String> abis = get_enabled_abis(p_preset);

View File

@ -131,7 +131,7 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
use_gl3 = false;
continue;

View File

@ -201,6 +201,9 @@ void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset>
r_features->push_back("etc");
} else if (driver == "GLES3") {
r_features->push_back("etc2");
if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
r_features->push_back("etc");
}
}
Vector<String> architectures = _get_preset_architectures(p_preset);

View File

@ -120,7 +120,7 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
use_gl3 = false;
continue;

View File

@ -829,7 +829,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3 = false;
continue;

View File

@ -1420,7 +1420,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3 = false;
continue;

View File

@ -202,7 +202,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
memdelete(gl_context);
gl_context = NULL;
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@ -224,7 +224,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
opengl_api_type = ContextEGL_UWP::GLES_2_0;
continue;

View File

@ -1290,7 +1290,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
memdelete(gl_context);
gl_context = NULL;
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@ -1312,7 +1312,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3_context = false;
continue;

View File

@ -299,7 +299,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
memdelete(context_gl);
context_gl = NULL;
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@ -321,7 +321,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
continue;