Drop broken Android 32-bit framebuffer setting for a reliable one for depth buffer

This commit is contained in:
Pedro J. Estébanez 2021-10-31 20:22:48 +01:00
parent 1aef3a42b2
commit 07adf1193d
12 changed files with 31 additions and 39 deletions

View File

@ -1667,7 +1667,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, "*.png"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/depth_buffer_bits", PROPERTY_HINT_ENUM, "16 bits,24 bits [default],32 bits"), 1));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/opengl_debug"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "xr_features/xr_mode", PROPERTY_HINT_ENUM, "Regular,Oculus Mobile VR"), 0));
@ -2209,9 +2209,10 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP
command_line_strings.push_back("--xr_mode_regular"); command_line_strings.push_back("--xr_mode_regular");
} }
bool use_32_bit_framebuffer = p_preset->get("graphics/32_bits_framebuffer"); int depth_buffer_bits_index = p_preset->get("graphics/depth_buffer_bits");
if (use_32_bit_framebuffer) { if (depth_buffer_bits_index >= 0 && depth_buffer_bits_index <= 2) {
command_line_strings.push_back("--use_depth_32"); int depth_buffer_bits = 16 + depth_buffer_bits_index * 8;
command_line_strings.push_back(vformat("--use_depth=%d", depth_buffer_bits));
} }
bool immersive = p_preset->get("screen/immersive_mode"); bool immersive = p_preset->get("screen/immersive_mode");

View File

@ -119,7 +119,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
private Button mWiFiSettingsButton; private Button mWiFiSettingsButton;
private XRMode xrMode = XRMode.REGULAR; private XRMode xrMode = XRMode.REGULAR;
private boolean use_32_bits = false; private int depth_buffer_bits = 24;
private boolean use_immersive = false; private boolean use_immersive = false;
private boolean use_debug_opengl = false; private boolean use_debug_opengl = false;
private boolean mStatePaused; private boolean mStatePaused;
@ -266,7 +266,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
if (videoDriver.equals("Vulkan")) { if (videoDriver.equals("Vulkan")) {
mRenderView = new GodotVulkanRenderView(activity, this); mRenderView = new GodotVulkanRenderView(activity, this);
} else { } else {
mRenderView = new GodotGLRenderView(activity, this, xrMode, use_32_bits, mRenderView = new GodotGLRenderView(activity, this, xrMode, depth_buffer_bits,
use_debug_opengl); use_debug_opengl);
} }
@ -506,8 +506,12 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
xrMode = XRMode.REGULAR; xrMode = XRMode.REGULAR;
} else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) { } else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) {
xrMode = XRMode.OVR; xrMode = XRMode.OVR;
} else if (command_line[i].equals("--use_depth_32")) { } else if (command_line[i].startsWith("--use_depth=")) {
use_32_bits = true; try {
depth_buffer_bits = Integer.parseInt(command_line[i].split("=")[1]);
} catch (Exception e) {
e.printStackTrace();
}
} else if (command_line[i].equals("--debug_opengl")) { } else if (command_line[i].equals("--debug_opengl")) {
use_debug_opengl = true; use_debug_opengl = true;
} else if (command_line[i].equals("--use_immersive")) { } else if (command_line[i].equals("--use_immersive")) {

View File

@ -78,10 +78,10 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
private final GodotRenderer godotRenderer; private final GodotRenderer godotRenderer;
private PointerIcon pointerIcon; private PointerIcon pointerIcon;
public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, boolean p_use_32_bits, public GodotGLRenderView(Context context, Godot godot, XRMode xrMode, int p_depth_buffer_bits,
boolean p_use_debug_opengl) { boolean p_use_debug_opengl) {
super(context); super(context);
GLUtils.use_32 = p_use_32_bits; GLUtils.depth_buffer_bits = p_depth_buffer_bits;
GLUtils.use_debug_opengl = p_use_debug_opengl; GLUtils.use_debug_opengl = p_use_debug_opengl;
this.godot = godot; this.godot = godot;
@ -209,18 +209,16 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
* below. * below.
*/ */
if (GLUtils.use_32) { RegularConfigChooser configChooser =
setEGLConfigChooser(translucent new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil,
? new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
new RegularConfigChooser(8, 8, 8, 8, 16, stencil)) if (GLUtils.depth_buffer_bits >= 24) {
: new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser);
new RegularConfigChooser(5, 6, 5, 0, 16, stencil))); if (GLUtils.depth_buffer_bits >= 32) {
configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, configChooser);
} else { }
setEGLConfigChooser(translucent
? new RegularConfigChooser(8, 8, 8, 8, 16, stencil)
: new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
} }
setEGLConfigChooser(configChooser);
break; break;
} }

View File

