emulator opengl: context version param

add version parameter when creating new context

Change-Id: I3e36796dd4e582b5deda0da2aaf764ceba92a1d1
This commit is contained in:
Jacky Romano
2011-04-23 22:28:23 +03:00
committed by David 'Digit' Turner
parent 0c814b227c
commit 25af30c464
9 changed files with 25 additions and 16 deletions

View File

@@ -21,9 +21,10 @@
struct EGLWrapperContext struct EGLWrapperContext
{ {
EGLWrapperContext(EGLContext p_aglContext) { EGLWrapperContext(EGLContext p_aglContext, int _version) {
aglContext = p_aglContext; aglContext = p_aglContext;
clientState = NULL; clientState = NULL;
version = _version;
} }
~EGLWrapperContext() { ~EGLWrapperContext() {
@@ -32,6 +33,7 @@ struct EGLWrapperContext
EGLContext aglContext; EGLContext aglContext;
GLClientState *clientState; GLClientState *clientState;
int version;
}; };
struct EGLThreadInfo struct EGLThreadInfo

View File

@@ -404,14 +404,14 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_c
if (share) share = ((EGLWrapperContext *)share_context)->aglContext; if (share) share = ((EGLWrapperContext *)share_context)->aglContext;
EGLContext ctx = getDispatch()->eglCreateContext(dpy, config, share, attrib_list); EGLContext ctx = getDispatch()->eglCreateContext(dpy, config, share, attrib_list);
EGLWrapperContext *wctx = new EGLWrapperContext(ctx); EGLWrapperContext *wctx = new EGLWrapperContext(ctx,1);
if (ctx != EGL_NO_CONTEXT) { if (ctx != EGL_NO_CONTEXT) {
ServerConnection *server; ServerConnection *server;
if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) {
wctx->clientState = new GLClientState(); wctx->clientState = new GLClientState();
server->utEnc()->createContext(server->utEnc(), getpid(), server->utEnc()->createContext(server->utEnc(), getpid(),
(uint32_t)wctx, (uint32_t)wctx,
(uint32_t)(share_context == EGL_NO_CONTEXT ? 0 : share_context)); (uint32_t)(share_context == EGL_NO_CONTEXT ? 0 : share_context), wctx->version);
} }
} }
return (EGLContext)wctx; return (EGLContext)wctx;

View File

@@ -1,4 +1,4 @@
GL_ENTRY(int, createContext, uint32_t pid, uint32_t handle, uint32_t shareCtx) GL_ENTRY(int, createContext, uint32_t pid, uint32_t handle, uint32_t shareCtx, int version)
GL_ENTRY(int, createSurface, uint32_t pid, uint32_t handle) GL_ENTRY(int, createSurface, uint32_t pid, uint32_t handle)
GL_ENTRY(int, makeCurrentContext, uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctxHandle) GL_ENTRY(int, makeCurrentContext, uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctxHandle)
GL_ENTRY(void, swapBuffers, uint32_t pid, uint32_t surface) GL_ENTRY(void, swapBuffers, uint32_t pid, uint32_t surface)

View File

