Files
android_development/tools/emulator/opengl/tests/ut_renderer/RenderingThread.h
David 'Digit' Turner 3d76ec1e3c emulator: opengl: Add support for unix sockets.
This patch allows the OpenGLES rendering library to use Unix
sockets instead of TCP ones when communicating with its clients.
On certain benchmarks (e.g. 0xBench teapot), this provides a
noticeable improvement (x1.05 fps) without any other changes.

On practice, Unix sockets are faster than TCP sockets, even
local ones. Also, this introduces a moderate amount of
abstraction that will allow us to use Win32 named pipes
on Windows (where TCP sockets are much slower than they
are on Unix).

Note that by default, TCP streams are still used.
The client (emulator) must call the new API 'setStreamMode'
to change it to STREAM_MODE_UNIX between 'initLibrary' and
'startOpenglRenderer' calls.

+ Adjust callers / user appropriately.

Change-Id: I4105bbf07541f3146b50a58d1a5b51e8cf044fab
2011-09-13 14:03:32 +02:00

118 lines
4.1 KiB
C++

/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _RENDERING_THREAD_H_
#define _RENDERING_THREAD_H_
#include "SocketStream.h"
#include "GLDecoder.h"
#include "GL2Decoder.h"
#include "ut_rendercontrol_dec.h"
#include <pthread.h>
#define GL_API
#define GL_APIENTRY
#include <GLES/egl.h>
#include <GLES/gl.h>
#define WINDOW_WIDTH 320
#define WINDOW_HEIGHT 480
#define DECODER_BUF_SIZE (4 * 1024 * 1024)
class RendererContext;
class RenderingThread {
public:
RenderingThread(SocketStream *stream);
int start();
void *thread();
RendererContext *currentContext() { return m_currentContext; }
void setCurrentContext(RendererContext *ctx) { m_currentContext = ctx; }
GLDecoder & glDecoder() { return m_glDec; }
GL2Decoder & gl2Decoder() { return m_gl2Dec; }
private:
void initBackendCaps();
private:
GLDecoder m_glDec;
ut_rendercontrol_decoder_context_t m_utDec;
GL2Decoder m_gl2Dec;
SocketStream *m_stream;
pthread_t m_thread;
RendererContext * m_currentContext;
struct BackendCaps {
bool initialized;
GLuint maxTextureUnits;
} m_backendCaps;
static void * s_thread(void *data);
static __thread RenderingThread *m_tls;
static int s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx, int version);
static int s_createSurface(uint32_t pid, uint32_t handle);
static int s_destroySurface(uint32_t pid, uint32_t handle);
static int s_destroyContext(uint32_t pid, uint32_t handle);
static int s_makeCurrent(uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctx);
static void s_swapBuffers(uint32_t pid, uint32_t surface);
#ifdef PVR_WAR
static void s_glTexParameteriv(GLenum target, GLenum param, const int *p);
static void s_glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h);
static void s_glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort w, GLshort h);
static void s_glDrawTexiOES(GLint x, GLint y, GLint z, GLint w, GLint h);
static void s_glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h);
static void s_glDrawTexfvOES(const GLfloat *coords);
static void s_glDrawTexsvOES(const GLshort *coords);
static void s_glDrawTexivOES(const GLint *coords);
static void s_glDrawTexxvOES(const GLfixed *coords);
static void s_glActiveTexture(GLenum texture);
static void s_glBindTexture(GLenum target, GLuint texture);
static void s_glEnable(GLenum cap);
static void s_glDisable(GLenum cap);
static void s_glClientActiveTexture(GLenum texture);
static void s_glEnableClientState(GLenum cap);
static void s_glDisableClientState(GLenum cap);
void applyPendingCropRects();
void fixTextureEnable();
glTexParameteriv_server_proc_t m_glTexParameteriv;
glDrawTexfOES_server_proc_t m_glDrawTexfOES;
glDrawTexiOES_server_proc_t m_glDrawTexiOES;
glDrawTexsOES_server_proc_t m_glDrawTexsOES;
glDrawTexxOES_server_proc_t m_glDrawTexxOES;
glDrawTexfvOES_server_proc_t m_glDrawTexfvOES;
glDrawTexivOES_server_proc_t m_glDrawTexivOES;
glDrawTexsvOES_server_proc_t m_glDrawTexsvOES;
glDrawTexxvOES_server_proc_t m_glDrawTexxvOES;
glActiveTexture_server_proc_t m_glActiveTexture;
glBindTexture_server_proc_t m_glBindTexture;
glEnable_server_proc_t m_glEnable;
glDisable_server_proc_t m_glDisable;
glClientActiveTexture_server_proc_t m_glClientActiveTexture;
glEnableClientState_server_proc_t m_glEnableClientState;
glDisableClientState_server_proc_t m_glDisableClientState;
#endif
};
#endif