Commit e7e70d03 by Nicolas Capens

Add the EGL display as a context member.

This prevents having to access the current display though TLS. Change-Id: Ic93d0f88096a7e7e50318dbafb9b32da5fbc50a2 Reviewed-on: https://swiftshader-review.googlesource.com/5511Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarMeng-Lin Wu <marleymoo@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 3345779e
......@@ -22,12 +22,15 @@
namespace egl
{
class Display;
class Surface;
class Image;
class Context : public gl::Object
{
public:
Context(egl::Display *display) : display(display) {}
virtual void makeCurrent(Surface *surface) = 0;
virtual void bindTexImage(Surface *surface) = 0;
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel) = 0;
......@@ -37,6 +40,8 @@ public:
protected:
virtual ~Context() {};
egl::Display *const display;
};
}
......
......@@ -411,13 +411,13 @@ EGLSurface Display::createPBufferSurface(EGLConfig config, const EGLint *attribL
EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *shareContext, EGLint clientVersion)
{
const egl::Config *config = mConfigSet.get(configHandle);
egl::Context *context = 0;
egl::Context *context = nullptr;
if(clientVersion == 1 && config->mRenderableType & EGL_OPENGL_ES_BIT)
{
if(libGLES_CM)
{
context = libGLES_CM->es1CreateContext(config, shareContext);
context = libGLES_CM->es1CreateContext(this, config, shareContext);
}
}
else if((clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT)
......@@ -428,7 +428,7 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
{
if(libGLESv2)
{
context = libGLESv2->es2CreateContext(config, shareContext, clientVersion);
context = libGLESv2->es2CreateContext(this, config, shareContext, clientVersion);
}
}
else
......
......@@ -37,8 +37,9 @@ using std::abs;
namespace es1
{
Context::Context(const egl::Config *config, const Context *shareContext)
: modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
Context::Context(egl::Display *const display, const egl::Config *config, const Context *shareContext)
: egl::Context(display),
modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
projectionStack(MAX_PROJECTION_STACK_DEPTH),
textureStack0(MAX_TEXTURE_STACK_DEPTH),
textureStack1(MAX_TEXTURE_STACK_DEPTH)
......@@ -3446,8 +3447,8 @@ unsigned int Context::getActiveTexture() const
}
egl::Context *es1CreateContext(const egl::Config *config, const egl::Context *shareContext)
egl::Context *es1CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext)
{
ASSERT(!shareContext || shareContext->getClientVersion() == 1); // Should be checked by eglCreateContext
return new es1::Context(config, static_cast<const es1::Context*>(shareContext));
return new es1::Context(display, config, static_cast<const es1::Context*>(shareContext));
}
......@@ -294,7 +294,7 @@ struct State
class Context : public egl::Context
{
public:
Context(const egl::Config *config, const Context *shareContext);
Context(egl::Display *display, const egl::Config *config, const Context *shareContext);
virtual void makeCurrent(egl::Surface *surface);
virtual int getClientVersion() const;
......
......@@ -29,6 +29,7 @@ enum Format : unsigned char;
namespace egl
{
class Display;
class Context;
class Image;
class Config;
......@@ -218,11 +219,11 @@ public:
void (*glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
void (*glDrawTexfvOES)(const GLfloat *coords);
egl::Context *(*es1CreateContext)(const egl::Config *config, const egl::Context *shareContext);
egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Config *config, const egl::Context *shareContext);
__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);
sw::FrameBuffer *(*createFrameBuffer)(void *display, EGLNativeWindowType window, int width, int height);
sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
};
class LibGLES_CM
......
......@@ -330,11 +330,11 @@ void DrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
void DrawTexfvOES(const GLfloat *coords);
}
egl::Context *es1CreateContext(const egl::Config *config, const egl::Context *shareContext);
egl::Context *es1CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext);
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);
sw::FrameBuffer *createFrameBuffer(void *display, EGLNativeWindowType window, int width, int height);
sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
extern "C"
{
......
......@@ -42,8 +42,8 @@
namespace es2
{
Context::Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion)
: clientVersion(clientVersion), mConfig(config)
Context::Context(egl::Display *display, const egl::Config *config, const Context *shareContext, EGLint clientVersion)
: egl::Context(display), clientVersion(clientVersion), mConfig(config)
{
sw::Context *context = new sw::Context();
device = new es2::Device(context);
......@@ -4361,8 +4361,8 @@ const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt) const
}
egl::Context *es2CreateContext(const egl::Config *config, const egl::Context *shareContext, int clientVersion)
egl::Context *es2CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion)
{
ASSERT(!shareContext || shareContext->getClientVersion() == clientVersion); // Should be checked by eglCreateContext
return new es2::Context(config, static_cast<const es2::Context*>(shareContext), clientVersion);
return new es2::Context(display, config, static_cast<const es2::Context*>(shareContext), clientVersion);
}
......@@ -87,7 +87,7 @@ enum
MAX_ELEMENTS_VERTICES = 0x7FFFFFFF,
MAX_VERTEX_OUTPUT_VECTORS = 16,
MAX_FRAGMENT_INPUT_VECTORS = 15,
MIN_PROGRAM_TEXEL_OFFSET = sw::MIN_PROGRAM_TEXEL_OFFSET,
MIN_PROGRAM_TEXEL_OFFSET = sw::MIN_PROGRAM_TEXEL_OFFSET,
MAX_PROGRAM_TEXEL_OFFSET = sw::MAX_PROGRAM_TEXEL_OFFSET,
MAX_DRAW_BUFFERS = sw::RENDERTARGETS,
MAX_COLOR_ATTACHMENTS = MAX(MAX_DRAW_BUFFERS, 8),
......@@ -425,7 +425,7 @@ struct State
class Context : public egl::Context
{
public:
Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion);
Context(egl::Display *display, const egl::Config *config, const Context *shareContext, EGLint clientVersion);
virtual void makeCurrent(egl::Surface *surface);
virtual EGLint getClientVersion() const;
......
......@@ -29,6 +29,7 @@ enum Format : unsigned char;
namespace egl
{
class Display;
class Context;
class Image;
class Config;
......@@ -240,11 +241,11 @@ public:
void (*glGenerateMipmapOES)(GLenum target);
void (*glDrawBuffersEXT)(GLsizei n, const GLenum *bufs);
egl::Context *(*es2CreateContext)(const egl::Config *config, const egl::Context *shareContext, int clientVersion);
egl::Context *(*es2CreateContext)(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion);
__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);
sw::FrameBuffer *(*createFrameBuffer)(void *display, EGLNativeWindowType window, int width, int height);
sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
};
class LibGLESv2
......
......@@ -1327,11 +1327,11 @@ GL_APICALL void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
}
}
egl::Context *es2CreateContext(const egl::Config *config, const egl::Context *shareContext, int clientVersion);
egl::Context *es2CreateContext(egl::Display *display, const egl::Config *config, const egl::Context *shareContext, int clientVersion);
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);
sw::FrameBuffer *createFrameBuffer(void *display, EGLNativeWindowType window, int width, int height);
sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height);
LibGLESv2exports::LibGLESv2exports()
{
......
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