Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to enable high precision float in GLES2 #33646

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@
<member name="rendering/quality/shading/force_lambert_over_burley.mobile" type="bool" setter="" getter="" default="true">
Lower-end override for [member rendering/quality/shading/force_lambert_over_burley] on mobile devices, due to performance concerns or driver support.
</member>
<member name="rendering/gles2/compatibility/enable_high_float.Android" type="bool" setter="" getter="" default="false">
If [code]true[/code] and available on the target device, enables high floating point precision for all shader computations in GLES2.
[b]Warning:[/b] High floating point precision can be extremely slow on older devices and is often not available at all. Use with caution.
</member>
<member name="rendering/quality/shading/force_vertex_shading" type="bool" setter="" getter="" default="false">
If [code]true[/code], forces vertex shading for all rendering. This can increase performance a lot, but also reduces quality immensely. Can be used to optimize performance on low-end mobile devices.
</member>
Expand Down
7 changes: 7 additions & 0 deletions drivers/gles2/shader_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "core/os/memory.h"
#include "core/print_string.h"
#include "core/project_settings.h"
#include "core/string_builder.h"
#include "rasterizer_gles2.h"
#include "rasterizer_storage_gles2.h"
Expand Down Expand Up @@ -180,6 +181,12 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
strings.push_back("#define USE_HIGHP_PRECISION\n");
#endif

if (GLOBAL_GET("rendering/gles2/compatibility/enable_high_float.Android")) {
// enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in GLES2
// see Section 4.5.4 of the GLSL_ES_Specification_1.00
strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n");
}

#endif

#ifdef ANDROID_ENABLED
Expand Down
1 change: 1 addition & 0 deletions servers/visual_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,7 @@ VisualServer::VisualServer() {
GLOBAL_DEF("rendering/batching/debug/flash_batching", false);
GLOBAL_DEF("rendering/batching/debug/diagnose_frame", false);
GLOBAL_DEF("rendering/gles2/compatibility/disable_half_float", false);
GLOBAL_DEF("rendering/gles2/compatibility/enable_high_float.Android", false);
GLOBAL_DEF("rendering/batching/precision/uv_contract", false);
GLOBAL_DEF("rendering/batching/precision/uv_contract_amount", 100);

Expand Down