aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorDavid Turner <digit@android.com>2011-09-12 18:21:58 +0200
committerDavid 'Digit' Turner <digit@google.com>2011-09-13 18:41:10 +0200
commit7b56a4a9a250573d5bdb8d04a2d8a64937432832 (patch)
tree2a0173464a0b4c19e3d6cff2aef93649acb86700 /android
parent4939812780883255043a09eceaf607263f30fde4 (diff)
downloadexternal_qemu-7b56a4a9a250573d5bdb8d04a2d8a64937432832.zip
external_qemu-7b56a4a9a250573d5bdb8d04a2d8a64937432832.tar.gz
external_qemu-7b56a4a9a250573d5bdb8d04a2d8a64937432832.tar.bz2
gles: use fast GLES pipe by default (Unix only)
This improves performance of various benchmarks by 5% Change-Id: If2d2be0e9849429ecffe52b7d482cfbee4008473
Diffstat (limited to 'android')
-rw-r--r--android/hw-pipe-net.c19
-rw-r--r--android/opengles.c34
-rw-r--r--android/opengles.h11
3 files changed, 60 insertions, 4 deletions
diff --git a/android/hw-pipe-net.c b/android/hw-pipe-net.c
index 8b8017d..193d60b 100644
--- a/android/hw-pipe-net.c
+++ b/android/hw-pipe-net.c
@@ -474,10 +474,21 @@ openglesPipe_init( void* hwpipe, void* _looper, const char* args )
return NULL;
}
- /* For now, simply connect through tcp */
- snprintf(temp, sizeof temp, "%d", ANDROID_OPENGLES_BASE_PORT);
- pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, temp);
-
+#ifndef _WIN32
+ if (android_gles_fast_pipes) {
+ char unix_path[PATH_MAX];
+ android_gles_unix_path(unix_path, sizeof(unix_path), ANDROID_OPENGLES_BASE_PORT);
+ pipe = (NetPipe *)netPipe_initUnix(hwpipe, _looper, unix_path);
+ D("Creating Unix OpenGLES pipe for GPU emulation: %s", unix_path);
+ } else {
+#else /* _WIN32 */
+ {
+#endif
+ /* Connect through TCP as a fallback */
+ snprintf(temp, sizeof temp, "%d", ANDROID_OPENGLES_BASE_PORT);
+ pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, temp);
+ D("Creating TCP OpenGLES pipe for GPU emulation!");
+ }
if (pipe != NULL) {
// Disable TCP nagle algorithm to improve throughput of small packets
socket_set_nodelay(pipe->io->fd);
diff --git a/android/opengles.c b/android/opengles.c
index 5d0c152..4913d0c 100644
--- a/android/opengles.c
+++ b/android/opengles.c
@@ -12,6 +12,7 @@
#include "config-host.h"
#include "android/opengles.h"
+#include "android/globals.h"
#include <android/utils/debug.h>
#include <android/utils/path.h>
#include <android/utils/bufprint.h>
@@ -22,6 +23,9 @@
#define D(...) VERBOSE_PRINT(init,__VA_ARGS__)
#define DD(...) VERBOSE_PRINT(gles,__VA_ARGS__)
+/* Declared in "android/globals.h" */
+int android_gles_fast_pipes = 1;
+
/* Name of the GLES rendering library we're going to use */
#define RENDERER_LIB_NAME "libOpenglRender"
@@ -30,12 +34,17 @@
*/
#define DYNLINK_FUNCTIONS \
DYNLINK_FUNC(int,initLibrary,(void),(),return) \
+ DYNLINK_FUNC(int,setStreamMode,(int a),(a),return) \
DYNLINK_FUNC(int,initOpenGLRenderer,(int width, int height, int port),(width,height,port),return) \
DYNLINK_FUNC(int,createOpenGLSubwindow,(void* window, int x, int y, int width, int height, float zRot),(window,x,y,width,height,zRot),return)\
DYNLINK_FUNC(int,destroyOpenGLSubwindow,(void),(),return)\
DYNLINK_FUNC(void,repaintOpenGLDisplay,(void),(),)\
DYNLINK_FUNC(void,stopOpenGLRenderer,(void),(),)
+#define STREAM_MODE_DEFAULT 0
+#define STREAM_MODE_TCP 1
+#define STREAM_MODE_UNIX 2
+#define STREAM_MODE_PIPE 3
#ifndef CONFIG_STANDALONE_UI
/* Defined in android/hw-pipe-net.c */
@@ -106,6 +115,16 @@ android_initOpenglesEmulation(void)
goto BAD_EXIT;
}
+ if (android_gles_fast_pipes) {
+#ifdef _WIN32
+ /* XXX: NEED Win32 pipe implementation */
+ setStreamMode(STREAM_MODE_TCP);
+#else
+ setStreamMode(STREAM_MODE_UNIX);
+#endif
+ } else {
+ setStreamMode(STREAM_MODE_TCP);
+ }
return 0;
BAD_EXIT:
@@ -165,3 +184,18 @@ android_redrawOpenglesWindow(void)
repaintOpenGLDisplay();
}
}
+
+void
+android_gles_unix_path(char* buff, size_t buffsize, int port)
+{
+ const char* user = getenv("USER");
+ char *p = buff, *end = buff + buffsize;
+
+ /* The logic here must correspond to the one inside
+ * development/tools/emulator/opengl/shared/libOpenglCodecCommon/UnixStream.cpp */
+ p = bufprint(p, end, "/tmp/");
+ if (user && user[0]) {
+ p = bufprint(p, end, "android-%s/", user);
+ }
+ p = bufprint(p, end, "qemu-gles-%d", port);
+}
diff --git a/android/opengles.h b/android/opengles.h
index b31ce11..2202e92 100644
--- a/android/opengles.h
+++ b/android/opengles.h
@@ -12,6 +12,8 @@
#ifndef ANDROID_OPENGLES_H
#define ANDROID_OPENGLES_H
+#include <stddef.h>
+
#define ANDROID_OPENGLES_BASE_PORT 22468
/* Call this function to initialize the hardware opengles emulation.
@@ -34,4 +36,13 @@ void android_redrawOpenglesWindow(void);
/* Stop the renderer process */
void android_stopOpenglesRenderer(void);
+/* set to TRUE if you want to use fast GLES pipes, 0 if you want to
+ * fallback to local TCP ones
+ */
+extern int android_gles_fast_pipes;
+
+/* Write the path of the Unix socket we're going to use to access GLES on a given <port> */
+/* The result is only valid on Unix systems */
+void android_gles_unix_path(char* buff, size_t buffsize, int port);
+
#endif /* ANDROID_OPENGLES_H */