Merge pull request #54463 from RandomShaper/fix_gl3_32bits

This commit is contained in:
Rémi Verschelde 2021-11-09 11:55:26 +01:00 committed by GitHub
commit 8a15e404b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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_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::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");
}
bool use_32_bit_framebuffer = p_preset->get("graphics/32_bits_framebuffer");
if (use_32_bit_framebuffer) {
command_line_strings.push_back("--use_depth_32");
int depth_buffer_bits_index = p_preset->get("graphics/depth_buffer_bits");
if (depth_buffer_bits_index >= 0 && depth_buffer_bits_index <= 2) {
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");

View File

@ -119,7 +119,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
private Button mWiFiSettingsButton;
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_debug_opengl = false;
private boolean mStatePaused;
@ -266,7 +266,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
if (videoDriver.equals("vulkan")) {
mRenderView = new GodotVulkanRenderView(activity, this);
} else {
mRenderView = new GodotGLRenderView(activity, this, xrMode, use_32_bits,
mRenderView = new GodotGLRenderView(activity, this, xrMode, depth_buffer_bits,
use_debug_opengl);
}
@ -506,8 +506,12 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
xrMode = XRMode.REGULAR;
} else if (command_line[i].equals(XRMode.OVR.cmdLineArg)) {
xrMode = XRMode.OVR;
} else if (command_line[i].equals("--use_depth_32")) {
use_32_bits = true;
} else if (command_line[i].startsWith("--use_depth=")) {
try {
depth_buffer_bits = Integer.parseInt(command_line[i].split("=")[1]);
} catch (Exception e) {
e.printStackTrace();
}
} else if (command_line[i].equals("--debug_opengl")) {
use_debug_opengl = true;
} 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 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) {
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;
this.godot = godot;
@ -209,18 +209,16 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
* below.
*/
if (GLUtils.use_32) {
setEGLConfigChooser(translucent
? new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
new RegularConfigChooser(8, 8, 8, 8, 16, stencil))
: new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
new RegularConfigChooser(5, 6, 5, 0, 16, stencil)));
} else {
setEGLConfigChooser(translucent
? new RegularConfigChooser(8, 8, 8, 8, 16, stencil)
: new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
RegularConfigChooser configChooser =
new RegularFallbackConfigChooser(8, 8, 8, 8, 16, stencil,
new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
if (GLUtils.depth_buffer_bits >= 24) {
configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil, configChooser);
if (GLUtils.depth_buffer_bits >= 32) {
configChooser = new RegularFallbackConfigChooser(8, 8, 8, 8, 32, stencil, configChooser);
}
}
setEGLConfigChooser(configChooser);
break;
}

View File

@ -75,9 +75,8 @@ public class GodotLib {
/**
* Invoked on the render thread when the underlying Android surface is created or recreated.
* @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.

View File

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

View File

@ -44,7 +44,7 @@ public class GLUtils {
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;
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.
*/
fun onVkSurfaceCreated(surface: Surface) {
GodotLib.newcontext(surface, false)
GodotLib.newcontext(surface)
for (plugin in pluginRegistry.getAllPlugins()) {
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.EGLDisplay;
/* Fallback if 32bit View is not supported*/
/* Fallback if the requested configuration is not supported */
public class RegularFallbackConfigChooser extends RegularConfigChooser {
private static final String TAG = RegularFallbackConfigChooser.class.getSimpleName();
@ -55,7 +55,6 @@ public class RegularFallbackConfigChooser extends RegularConfigChooser {
if (ec == null) {
Log.w(TAG, "Trying ConfigChooser fallback");
ec = fallback.chooseConfig(egl, display, configs);
GLUtils.use_32 = false;
}
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 (step.get() == 0) {
// During startup
os_android->set_context_is_16_bits(!p_32_bits);
if (p_surface) {
ANativeWindow *native_window = ANativeWindow_fromSurface(env, p_surface);
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_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_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_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);

View File

@ -261,13 +261,6 @@ Size2i OS_Android::get_display_size() const {
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) {
#if defined(GLES3_ENABLED)
ERR_FAIL_COND(!p_gl_extensions);

View File

@ -102,7 +102,6 @@ public:
void set_display_size(const Size2i &p_size);
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_native_window(ANativeWindow *p_native_window);