@ -75,9 +75,8 @@ public class GodotLib {
/** /**
* Invoked on the render thread when the underlying Android surface is created or recreated. * Invoked on the render thread when the underlying Android surface is created or recreated.
* @param p_surface * @param p_surface
* @param p_32_bits
*/ */
public static native void newcontext(Surface p_surface, boolean p_32_bits); public static native void newcontext(Surface p_surface);
/** /**
* Forward {@link Activity#onBackPressed()} event from the main thread to the GL thread. * Forward {@link Activity#onBackPressed()} event from the main thread to the GL thread.

View File

@ -70,7 +70,7 @@ class GodotRenderer implements GLSurfaceView.Renderer {
} }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { public void onSurfaceCreated(GL10 gl, EGLConfig config) {
GodotLib.newcontext(null, GLUtils.use_32); GodotLib.newcontext(null);
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) { for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLSurfaceCreated(gl, config); plugin.onGLSurfaceCreated(gl, config);
} }

View File

@ -44,7 +44,7 @@ public class GLUtils {
public static final boolean DEBUG = false; public static final boolean DEBUG = false;
public static boolean use_32 = false; public static int depth_buffer_bits; // No need to reiterate the default here
public static boolean use_debug_opengl = false; public static boolean use_debug_opengl = false;
private static final String[] ATTRIBUTES_NAMES = new String[] { private static final String[] ATTRIBUTES_NAMES = new String[] {

View File

@ -58,7 +58,7 @@ internal class VkRenderer {
* Called when the surface is created and signals the beginning of rendering. * Called when the surface is created and signals the beginning of rendering.
*/ */
fun onVkSurfaceCreated(surface: Surface) { fun onVkSurfaceCreated(surface: Surface) {
GodotLib.newcontext(surface, false) GodotLib.newcontext(surface)
for (plugin in pluginRegistry.getAllPlugins()) { for (plugin in pluginRegistry.getAllPlugins()) {
plugin.onVkSurfaceCreated(surface) plugin.onVkSurfaceCreated(surface)

View File

@ -38,7 +38,7 @@ import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLDisplay;
/* Fallback if 32bit View is not supported*/ /* Fallback if the requested configuration is not supported */
public class RegularFallbackConfigChooser extends RegularConfigChooser { public class RegularFallbackConfigChooser extends RegularConfigChooser {
private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName(); private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName();
@ -55,7 +55,6 @@ public class RegularFallbackConfigChooser extends RegularConfigChooser {
if (ec == null) { if (ec == null) {
Log.w(TAG, "Trying ConfigChooser fallback"); Log.w(TAG, "Trying ConfigChooser fallback");
ec = fallback.chooseConfig(egl, display, configs); ec = fallback.chooseConfig(egl, display, configs);
GLUtils.use_32 = false;
} }
return ec; return ec;
} }

View File

@ -182,11 +182,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j
} }
} }
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits) { JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface) {
if (os_android) { if (os_android) {
if (step.get() == 0) { if (step.get() == 0) {
// During startup // During startup
os_android->set_context_is_16_bits(!p_32_bits);
if (p_surface) { if (p_surface) {
ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface); ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
os_android->set_native_window(native_window); os_android->set_native_window(native_window);

View File

@ -41,7 +41,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jclass clazz, jobject p_surface, jint p_width, jint p_height);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface, jboolean p_32_bits); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jclass clazz, jobject p_surface);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz);
void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask = 0, jfloat vertical_factor = 0, jfloat horizontal_factor = 0); void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jint buttons_mask = 0, jfloat vertical_factor = 0, jfloat horizontal_factor = 0);

View File

@ -261,13 +261,6 @@ Size2i OS_Android::get_display_size() const {
return display_size; return display_size;
} }
void OS_Android::set_context_is_16_bits(bool p_is_16) {
#if defined(GLES3_ENABLED)
//if (rasterizer)
// rasterizer->set_force_16_bits_fbo(p_is_16);
#endif
}
void OS_Android::set_opengl_extensions(const char *p_gl_extensions) { void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
#if defined(GLES3_ENABLED) #if defined(GLES3_ENABLED)
ERR_FAIL_COND(!p_gl_extensions); ERR_FAIL_COND(!p_gl_extensions);

View File

@ -102,7 +102,6 @@ public:
void set_display_size(const Size2i &p_size); void set_display_size(const Size2i &p_size);
Size2i get_display_size() const; Size2i get_display_size() const;
void set_context_is_16_bits(bool p_is_16);
void set_opengl_extensions(const char *p_gl_extensions); void set_opengl_extensions(const char *p_gl_extensions);
void set_native_window(ANativeWindow *p_native_window); void set_native_window(ANativeWindow *p_native_window);