eglCreateContext passes the client version to the context. gl::Context stores…

eglCreateContext passes the client version to the context. gl::Context stores the client version to validate gl function parameters. TRAC #22694 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2067 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 89ae1133
...@@ -373,7 +373,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, ...@@ -373,7 +373,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return success(surface); return success(surface);
} }
EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess) EGLContext Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess)
{ {
if (!mRenderer) if (!mRenderer)
{ {
...@@ -385,7 +385,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha ...@@ -385,7 +385,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *sha
return NULL; return NULL;
} }
gl::Context *context = glCreateContext(shareContext, mRenderer, notifyResets, robustAccess); gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess);
mContextSet.insert(context); mContextSet.insert(context);
return context; return context;
......
...@@ -42,7 +42,7 @@ class Display ...@@ -42,7 +42,7 @@ class Display
EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList); EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList); EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess); EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
void destroySurface(egl::Surface *surface); void destroySurface(egl::Surface *surface);
void destroyContext(gl::Context *context); void destroyContext(gl::Context *context);
......
...@@ -814,15 +814,23 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte ...@@ -814,15 +814,23 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
} }
} }
if (client_version != 2) if (client_version != 2 && client_version != 3)
{ {
return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
} }
if (share_context && static_cast<gl::Context*>(share_context)->isResetNotificationEnabled() != reset_notification) if (share_context)
{
gl::Context* glContext = static_cast<gl::Context*>(share_context);
if (glContext->isResetNotificationEnabled() != reset_notification)
{ {
return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT); return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
} }
if (glContext->getClientVersion() != client_version)
{
return egl::error(EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
}
}
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -831,7 +839,7 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte ...@@ -831,7 +839,7 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
return EGL_NO_CONTEXT; return EGL_NO_CONTEXT;
} }
EGLContext context = display->createContext(config, static_cast<gl::Context*>(share_context), reset_notification, robust_access); EGLContext context = display->createContext(config, client_version, static_cast<gl::Context*>(share_context), reset_notification, robust_access);
if (context) if (context)
return egl::success(context); return egl::success(context);
......
...@@ -42,7 +42,7 @@ static const char* makeStaticString(const std::string& str) ...@@ -42,7 +42,7 @@ static const char* makeStaticString(const std::string& str)
return strings.insert(str).first->c_str(); return strings.insert(str).first->c_str();
} }
Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer) Context::Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) : mRenderer(renderer)
{ {
ASSERT(robustAccess == false); // Unimplemented ASSERT(robustAccess == false); // Unimplemented
...@@ -50,6 +50,8 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n ...@@ -50,6 +50,8 @@ Context::Context(const gl::Context *shareContext, rx::Renderer *renderer, bool n
setClearColor(0.0f, 0.0f, 0.0f, 0.0f); setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
mClientVersion = clientVersion;
mState.depthClearValue = 1.0f; mState.depthClearValue = 1.0f;
mState.stencilClearValue = 0; mState.stencilClearValue = 0;
...@@ -2123,6 +2125,11 @@ bool Context::isResetNotificationEnabled() ...@@ -2123,6 +2125,11 @@ bool Context::isResetNotificationEnabled()
return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT); return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
} }
int Context::getClientVersion() const
{
return mClientVersion;
}
int Context::getMajorShaderModel() const int Context::getMajorShaderModel() const
{ {
return mMajorShaderModel; return mMajorShaderModel;
...@@ -2884,9 +2891,9 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -2884,9 +2891,9 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
extern "C" extern "C"
{ {
gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess) gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess)
{ {
return new gl::Context(shareContext, renderer, notifyResets, robustAccess); return new gl::Context(clientVersion, shareContext, renderer, notifyResets, robustAccess);
} }
void glDestroyContext(gl::Context *context) void glDestroyContext(gl::Context *context)
......
...@@ -169,7 +169,7 @@ struct State ...@@ -169,7 +169,7 @@ struct State
class Context class Context
{ {
public: public:
Context(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess); Context(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
~Context(); ~Context();
...@@ -359,6 +359,8 @@ class Context ...@@ -359,6 +359,8 @@ class Context
GLenum getResetStatus(); GLenum getResetStatus();
virtual bool isResetNotificationEnabled(); virtual bool isResetNotificationEnabled();
virtual int getClientVersion() const;
int getMajorShaderModel() const; int getMajorShaderModel() const;
float getMaximumPointSize() const; float getMaximumPointSize() const;
unsigned int getMaximumCombinedTextureImageUnits() const; unsigned int getMaximumCombinedTextureImageUnits() const;
...@@ -421,6 +423,8 @@ class Context ...@@ -421,6 +423,8 @@ class Context
rx::Renderer *const mRenderer; rx::Renderer *const mRenderer;
int mClientVersion;
State mState; State mState;
BindingPointer<Texture2D> mTexture2DZero; BindingPointer<Texture2D> mTexture2DZero;
......
...@@ -54,7 +54,7 @@ class Renderer; ...@@ -54,7 +54,7 @@ class Renderer;
extern "C" extern "C"
{ {
// Exported functions for use by EGL // Exported functions for use by EGL
gl::Context *glCreateContext(const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess); gl::Context *glCreateContext(int clientVersion, const gl::Context *shareContext, rx::Renderer *renderer, bool notifyResets, bool robustAccess);
void glDestroyContext(gl::Context *context); void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface); void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext(); gl::Context *glGetCurrentContext();
......
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