Commit f6a377b0 by Nicolas Capens

Implement eglQueryContext.

Bug b/37991302 Change-Id: I8a1c28d4a9c8968be3a04da64a19ddd3f5274dd6 Reviewed-on: https://swiftshader-review.googlesource.com/9768Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 3532c694
...@@ -35,7 +35,8 @@ public: ...@@ -35,7 +35,8 @@ public:
virtual void bindTexImage(Surface *surface) = 0; virtual void bindTexImage(Surface *surface) = 0;
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0; virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
virtual Image *createSharedImage(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; virtual void finish() = 0;
protected: protected:
......
...@@ -441,7 +441,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh ...@@ -441,7 +441,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
{ {
if(libGLES_CM) 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) || else if((clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT) ||
...@@ -449,7 +449,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh ...@@ -449,7 +449,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
{ {
if(libGLESv2) if(libGLESv2)
{ {
context = libGLESv2->es2CreateContext(this, shareContext, clientVersion); context = libGLESv2->es2CreateContext(this, shareContext, clientVersion, config);
} }
} }
else else
......
...@@ -871,9 +871,25 @@ EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint ...@@ -871,9 +871,25 @@ EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint
return EGL_FALSE; return EGL_FALSE;
} }
UNIMPLEMENTED(); // FIXME switch(attribute)
{
case EGL_CONFIG_ID:
*value = context->getConfigID();
break;
case EGL_CONTEXT_CLIENT_TYPE:
*value = egl::getCurrentAPI();
break;
case EGL_CONTEXT_CLIENT_VERSION:
*value = context->getClientVersion();
break;
case EGL_RENDER_BUFFER:
*value = EGL_BACK_BUFFER;
break;
default:
return error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
return success(0); return success(EGL_TRUE);
} }
EGLBoolean WaitGL(void) EGLBoolean WaitGL(void)
......
...@@ -37,8 +37,8 @@ using std::abs; ...@@ -37,8 +37,8 @@ using std::abs;
namespace es1 namespace es1
{ {
Context::Context(egl::Display *const display, const Context *shareContext) Context::Context(egl::Display *const display, const Context *shareContext, const egl::Config *config)
: egl::Context(display), : egl::Context(display), config(config),
modelViewStack(MAX_MODELVIEW_STACK_DEPTH), modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
projectionStack(MAX_PROJECTION_STACK_DEPTH), projectionStack(MAX_PROJECTION_STACK_DEPTH),
textureStack0(MAX_TEXTURE_STACK_DEPTH), textureStack0(MAX_TEXTURE_STACK_DEPTH),
...@@ -321,11 +321,16 @@ void Context::makeCurrent(egl::Surface *surface) ...@@ -321,11 +321,16 @@ void Context::makeCurrent(egl::Surface *surface)
markAllStateDirty(); markAllStateDirty();
} }
int Context::getClientVersion() const EGLint Context::getClientVersion() const
{ {
return 1; 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. // This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
void Context::markAllStateDirty() void Context::markAllStateDirty()
{ {
...@@ -3470,8 +3475,8 @@ unsigned int Context::getActiveTexture() const ...@@ -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 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);
} }
...@@ -291,14 +291,16 @@ struct State ...@@ -291,14 +291,16 @@ struct State
TextureUnit textureUnit[MAX_TEXTURE_UNITS]; TextureUnit textureUnit[MAX_TEXTURE_UNITS];
}; };
class Context : public egl::Context class [[clang::lto_visibility_public]] Context : public egl::Context
{ {
public: 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); void makeCurrent(egl::Surface *surface) override;
virtual int getClientVersion() const; EGLint getClientVersion() const override;
virtual void finish(); EGLint getConfigID() const override;
void finish() override;
void markAllStateDirty(); void markAllStateDirty();
...@@ -594,6 +596,8 @@ private: ...@@ -594,6 +596,8 @@ private:
bool cullSkipsDraw(GLenum drawMode); bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode); bool isTriangleMode(GLenum drawMode);
const egl::Config *const config;
State mState; State mState;
gl::BindingPointer<Texture2D> mTexture2DZero; gl::BindingPointer<Texture2D> mTexture2DZero;
......
...@@ -219,7 +219,7 @@ public: ...@@ -219,7 +219,7 @@ public:
void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
void (*glDrawTexfvOES)(const GLfloat *coords); 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); __eglMustCastToProperFunctionPointerType (*es1GetProcAddress)(const char *procname);
egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config); 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); egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
......
...@@ -330,7 +330,7 @@ void DrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) ...@@ -330,7 +330,7 @@ void DrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
void DrawTexfvOES(const GLfloat *coords); 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); extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char *procname);
egl::Image *createBackBuffer(int width, int height, const egl::Config *config); 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); egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
namespace es2 namespace es2
{ {
Context::Context(egl::Display *display, const Context *shareContext, EGLint clientVersion) Context::Context(egl::Display *display, const Context *shareContext, EGLint clientVersion, const egl::Config *config)
: egl::Context(display), clientVersion(clientVersion) : egl::Context(display), clientVersion(clientVersion), config(config)
{ {
sw::Context *context = new sw::Context(); sw::Context *context = new sw::Context();
device = new es2::Device(context); device = new es2::Device(context);
...@@ -313,6 +313,11 @@ EGLint Context::getClientVersion() const ...@@ -313,6 +313,11 @@ EGLint Context::getClientVersion() const
return clientVersion; 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. // This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
void Context::markAllStateDirty() void Context::markAllStateDirty()
{ {
...@@ -4358,8 +4363,8 @@ const GLubyte *Context::getExtensions(GLuint index, GLuint *numExt) const ...@@ -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 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);
} }
...@@ -429,10 +429,11 @@ struct State ...@@ -429,10 +429,11 @@ struct State
class [[clang::lto_visibility_public]] Context : public egl::Context class [[clang::lto_visibility_public]] Context : public egl::Context
{ {
public: 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; void makeCurrent(egl::Surface *surface) override;
virtual EGLint getClientVersion() const; EGLint getClientVersion() const override;
EGLint getConfigID() const override;
void markAllStateDirty(); void markAllStateDirty();
...@@ -725,6 +726,7 @@ private: ...@@ -725,6 +726,7 @@ private:
Query *createQuery(GLuint handle, GLenum type); Query *createQuery(GLuint handle, GLenum type);
const EGLint clientVersion; const EGLint clientVersion;
const egl::Config *const config;
State mState; State mState;
......
...@@ -242,7 +242,7 @@ public: ...@@ -242,7 +242,7 @@ public:
void (*glGenerateMipmapOES)(GLenum target); void (*glGenerateMipmapOES)(GLenum target);
void (*glDrawBuffersEXT)(GLsizei n, const GLenum *bufs); 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); __eglMustCastToProperFunctionPointerType (*es2GetProcAddress)(const char *procname);
egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config); 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); egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
......
...@@ -1338,7 +1338,7 @@ void GL_APIENTRY Register(const char *licenseKey) ...@@ -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); extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname);
egl::Image *createBackBuffer(int width, int height, const egl::Config *config); 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); egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment