This prevents having to access the current display though TLS.
Change-Id: Ic93d0f88096a7e7e50318dbafb9b32da5fbc50a2
Reviewed-on: https://swiftshader-review.googlesource.com/5511
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Meng-Lin Wu <marleymoo@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
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;
protected:
virtual ~Context() {};
+
+ egl::Display *const display;
};
}
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)
{
if(libGLESv2)
{
- context = libGLESv2->es2CreateContext(config, shareContext, clientVersion);
+ context = libGLESv2->es2CreateContext(this, config, shareContext, clientVersion);
}
}
else
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)
}
-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));
}
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;
namespace egl
{
+class Display;
class Context;
class Image;
class Config;
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
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"
{
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);
}
-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);
}
MAX_ELEMENTS_VERTICES = 0x7FFFFFFF,
MAX_VERTEX_OUTPUT_VECTORS = 16,
MAX_FRAGMENT_INPUT_VECTORS = 15,
- MIN_PROGRAM_TEXEL_OFFSET = sw::MIN_PROGRAM_TEXEL_OFFSET,\r
+ 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),
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;
namespace egl
{
+class Display;
class Context;
class Image;
class Config;
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
}
}
-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()
{