OSDN Git Service

Implement eglQueryContext.
authorNicolas Capens <capn@google.com>
Fri, 19 May 2017 13:31:35 +0000 (09:31 -0400)
committerNicolas Capens <capn@google.com>
Fri, 19 May 2017 20:34:01 +0000 (20:34 +0000)
Bug b/37991302

Change-Id: I8a1c28d4a9c8968be3a04da64a19ddd3f5274dd6
Reviewed-on: https://swiftshader-review.googlesource.com/9768
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/libEGL/Context.hpp
src/OpenGL/libEGL/Display.cpp
src/OpenGL/libEGL/libEGL.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 da3246c..70a47a6 100644 (file)
@@ -35,7 +35,8 @@ public:
        virtual void bindTexImage(Surface *surface) = 0;
        virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
        virtual Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
-       virtual int getClientVersion() const = 0;
+       virtual EGLint getClientVersion() const = 0;
+       virtual EGLint getConfigID() const = 0;
        virtual void finish() = 0;
 
 protected:
index ff30812..b5097ac 100644 (file)
@@ -441,7 +441,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
        {
                if(libGLES_CM)
                {
-                       context = libGLES_CM->es1CreateContext(this, shareContext);
+                       context = libGLES_CM->es1CreateContext(this, shareContext, config);
                }
        }
        else if((clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT) ||
@@ -449,7 +449,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
        {
                if(libGLESv2)
                {
-                       context = libGLESv2->es2CreateContext(this, shareContext, clientVersion);
+                       context = libGLESv2->es2CreateContext(this, shareContext, clientVersion, config);
                }
        }
        else
index 4a1998f..3103abf 100644 (file)
@@ -871,9 +871,25 @@ EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint
                return EGL_FALSE;
        }
 
-       UNIMPLEMENTED();   // FIXME
+       switch(attribute)
+       {
+       case EGL_CONFIG_ID:\r
+               *value = context->getConfigID();\r
+               break;\r
+       case EGL_CONTEXT_CLIENT_TYPE:\r
+               *value = egl::getCurrentAPI();\r
+               break;\r
+       case EGL_CONTEXT_CLIENT_VERSION:
+               *value = context->getClientVersion();
+               break;
+       case EGL_RENDER_BUFFER:
+               *value = EGL_BACK_BUFFER;\r
+               break;
+       default:
+               return error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+       }
 
-       return success(0);
+       return success(EGL_TRUE);
 }
 
 EGLBoolean WaitGL(void)
index 1a4ed35..78fcec5 100644 (file)
@@ -37,8 +37,8 @@ using std::abs;
 
 namespace es1
 {
-Context::Context(egl::Display *const display, const Context *shareContext)
-       : egl::Context(display),
+Context::Context(egl::Display *const display, const Context *shareContext, const egl::Config *config)
+       : egl::Context(display), config(config),
          modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
          projectionStack(MAX_PROJECTION_STACK_DEPTH),
          textureStack0(MAX_TEXTURE_STACK_DEPTH),
@@ -321,11 +321,16 @@ void Context::makeCurrent(egl::Surface *surface)
        markAllStateDirty();
 }
 
-int Context::getClientVersion() const
+EGLint Context::getClientVersion() const
 {
        return 1;
 }
 
+EGLint Context::getConfigID() const
+{
+       return config->mConfigID;
+}
+
 // This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
 void Context::markAllStateDirty()
 {
@@ -3470,8 +3475,8 @@ unsigned int Context::getActiveTexture() const
 
 }
 
-egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext)
+egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext, const egl::Config *config)
 {
        ASSERT(!shareContext || shareContext->getClientVersion() == 1);   // Should be checked by eglCreateContext
-       return new es1::Context(display, static_cast<const es1::Context*>(shareContext));
+       return new es1::Context(display, static_cast<const es1::Context*>(shareContext), config);
 }
index 24e5a08..63efb74 100644 (file)
@@ -291,14 +291,16 @@ struct State
        TextureUnit textureUnit[MAX_TEXTURE_UNITS];
 };
 
