[Mesa-dev] [RFC 5/5] DEBUG
Robert Foss
robert.foss at collabora.com
Thu Jul 5 10:07:40 UTC 2018
Signed-off-by: Robert Foss <robert.foss at collabora.com>
---
src/egl/drivers/dri2/egl_dri2.c | 29 +++++++++++++++----
src/egl/drivers/dri2/platform_android.c | 27 +++++++++++++----
src/egl/main/egldriver.c | 8 ++++-
src/gallium/auxiliary/Android.mk | 5 ++++
src/gallium/winsys/sw/kms-dri/Android.mk | 6 ++++
.../winsys/sw/kms-dri/kms_dri_sw_winsys.c | 6 ++--
6 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 45d0c7275c5..64b65042fda 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -65,6 +65,10 @@
#include "util/u_vector.h"
#include "mapi/glapi/glapi.h"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#define LOG_TAG "egl-dri2"
+#include <cutils/log.h>
+
/* The kernel header drm_fourcc.h defines the DRM formats below. We duplicate
* some of the definitions here so that building Mesa won't bleeding-edge
* kernel headers.
@@ -511,7 +515,7 @@ dri2_open_driver(_EGLDisplay *disp)
char path[PATH_MAX], *search_paths, *next, *end;
char *get_extensions_name;
const __DRIextension **(*get_extensions)(void);
-
+ ALOGE("%s() 1 driver_name=%s", __func__, dri2_dpy->driver_name);
search_paths = NULL;
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
@@ -523,6 +527,7 @@ dri2_open_driver(_EGLDisplay *disp)
dri2_dpy->driver = NULL;
end = search_paths + strlen(search_paths);
for (char *p = search_paths; p < end; p = next + 1) {
+ ALOGE("%s() 1.1 driver path: %s", __func__, p);
int len;
next = strchr(p, ':');
if (next == NULL)
@@ -532,14 +537,19 @@ dri2_open_driver(_EGLDisplay *disp)
#if GLX_USE_TLS
snprintf(path, sizeof path,
"%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name);
+ ALOGE("%s() 2 .so path: %s", __func__, path);
+
dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
#endif
if (dri2_dpy->driver == NULL) {
snprintf(path, sizeof path,
"%.*s/%s_dri.so", len, p, dri2_dpy->driver_name);
+ ALOGE("%s() 3 .so path: %s", __func__, path);
dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
- if (dri2_dpy->driver == NULL)
+ if (dri2_dpy->driver == NULL){
_eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
+ ALOGE("%s() failed to open %s: %s\n", __func__, path, dlerror());
+ }
}
/* not need continue to loop all paths once the driver is found */
if (dri2_dpy->driver != NULL)
@@ -550,6 +560,8 @@ dri2_open_driver(_EGLDisplay *disp)
_eglLog(_EGL_WARNING,
"DRI2: failed to open %s (search paths %s)",
dri2_dpy->driver_name, search_paths);
+ ALOGE("%s() DRI2: failed to open %s (search paths %s)",
+ __func__, dri2_dpy->driver_name, search_paths);
return NULL;
}
@@ -821,8 +833,9 @@ EGLBoolean
dri2_create_screen(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-
+ ALOGE("%s() 1", __func__);
if (dri2_dpy->image_driver) {
+ ALOGE("%s() 1 1 image_driver", __func__);
dri2_dpy->dri_screen =
dri2_dpy->image_driver->createNewScreen2(0, dri2_dpy->fd,
dri2_dpy->loader_extensions,
@@ -830,19 +843,23 @@ dri2_create_screen(_EGLDisplay *disp)
&dri2_dpy->driver_configs,
disp);
} else if (dri2_dpy->dri2) {
+ ALOGE("%s() 1 2 dri2", __func__);
if (dri2_dpy->dri2->base.version >= 4) {
+ ALOGE("%s() 1 2 1 dri2", __func__);
dri2_dpy->dri_screen =
dri2_dpy->dri2->createNewScreen2(0, dri2_dpy->fd,
dri2_dpy->loader_extensions,
dri2_dpy->driver_extensions,
&dri2_dpy->driver_configs, disp);
} else {
+ ALOGE("%s() 1 2 2 !dri2", __func__);
dri2_dpy->dri_screen =
dri2_dpy->dri2->createNewScreen(0, dri2_dpy->fd,
dri2_dpy->loader_extensions,
&dri2_dpy->driver_configs, disp);
}
} else {
+ ALOGE("%s() 1 3 1 swrast", __func__);
assert(dri2_dpy->swrast);
if (dri2_dpy->swrast->base.version >= 4) {
dri2_dpy->dri_screen =
@@ -850,17 +867,19 @@ dri2_create_screen(_EGLDisplay *disp)
dri2_dpy->driver_extensions,
&dri2_dpy->driver_configs, disp);
} else {
+ ALOGE("%s() 1 3 2 swrast", __func__);
dri2_dpy->dri_screen =
dri2_dpy->swrast->createNewScreen(0, dri2_dpy->loader_extensions,
&dri2_dpy->driver_configs, disp);
}
}
-
+ALOGE("%s() 2", __func__);
if (dri2_dpy->dri_screen == NULL) {
+ALOGE("%s() 2 1 DRI2: failed to create dri screen", __func__);
_eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
return EGL_FALSE;
}
-
+ALOGE("%s() 3 returning", __func__);
dri2_dpy->own_dri_screen = true;
return EGL_TRUE;
}
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index bc644c25bf9..7a61e333153 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -27,6 +27,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#define LOG_TAG "mesa-platform"
+#include <cutils/log.h>
+
#include <cutils/properties.h>
#include <errno.h>
#include <dirent.h>
@@ -1197,7 +1201,7 @@ droid_load_driver(_EGLDisplay *disp, EGLBoolean force_software)
{
struct dri2_egl_display *dri2_dpy = disp->DriverData;
const char *err;
-
+ ALOGE("%s() 1", __func__);
if (force_software) {
dri2_dpy->driver_name = strdup("kms_swrast");
} else {
@@ -1206,10 +1210,13 @@ droid_load_driver(_EGLDisplay *disp, EGLBoolean force_software)
if (dri2_dpy->driver_name == NULL)
return false;
+ ALOGE("%s() 2 driver_name=%s", __func__, dri2_dpy->driver_name);
dri2_dpy->is_render_node = drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER;
if (!dri2_dpy->is_render_node) {
#ifdef HAVE_DRM_GRALLOC
+ ALOGE("%s() 2.1 ", __func__, dri2_dpy->driver_name);
+
/* Handle control nodes using __DRI_DRI2_LOADER extension and GEM names
* for backwards compatibility with drm_gralloc. (Do not use on new
* systems.) */
@@ -1219,10 +1226,14 @@ droid_load_driver(_EGLDisplay *disp, EGLBoolean force_software)
goto error;
}
#else
+ ALOGE("%s() 2.2", __func__);
+
err = "DRI2: handle is not for a render node";
goto error;
#endif
} else {
+ ALOGE("%s() 2.3", __func__);
+
dri2_dpy->loader_extensions = droid_image_loader_extensions;
if (!dri2_load_driver_dri3(disp)) {
err = "DRI3: failed to load driver";
@@ -1233,6 +1244,7 @@ droid_load_driver(_EGLDisplay *disp, EGLBoolean force_software)
return true;
error:
+ ALOGE("%s() 3 error: %s", __func__, err);
free(dri2_dpy->driver_name);
dri2_dpy->driver_name = NULL;
return false;
@@ -1367,10 +1379,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
const char *err;
int ret;
- /* Not supported yet */
- if (disp->Options.ForceSoftware)
- return EGL_FALSE;
-
loader_set_logger(_eglLog);
dri2_dpy = calloc(1, sizeof(*dri2_dpy));
@@ -1387,22 +1395,27 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
disp->DriverData = (void *) dri2_dpy;
+ ALOGE("%s() 1 force_software=%d", __func__, force_software);
dri2_dpy->fd = droid_open_device(disp);
if (dri2_dpy->fd < 0) {
+ ALOGE("%s() 1.1 failed to open device, trying software device", __func__);
err = "DRI2: failed to open device, trying software device";
}
load_driver:
+ ALOGE("%s() 2 load_driver force_software=%s", __func__, force_software?"true":"false");
if (!droid_load_driver(disp, force_software)) {
if (force_software) {
+ ALOGE("%s() 2.1 failed to load software driver", __func__);
err = "DRI2: failed to load driver";
goto cleanup;
} else {
+ ALOGE("%s() 2.2 failed to load hardware driver, retrying software", __func__);
force_software = true;
goto load_driver;
}
}
-
+ ALOGE("%s() 3 loaded _some_ driver", __func__);
if (!dri2_create_screen(disp)) {
err = "DRI2: failed to create screen";
goto cleanup;
@@ -1443,6 +1456,8 @@ load_driver:
return EGL_TRUE;
cleanup:
+ ALOGE("%s() cleanup", __func__);
+
dri2_display_destroy(disp);
return _eglError(EGL_NOT_INITIALIZED, err);
}
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index bb9e90c157d..5dd71b0c12e 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -50,6 +50,10 @@
#include "util/debug.h"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#define LOG_TAG "egldriver"
+#include <cutils/log.h>
+
static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP;
static _EGLDriver *_eglDriver;
@@ -93,7 +97,9 @@ _eglMatchDriver(_EGLDisplay *dpy)
#ifdef HAVE_ANDROID_PLATFORM
char prop_val[PROPERTY_VALUE_MAX];
- property_get("drm.gpu.force_software", prop_val, "0");
+ //property_get("drm.gpu.force_software", prop_val, "0");
+ property_get("drm.gpu.force_software", prop_val, "1");
+ ALOGE("%s() drm.gpu.force_software=\"%s\"", __func__, prop_val);
dpy->Options.ForceSoftware |= strncmp(prop_val, "0", PROPERTY_VALUE_MAX);
#endif
diff --git a/src/gallium/auxiliary/Android.mk b/src/gallium/auxiliary/Android.mk
index acd243b8346..08aaacdc40f 100644
--- a/src/gallium/auxiliary/Android.mk
+++ b/src/gallium/auxiliary/Android.mk
@@ -50,6 +50,11 @@ LOCAL_CPPFLAGS += -std=c++11
LOCAL_MODULE := libmesa_gallium
LOCAL_STATIC_LIBRARIES += libmesa_nir
+LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libcutils
+
LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures
LOCAL_CFLAGS += -DHAS_ANDROID_CPUFEATURES
diff --git a/src/gallium/winsys/sw/kms-dri/Android.mk b/src/gallium/winsys/sw/kms-dri/Android.mk
index f5c1ccab12a..f7ff90ba4a1 100644
--- a/src/gallium/winsys/sw/kms-dri/Android.mk
+++ b/src/gallium/winsys/sw/kms-dri/Android.mk
@@ -29,5 +29,11 @@ LOCAL_SRC_FILES := $(C_SOURCES)
LOCAL_MODULE := libmesa_winsys_sw_kms_dri
+
+
include $(GALLIUM_COMMON_MK)
include $(BUILD_STATIC_LIBRARY)
+
+LOCAL_STATIC_LIBRARIES := \
+ liblog \
+ libcutils
diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
index d842fe3257a..6d7828fca78 100644
--- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c
@@ -53,6 +53,10 @@
#include "state_tracker/drm_driver.h"
#include "kms_dri_sw_winsys.h"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#define LOG_TAG "kms_dri_sw_winsys"
+#include <cutils/log.h>
+
#ifdef DEBUG
#define DEBUG_PRINT(msg, ...) fprintf(stderr, msg, __VA_ARGS__)
#else
@@ -474,7 +478,6 @@ struct sw_winsys *
kms_dri_create_winsys(int fd)
{
struct kms_sw_winsys *ws;
-
ws = CALLOC_STRUCT(kms_sw_winsys);
if (!ws)
return NULL;
@@ -497,7 +500,6 @@ kms_dri_create_winsys(int fd)
ws->base.displaytarget_unmap = kms_sw_displaytarget_unmap;
ws->base.displaytarget_display = kms_sw_displaytarget_display;
-
return &ws->base;
}
--
2.17.1
More information about the mesa-dev
mailing list