Commit b97ad2e8 by Nicolas Capens

Enable OpenGL ES 3.0 context creation.

Bug 19362672 Change-Id: Ie948dd0c26a6a5f65f6e15b75f2376d598129c28 Reviewed-on: https://swiftshader-review.googlesource.com/2287Tested-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 792950af
...@@ -81,7 +81,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt ...@@ -81,7 +81,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
mColorBufferType = EGL_RGB_BUFFER; mColorBufferType = EGL_RGB_BUFFER;
mConfigCaveat = isSlowConfig() ? EGL_SLOW_CONFIG : EGL_NONE; mConfigCaveat = isSlowConfig() ? EGL_SLOW_CONFIG : EGL_NONE;
mConfigID = 0; mConfigID = 0;
mConformant = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; mConformant = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
switch (depthStencilFormat) switch (depthStencilFormat)
{ {
...@@ -139,7 +139,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt ...@@ -139,7 +139,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
mNativeRenderable = EGL_FALSE; mNativeRenderable = EGL_FALSE;
mNativeVisualID = 0; mNativeVisualID = 0;
mNativeVisualType = 0; mNativeVisualType = 0;
mRenderableType = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; mRenderableType = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
mSampleBuffers = multiSample ? 1 : 0; mSampleBuffers = multiSample ? 1 : 0;
mSamples = multiSample; mSamples = multiSample;
mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
......
...@@ -400,11 +400,12 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh ...@@ -400,11 +400,12 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
context = es1::createContext(config, shareContext); context = es1::createContext(config, shareContext);
} }
} }
else if(clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT) else if((clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT) ||
(clientVersion == 3 && config->mRenderableType & EGL_OPENGL_ES3_BIT))
{ {
if(es2::createContext != 0) if(es2::createContext != 0)
{ {
context = es2::createContext(config, shareContext); context = es2::createContext(config, shareContext, clientVersion);
} }
} }
else else
......
...@@ -104,7 +104,7 @@ CONSTRUCTOR static bool eglAttachProcess() ...@@ -104,7 +104,7 @@ CONSTRUCTOR static bool eglAttachProcess()
#endif #endif
libGLESv2 = loadLibrary(libGLESv2_lib); libGLESv2 = loadLibrary(libGLESv2_lib);
es2::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*))getProcAddress(libGLESv2, "glCreateContext"); es2::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*, EGLint))getProcAddress(libGLESv2, "glCreateContext");
es2::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress"); es2::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
es::createBackBuffer = (egl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLES_CM, "createBackBuffer"); es::createBackBuffer = (egl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLES_CM, "createBackBuffer");
...@@ -342,7 +342,7 @@ namespace es1 ...@@ -342,7 +342,7 @@ namespace es1
namespace es2 namespace es2
{ {
egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext) = 0; egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext, EGLint clientVersion) = 0;
__eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0; __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0;
} }
......
...@@ -92,7 +92,7 @@ namespace es1 ...@@ -92,7 +92,7 @@ namespace es1
// libGLESv2 dependencies // libGLESv2 dependencies
namespace es2 namespace es2
{ {
extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext); extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext, EGLint clientVersion);
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname); extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
} }
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
namespace es2 namespace es2
{ {
Context::Context(const egl::Config *config, const Context *shareContext) : mConfig(config) Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)
: mConfig(config), clientVersion(clientVersion)
{ {
sw::Context *context = new sw::Context(); sw::Context *context = new sw::Context();
device = new es2::Device(context); device = new es2::Device(context);
...@@ -272,9 +273,9 @@ void Context::destroy() ...@@ -272,9 +273,9 @@ void Context::destroy()
delete this; delete this;
} }
int Context::getClientVersion() EGLint Context::getClientVersion()
{ {
return 2; return clientVersion;
} }
// 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.
...@@ -3245,8 +3246,8 @@ Device *Context::getDevice() ...@@ -3245,8 +3246,8 @@ Device *Context::getDevice()
// Exported functions for use by EGL // Exported functions for use by EGL
extern "C" extern "C"
{ {
es2::Context *glCreateContext(const egl::Config *config, const es2::Context *shareContext) es2::Context *glCreateContext(const egl::Config *config, const es2::Context *shareContext, int clientVersion)
{ {
return new es2::Context(config, shareContext); return new es2::Context(config, shareContext, clientVersion);
} }
} }
...@@ -251,11 +251,11 @@ struct State ...@@ -251,11 +251,11 @@ struct State
class Context : public egl::Context class Context : public egl::Context
{ {
public: public:
Context(const egl::Config *config, const Context *shareContext); Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion);
virtual void makeCurrent(egl::Surface *surface); virtual void makeCurrent(egl::Surface *surface);
virtual void destroy(); virtual void destroy();
virtual int getClientVersion(); virtual EGLint getClientVersion();
void markAllStateDirty(); void markAllStateDirty();
...@@ -459,6 +459,7 @@ private: ...@@ -459,6 +459,7 @@ private:
bool cullSkipsDraw(GLenum drawMode); bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode); bool isTriangleMode(GLenum drawMode);
const EGLint clientVersion;
const egl::Config *const mConfig; const egl::Config *const mConfig;
State mState; State mState;
......
...@@ -4086,10 +4086,17 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, ...@@ -4086,10 +4086,17 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat,
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
es2::Context *context = es2::getContext();
if(context)
{
if(context->getClientVersion() < 3)
{
if(internalformat != format) if(internalformat != format)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
}
switch(format) switch(format)
{ {
...@@ -4182,10 +4189,6 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, ...@@ -4182,10 +4189,6 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat,
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
es2::Context *context = es2::getContext();
if(context)
{
switch(target) switch(target)
{ {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
......
...@@ -109,7 +109,8 @@ es2::Context *getContext() ...@@ -109,7 +109,8 @@ es2::Context *getContext()
{ {
egl::Context *context = egl::getCurrentContext(); egl::Context *context = egl::getCurrentContext();
if(context && context->getClientVersion() == 2) if(context && (context->getClientVersion() == 2 ||
context->getClientVersion() == 3))
{ {
return static_cast<es2::Context*>(context); return static_cast<es2::Context*>(context);
} }
......
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