-class Context : public egl::Context
+class [[clang::lto_visibility_public]] Context : public egl::Context
 {
 public:
-       Context(egl::Display *display, const Context *shareContext);
+       Context(egl::Display *display, const Context *shareContext, const egl::Config *config);
 
-       virtual void makeCurrent(egl::Surface *surface);
-       virtual int getClientVersion() const;
-       virtual void finish();
+       void makeCurrent(egl::Surface *surface) override;
+       EGLint getClientVersion() const override;
+       EGLint getConfigID() const override;
+
+       void finish() override;
 
        void markAllStateDirty();
 
@@ -594,6 +596,8 @@ private:
        bool cullSkipsDraw(GLenum drawMode);
        bool isTriangleMode(GLenum drawMode);
 
+       const egl::Config *const config;
+
        State mState;
 
        gl::BindingPointer<Texture2D> mTexture2DZero;
index 08644c6..1c66f18 100644 (file)
@@ -219,7 +219,7 @@ public:
        void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
        void (*glDrawTexfvOES)(const GLfloat *coords);
 
-       egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Context *shareContext);
+       egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Context *shareContext, const egl::Config *config);
        __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);
index 4840522..036147f 100644 (file)
@@ -330,7 +330,7 @@ void DrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
 void DrawTexfvOES(const GLfloat *coords);
 }
 
-egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext);
+egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext, const egl::Config *config);
 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);
index 0504a31..00ad92c 100644 (file)
@@ -45,8 +45,8 @@
 
 namespace es2
 {
-Context::Context(egl::Display *display, const Context *shareContext, EGLint clientVersion)
-       : egl::Context(display), clientVersion(clientVersion)
+Context::Context(egl::Display *display, const Context *shareContext, EGLint clientVersion, const egl::Config *config)
+       : egl::Context(display), clientVersion(clientVersion), config(config)
 {
        sw::Context *context = new sw::Context();
        device = new es2::Device(context);
@@ -313,6 +313,11 @@ EGLint Context::getClientVersion() const
        return clientVersion;
 }
 
+EGLint Context::getConfigID() const
+{
+       return config->mConfigID;
+}
+
 // This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
 void Context::markAllStateDirty()
 {
@@ -4358,8 +4363,8 @@ const GLubyte *Context::getExtensions(GLuint index, GLuint *numExt) const
 
 }
 
-egl::Context *es2CreateContext(egl::Display *display, const egl::Context *shareContext, int clientVersion)
+egl::Context *es2CreateContext(egl::Display *display, const egl::Context *shareContext, int clientVersion, const egl::Config *config)
 {
        ASSERT(!shareContext || shareContext->getClientVersion() == clientVersion);   // Should be checked by eglCreateContext
-       return new es2::Context(display, static_cast<const es2::Context*>(shareContext), clientVersion);
+       return new es2::Context(display, static_cast<const es2::Context*>(shareContext), clientVersion, config);
 }
index a6c6e71..a8e450a 100644 (file)
@@ -429,10 +429,11 @@ struct State
 class [[clang::lto_visibility_public]] Context : public egl::Context
 {
 public:
-       Context(egl::Display *display, const Context *shareContext, EGLint clientVersion);
+       Context(egl::Display *display, const Context *shareContext, EGLint clientVersion, const egl::Config *config);
 
        void makeCurrent(egl::Surface *surface) override;
-       virtual EGLint getClientVersion() const;
+       EGLint getClientVersion() const override;
+       EGLint getConfigID() const override;
 
        void markAllStateDirty();
 
@@ -725,6 +726,7 @@ private:
        Query *createQuery(GLuint handle, GLenum type);
 
        const EGLint clientVersion;
+       const egl::Config *const config;
 
        State mState;
 
index 89811c3..0b9e135 100644 (file)
@@ -242,7 +242,7 @@ public:
        void (*glGenerateMipmapOES)(GLenum target);
        void (*glDrawBuffersEXT)(GLsizei n, const GLenum *bufs);
 
-       egl::Context *(*es2CreateContext)(egl::Display *display, const egl::Context *shareContext, int clientVersion);
+       egl::Context *(*es2CreateContext)(egl::Display *display, const egl::Context *shareContext, int clientVersion, const egl::Config *config);
        __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);
index 28efe8c..de3e7e1 100644 (file)
@@ -1338,7 +1338,7 @@ void GL_APIENTRY Register(const char *licenseKey)
 }
 }
 
-egl::Context *es2CreateContext(egl::Display *display, const egl::Context *shareContext, int clientVersion);
+egl::Context *es2CreateContext(egl::Display *display, const egl::Context *shareContext, int clientVersion, const egl::Config *config);
 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);