exynos4: EGL_mali: allow to skip EGL context detach

This should prevent Mali blob freaking on context detach.
Not sure if this is a good idea just skipping context detach,
but let's see how it goes...

Change-Id: I62121b17b74276a687818531187ba444fedc32bf
This commit is contained in:
Shilin Victor 2019-03-02 21:04:20 +03:00
parent c1b4b30ccc
commit fb016d5b6e
3 changed files with 96 additions and 7 deletions

View File

@ -27,16 +27,18 @@ LOCAL_C_INCLUDES := \
frameworks/native/libs/arect/include \
system/core/include
LOCAL_SHARED_LIBRARIES := liblog libcutils
LOCAL_CFLAGS := -DLOG_TAG=\"EGL_mali\"
ifeq ($(TARGET_NEEDS_NATIVE_WINDOW_FORMAT_FIX),true)
LOCAL_CFLAGS += -DNEEDS_NATIVE_WINDOW_FORMAT_FIX
endif
ifeq ($(TARGET_SKIP_EGL_CONTEXT_DETACH),true)
LOCAL_CFLAGS += -DSKIP_EGL_CONTEXT_DETACH
endif
LOCAL_SRC_FILES := shim.S eglApi.cpp
LOCAL_SHARED_LIBRARIES := libMali
LOCAL_SHARED_LIBRARIES := libMali liblog libcutils
LOCAL_MODULE := libEGL_mali
LOCAL_MODULE_TAGS := optional

View File

@ -15,11 +15,16 @@
* limitations under the License.
*/
#include <log/log.h>
#include <system/graphics.h>
#include <system/window.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#ifdef SKIP_EGL_CONTEXT_DETACH
static int debug_level = 0;
#endif
extern "C" EGLBoolean shim_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
@ -27,6 +32,15 @@ extern "C" EGLSurface shim_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig conf
NativeWindowType window,
const EGLint *attrib_list);
extern "C" EGLBoolean shim_eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
extern "C" EGLBoolean shim_eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
extern "C" EGLSurface shim_eglGetCurrentSurface(EGLint readdraw);
extern "C" EGLContext shim_eglGetCurrentContext(void);
EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value) {
return shim_eglGetConfigAttrib(dpy, config, attribute, value);
@ -47,3 +61,76 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
#endif
return shim_eglCreateWindowSurface(dpy, config, window, attrib_list);
}
EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx) {
#ifdef SKIP_EGL_CONTEXT_DETACH
EGLSurface curRead, curDraw;
EGLContext curCtx;
if (debug_level > 1) {
curRead = shim_eglGetCurrentSurface(EGL_READ);
curDraw = shim_eglGetCurrentSurface(EGL_DRAW);
curCtx = shim_eglGetCurrentContext();
ALOGD("%s: before makeCurrent: curRead=%s, curDraw=%s, curCtx=%s",
__func__, (curRead == EGL_NO_SURFACE ? "NULL" : "ok"),
(curDraw == EGL_NO_SURFACE ? "NULL" : "ok"),
(curCtx == EGL_NO_CONTEXT ? "NULL" : "ok"));
}
if (draw == EGL_NO_SURFACE &&
read == EGL_NO_SURFACE &&
ctx == EGL_NO_CONTEXT) {
ALOGD_IF(debug_level > 0, "%s: skipping context detach!", __func__);
return true;
} else
ALOGD_IF(debug_level > 1, "%s: init", __func__);
#endif
EGLBoolean res = shim_eglMakeCurrent(dpy, draw, read, ctx);
#ifdef SKIP_EGL_CONTEXT_DETACH
if (debug_level > 1) {
curRead = shim_eglGetCurrentSurface(EGL_READ);
curDraw = shim_eglGetCurrentSurface(EGL_DRAW);
curCtx = shim_eglGetCurrentContext();
ALOGD("%s: after makeCurrent: curRead=%s, curDraw=%s, curCtx=%s",
__func__, (curRead == EGL_NO_SURFACE ? "NULL" : "ok"),
(curDraw == EGL_NO_SURFACE ? "NULL" : "ok"),
(curCtx == EGL_NO_CONTEXT ? "NULL" : "ok"));
}
#endif
return res;
}
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) {
#ifdef SKIP_EGL_CONTEXT_DETACH
EGLSurface curRead, curDraw;
EGLContext curCtx;
if (debug_level > 2) {
curRead = shim_eglGetCurrentSurface(EGL_READ);
curDraw = shim_eglGetCurrentSurface(EGL_DRAW);
curCtx = shim_eglGetCurrentContext();
ALOGD("%s: before destroySurface: curRead=%s, curDraw=%s, curCtx=%s",
__func__, (curRead == EGL_NO_SURFACE ? "NULL" : "ok"),
(curDraw == EGL_NO_SURFACE ? "NULL" : "ok"),
(curCtx == EGL_NO_CONTEXT ? "NULL" : "ok"));
}
#endif
EGLBoolean res = shim_eglDestroySurface(dpy, surface);
#ifdef SKIP_EGL_CONTEXT_DETACH
if (debug_level > 2) {
curRead = shim_eglGetCurrentSurface(EGL_READ);
curDraw = shim_eglGetCurrentSurface(EGL_DRAW);
curCtx = shim_eglGetCurrentContext();
ALOGD("%s: after destroySurface: curRead=%s, curDraw=%s, curCtx=%s",
__func__, (curRead == EGL_NO_SURFACE ? "NULL" : "ok"),
(curDraw == EGL_NO_SURFACE ? "NULL" : "ok"),
(curCtx == EGL_NO_CONTEXT ? "NULL" : "ok"));
}
#endif
return res;
}

View File

@ -89,9 +89,9 @@ eglDestroyContext:
eglQueryContext:
b shim_eglQueryContext
.globl eglMakeCurrent
/*.globl eglMakeCurrent
eglMakeCurrent:
b shim_eglMakeCurrent
b shim_eglMakeCurrent*/
.globl eglGetCurrentContext
eglGetCurrentContext:
@ -130,9 +130,9 @@ eglCreatePbufferFromClientBuffer:
eglCreatePixmapSurface:
b shim_eglCreatePixmapSurface
.globl eglDestroySurface
/*.globl eglDestroySurface
eglDestroySurface:
b shim_eglDestroySurface
b shim_eglDestroySurface*/
.globl eglQuerySurface
eglQuerySurface: