OSDN Git Service

Add the EGL display as a context member.
authorNicolas Capens <capn@google.com>
Tue, 7 Jun 2016 18:40:12 +0000 (14:40 -0400)
committerNicolas Capens <capn@google.com>
Wed, 8 Jun 2016 15:46:20 +0000 (15:46 +0000)
This prevents having to access the current display though TLS.

Change-Id: Ic93d0f88096a7e7e50318dbafb9b32da5fbc50a2
Reviewed-on: https://swiftshader-review.googlesource.com/5511
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Meng-Lin Wu <marleymoo@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/libEGL/Context.hpp
src/OpenGL/libEGL/Display.cpp
src/OpenGL/libGLES_CM/Context.cpp
src/OpenGL/libGLES_CM/Context.h
src/OpenGL/libGLES_CM/libGLES_CM.hpp
src/OpenGL/libGLES_CM/main.cpp
src/OpenGL/libGLESv2/Context.cpp
src/OpenGL/libGLESv2/Context.h
src/OpenGL/libGLESv2/libGLESv2.hpp
src/OpenGL/libGLESv2/main.cpp

index f44fec3..182516e 100644 (file)
 
 namespace egl
 {
+class Display;
 class Surface;
 class Image;
 
 class Context : public gl::Object
 {
 public:
+       Context(egl::Display *display) : display(display) {}
+
        virtual void makeCurrent(Surface *surface) = 0;
        virtual void bindTexImage(Surface *surface) = 0;
        virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
@@ -37,6 +40,8 @@ public:
 
 protected:
        virtual ~Context() {};
+
+       egl::Display *const display;
 };
 }
 
index 799b072..0e8465e 100644 (file)
@@ -411,13 +411,13 @@ EGLSurface Display::createPBufferSurface(EGLConfig config, const EGLint *attribL
 EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *shareContext, EGLint clientVersion)
 {
        const egl::Config *config = mConfigSet.get(configHandle);
-       egl::Context *context = 0;
+       egl::Context *context = nullptr;
 
        if(clientVersion == 1 && config->mRenderableType & EGL_OPENGL_ES_BIT)
        {
                if(libGLES_CM)
                {
-                       context = libGLES_CM->es1CreateContext(config, shareContext);
+                       context = libGLES_CM->es1CreateContext(this, config, shareContext);
                }
        }
        else if((clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT)
@@ -428,7 +428,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
        {
                if(libGLESv2)
                {
-                       context = libGLESv2->es2CreateContext(config, shareContext, clientVersion);
+                       context = libGLESv2->es2CreateContext(this, config, shareContext, clientVersion);
                }
        }
        else
index 8650d84..ba34dab 100644 (file)
@@ -37,8 +37,9 @@ using std::abs;
 
 namespace es1
 {
-Context::Context(const egl::Config *config, const Context *shareContext)
-       : modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
+Context::Context(egl::Display *const display, const egl::Config *config, const Context *shareContext)
+       : egl::Context(display),
+         modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
          projectionStack(MAX_PROJECTION_STACK_DEPTH),
          textureStack0(MAX_TEXTURE_STACK_DEPTH),
          textureStack1(MAX_TEXTURE_STACK_DEPTH)
@@ -3446,8 +3447,8 @@ unsigned int Context::getActiveTexture() const
 
 }
 
-egl::Context *es1CreateContext(const egl::Config *config, const egl::Context *shareContext)
+egl::Context *es1CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext)
 {
        ASSERT(!shareContext || shareContext->getClientVersion() == 1);   // Should be checked by eglCreateContext
-       return new es1::Context(config, static_cast<const es1::Context*>(shareContext));
+       return new es1::Context(display, config, static_cast<const es1::Context*>(shareContext));
 }
index 1ee5699..2dee4fa 100644 (file)
@@ -294,7 +294,7 @@ struct State
 class Context : public egl::Context
 {
 public:
-       Context(const egl::Config *config, const Context *shareContext);
+       Context(egl::Display *display, const egl::Config *config, const Context *shareContext);
 
        virtual void makeCurrent(egl::Surface *surface);
        virtual int getClientVersion() const;
index 5c9657b..b92e21f 100644 (file)
@@ -29,6 +29,7 @@ enum Format : unsigned char;
 
 namespace egl
 {
+class Display;
 class Context;
 class Image;
 class Config;
@@ -218,11 +219,11 @@ public:
        void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
        void (*glDrawTexfvOES)(const GLfloat *coords);
 
-       egl::Context *(*es1CreateContext)(const egl::Config *config, const egl::Context *shareContext);
+       egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Config *config, const egl::Context *shareContext);
        __eglMustCastToProperFunctionPointerType (*es1GetProcAddress)(const char *procname);
        egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
        egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
-       sw::FrameBuffer *(*createFrameBuffer)(void *display, EGLNativeWindowType window, int width, int height);
+       sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
 };
 
 class LibGLES_CM
index be2462a..b44b0ec 100644 (file)
@@ -330,11 +330,11 @@ void DrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
 void DrawTexfvOES(const GLfloat *coords);
 }
 
-egl::Context *es1CreateContext(const egl::Config *config, const egl::Context *shareContext);
+egl::Context *es1CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext);
 extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char *procname);
 egl::Image *createBackBuffer(int width, int height, const egl::Config *config);
 egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
-sw::FrameBuffer *createFrameBuffer(void *display, EGLNativeWindowType window, int width, int height);
+sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
 
 extern "C"
 {
index a816725..8583f12 100644 (file)
@@ -42,8 +42,8 @@
 
 namespace es2
 {
-Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)
-       : clientVersion(clientVersion), mConfig(config)
+Context::Context(egl::Display *display, const egl::Config *config, const Context *shareContext, EGLint clientVersion)
+       : egl::Context(display), clientVersion(clientVersion), mConfig(config)
 {
        sw::Context *context = new sw::Context();
        device = new es2::Device(context);
@@ -4361,8 +4361,8 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const
 
 }
 
-egl::Context *es2CreateContext(const egl::Config *config, const egl::Context *shareContext, int clientVersion)
+egl::Context *es2CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion)
 {
        ASSERT(!shareContext || shareContext->getClientVersion() == clientVersion);   // Should be checked by eglCreateContext
-       return new es2::Context(config, static_cast<const es2::Context*>(shareContext), clientVersion);
+       return new es2::Context(display, config, static_cast<const es2::Context*>(shareContext), clientVersion);
 }
index f5775ca..4750485 100644 (file)
@@ -87,7 +87,7 @@ enum
        MAX_ELEMENTS_VERTICES = 0x7FFFFFFF,
        MAX_VERTEX_OUTPUT_VECTORS = 16,
        MAX_FRAGMENT_INPUT_VECTORS = 15,
-       MIN_PROGRAM_TEXEL_OFFSET = sw::MIN_PROGRAM_TEXEL_OFFSET,\r
+       MIN_PROGRAM_TEXEL_OFFSET = sw::MIN_PROGRAM_TEXEL_OFFSET,
        MAX_PROGRAM_TEXEL_OFFSET = sw::MAX_PROGRAM_TEXEL_OFFSET,
        MAX_DRAW_BUFFERS = sw::RENDERTARGETS,
        MAX_COLOR_ATTACHMENTS = MAX(MAX_DRAW_BUFFERS, 8),
@@ -425,7 +425,7 @@ struct State
 class Context : public egl::Context
 {
 public:
-       Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion);
+       Context(egl::Display *display, const egl::Config *config, const Context *shareContext, EGLint clientVersion);
 
        virtual void makeCurrent(egl::Surface *surface);
        virtual EGLint getClientVersion() const;
index 2d98a1c..f858ba7 100644 (file)
@@ -29,6 +29,7 @@ enum Format : unsigned char;
 
 namespace egl
 {
+class Display;
 class Context;
 class Image;
 class Config;
@@ -240,11 +241,11 @@ public:
        void (*glGenerateMipmapOES)(GLenum target);
        void (*glDrawBuffersEXT)(GLsizei n, const GLenum *bufs);
 
-       egl::Context *(*es2CreateContext)(const egl::Config *config, const egl::Context *shareContext, int clientVersion);
+       egl::Context *(*es2CreateContext)(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion);
        __eglMustCastToProperFunctionPointerType (*es2GetProcAddress)(const char *procname);
        egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
        egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
-       sw::FrameBuffer *(*createFrameBuffer)(void *display, EGLNativeWindowType window, int width, int height);
+       sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
 };
 
 class LibGLESv2
index 99d24e1..001aa7a 100644 (file)
@@ -1327,11 +1327,11 @@ GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
 }
 }
 
-egl::Context *es2CreateContext(const egl::Config *config, const egl::Context *shareContext, int clientVersion);
+egl::Context *es2CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion);
 extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname);
 egl::Image *createBackBuffer(int width, int height, const egl::Config *config);
 egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
-sw::FrameBuffer *createFrameBuffer(void *display, EGLNativeWindowType window, int width, int height);
+sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
 
 LibGLESv2exports::LibGLESv2exports()
 {