@@ -88,7 +88,7 @@ int Renderer::destroySurface(RenderingThread *thread, const ClientHandle &handle
return 0; return 0;
} }
int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle, ClientHandle shareCtx) int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle, ClientHandle shareCtx, int version)
{ {
android::Mutex::Autolock(this->m_mutex); android::Mutex::Autolock(this->m_mutex);
@@ -104,7 +104,7 @@ int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle,
RendererContext *ctx = RendererContext *ctx =
RendererContext::create(m_dpy, RendererContext::create(m_dpy,
RendererSurface::getEglConfig(m_dpy, RendererSurface::CONFIG_DEPTH), RendererSurface::getEglConfig(m_dpy, RendererSurface::CONFIG_DEPTH),
shared); shared, version);
if (ctx == NULL) { if (ctx == NULL) {
fprintf(stderr, "failed to create context\n"); fprintf(stderr, "failed to create context\n");
return -1; return -1;

View File

@@ -41,7 +41,7 @@ public:
static Renderer *instance(); static Renderer *instance();
int createSurface(RenderingThread *thread, const ClientHandle & handle); int createSurface(RenderingThread *thread, const ClientHandle & handle);
int destroySurface(RenderingThread *thread, const ClientHandle &handle); int destroySurface(RenderingThread *thread, const ClientHandle &handle);
int createContext(RenderingThread *thread, const ClientHandle & ctx, const ClientHandle shareCtx); int createContext(RenderingThread *thread, const ClientHandle & ctx, const ClientHandle shareCtx, int version);
int destroyContext(RenderingThread *thread,const ClientHandle & ctx); int destroyContext(RenderingThread *thread,const ClientHandle & ctx);
int makeCurrent(RenderingThread *thread, int makeCurrent(RenderingThread *thread,
const ClientHandle & drawSurface, const ClientHandle & readSurface, const ClientHandle & ctx); const ClientHandle & drawSurface, const ClientHandle & readSurface, const ClientHandle & ctx);

View File

@@ -17,14 +17,18 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
RendererContext * RendererContext::create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx) RendererContext * RendererContext::create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx, int version)
{ {
EGLContext ctx; EGLContext ctx;
EGLContext shared = shareCtx == NULL ? EGL_NO_CONTEXT : shareCtx->eglContext(); EGLContext shared = shareCtx == NULL ? EGL_NO_CONTEXT : shareCtx->eglContext();
ctx = eglCreateContext(dpy, config, shared, NULL);
EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 1, EGL_NONE };
context_attributes[1] = version;
ctx = eglCreateContext(dpy, config, shared, context_attributes);
if (eglGetError() != EGL_SUCCESS) return NULL; if (eglGetError() != EGL_SUCCESS) return NULL;
return new RendererContext(dpy, ctx); return new RendererContext(dpy, ctx, version);
} }
int RendererContext::destroy() int RendererContext::destroy()

View File

@@ -38,7 +38,7 @@ typedef std::set<PendingCropRect *> PendingCropRectSet;
class RendererContext : public RendererObject { class RendererContext : public RendererObject {
public: public:
static RendererContext *create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx); static RendererContext *create(EGLDisplay dpy, EGLConfig config, RendererContext *shareCtx, int version);
EGLContext eglContext() { return m_ctx; } EGLContext eglContext() { return m_ctx; }
int destroy(); int destroy();
GLDecoderContextData & decoderContextData() { return m_contextData; } GLDecoderContextData & decoderContextData() { return m_contextData; }
@@ -99,10 +99,12 @@ private:
EGLDisplay m_dpy; EGLDisplay m_dpy;
EGLContext m_ctx; EGLContext m_ctx;
GLDecoderContextData m_contextData; GLDecoderContextData m_contextData;
int m_version;
RendererContext(EGLDisplay dpy, EGLContext ctx) : RendererContext(EGLDisplay dpy, EGLContext ctx, int version) :
m_dpy(dpy), m_dpy(dpy),
m_ctx(ctx) m_ctx(ctx),
m_version(version)
{ {
#ifdef PVR_WAR #ifdef PVR_WAR
m_activeTexture = 0; m_activeTexture = 0;

View File

@@ -210,10 +210,11 @@ void RenderingThread::fixTextureEnable()
#endif #endif
int RenderingThread::s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx) int RenderingThread::s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx, int version)
{ {
return Renderer::instance()->createContext(m_tls, Renderer::ClientHandle(pid, handle), return Renderer::instance()->createContext(m_tls, Renderer::ClientHandle(pid, handle),
Renderer::ClientHandle(pid, shareCtx)); Renderer::ClientHandle(pid, shareCtx),
version);
} }

View File

@@ -62,7 +62,7 @@ private:
static void * s_thread(void *data); static void * s_thread(void *data);
static __thread RenderingThread *m_tls; static __thread RenderingThread *m_tls;
static int s_createContext(uint32_t pid, uint32_t handle, uint32_t shareCtx); 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_createSurface(uint32_t pid, uint32_t handle);
static int s_destroySurface(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_destroyContext(uint32_t pid, uint32_t handle);