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
mColorBufferType = EGL_RGB_BUFFER;
mConfigCaveat = isSlowConfig() ? EGL_SLOW_CONFIG : EGL_NONE;
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)
{
......@@ -139,7 +139,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
mNativeRenderable = EGL_FALSE;
mNativeVisualID = 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;
mSamples = multiSample;
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
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)
{
context = es2::createContext(config, shareContext);
context = es2::createContext(config, shareContext, clientVersion);
}
}
else
......
......@@ -104,7 +104,7 @@ CONSTRUCTOR static bool eglAttachProcess()
#endif
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");
es::createBackBuffer = (egl::Image *(*)(int, int, const egl::Config*))getProcAddress(libGLES_CM, "createBackBuffer");
......@@ -342,7 +342,7 @@ namespace es1
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;
}
......
......@@ -92,7 +92,7 @@ namespace es1
// libGLESv2 dependencies
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);
}
......
......@@ -39,7 +39,8 @@
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();
device = new es2::Device(context);
......@@ -272,9 +273,9 @@ void Context::destroy()
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.
......@@ -3245,8 +3246,8 @@ Device *Context::getDevice()
// Exported functions for use by EGL
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
class Context : public egl::Context
{
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 destroy();
virtual int getClientVersion();
virtual EGLint getClientVersion();
void markAllStateDirty();
......@@ -459,6 +459,7 @@ private:
bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode);
const EGLint clientVersion;
const egl::Config *const mConfig;
State mState;
......
......@@ -4086,106 +4086,109 @@ void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat,
return error(GL_INVALID_VALUE);
}
if(internalformat != format)
{
return error(GL_INVALID_OPERATION);
}
es2::Context *context = es2::getContext();
switch(format)
if(context)
{
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
switch(type)
if(context->getClientVersion() < 3)
{
case GL_UNSIGNED_BYTE:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
if(internalformat != format)
{
return error(GL_INVALID_OPERATION);
}
}
break;
case GL_RGB:
switch(type)
switch(format)
{
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
case GL_ALPHA:
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
default:
return error(GL_INVALID_ENUM);
}
break;
case GL_RGBA:
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
case GL_RGB:
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
default:
return error(GL_INVALID_ENUM);
}
break;
case GL_BGRA_EXT:
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_RGBA:
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
default:
return error(GL_INVALID_ENUM);
}
break;
case GL_ETC1_RGB8_OES:
return error(GL_INVALID_OPERATION);
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if(S3TC_SUPPORT)
{
case GL_BGRA_EXT:
switch(type)
{
case GL_UNSIGNED_BYTE:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
case GL_ETC1_RGB8_OES:
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
case GL_DEPTH_COMPONENT:
switch(type)
{
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_INT:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if(S3TC_SUPPORT)
{
return error(GL_INVALID_OPERATION);
}
else
{
return error(GL_INVALID_ENUM);
}
case GL_DEPTH_COMPONENT:
switch(type)
{
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_INT:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
default:
return error(GL_INVALID_ENUM);
}
break;
case GL_DEPTH_STENCIL_OES:
switch(type)
{
case GL_UNSIGNED_INT_24_8_OES:
case GL_DEPTH_STENCIL_OES:
switch(type)
{
case GL_UNSIGNED_INT_24_8_OES:
break;
default:
return error(GL_INVALID_ENUM);
}
break;
default:
return error(GL_INVALID_ENUM);
return error(GL_INVALID_VALUE);
}
break;
default:
return error(GL_INVALID_VALUE);
}
if(border != 0)
{
return error(GL_INVALID_VALUE);
}
es2::Context *context = es2::getContext();
if(border != 0)
{
return error(GL_INVALID_VALUE);
}
if(context)
{
switch(target)
{
case GL_TEXTURE_2D:
......
......@@ -109,7 +109,8 @@ es2::Context *getContext()
{
egl::Context *context = egl::getCurrentContext();
if(context && context->getClientVersion() == 2)
if(context && (context->getClientVersion() == 2 ||
context->getClientVersion() == 3))
{
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