Commit c78445cd by Nicolas Capens Committed by Nicolas Capens

Eliminate the createDevice() dependency.

BUG=18110152 Change-Id: I70182caebeb645d89c222782354ee8a48272893f Reviewed-on: https://swiftshader-review.googlesource.com/1264Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent b387caa6
......@@ -16,7 +16,6 @@
#include "Display.h"
#include "main.h"
#include "libGLESv2/Device.hpp"
#include "libEGL/Surface.h"
#include "libEGL/Context.hpp"
#include "common/debug.h"
......@@ -56,8 +55,6 @@ egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
Display::Display(EGLNativeDisplayType displayId) : displayId(displayId)
{
mDevice = NULL;
mMinSwapInterval = 1;
mMaxSwapInterval = 1;
}
......@@ -180,9 +177,6 @@ void Display::terminate()
{
destroyContext(*mContextSet.begin());
}
delete mDevice;
mDevice = NULL;
}
bool Display::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig)
......@@ -236,21 +230,6 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
return true;
}
bool Display::createDevice()
{
mDevice = gl::createDevice();
if(!mDevice)
{
return error(EGL_BAD_ALLOC, false);
}
// Permanent non-default states
mDevice->setPointSpriteEnable(true);
return true;
}
EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList)
{
const Config *configuration = mConfigSet.get(config);
......@@ -406,14 +385,6 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, const EGLint *attri
EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *shareContext)
{
if(!mDevice)
{
if(!createDevice())
{
return NULL;
}
}
const egl::Config *config = mConfigSet.get(configHandle);
egl::Context *context = gl::createContext(config, shareContext);
......@@ -489,19 +460,6 @@ EGLint Display::getMaxSwapInterval()
return mMaxSwapInterval;
}
gl::Device *Display::getDevice()
{
if(!mDevice)
{
if(!createDevice())
{
return NULL;
}
}
return mDevice;
}
EGLNativeDisplayType Display::getNativeDisplay() const
{
return displayId;
......
......@@ -20,11 +20,6 @@
#include <set>
namespace gl
{
class Device;
}
namespace egl
{
class Surface;
......@@ -60,8 +55,6 @@ namespace egl
EGLint getMinSwapInterval();
EGLint getMaxSwapInterval();
virtual gl::Device *getDevice();
EGLNativeDisplayType getNativeDisplay() const;
const char *getExtensionString() const;
......@@ -71,7 +64,6 @@ namespace egl
DisplayMode getDisplayMode() const;
const EGLNativeDisplayType displayId;
gl::Device *mDevice;
EGLint mMaxSwapInterval;
EGLint mMinSwapInterval;
......@@ -83,8 +75,6 @@ namespace egl
typedef std::set<Context*> ContextSet;
ContextSet mContextSet;
bool createDevice();
};
}
......
......@@ -89,7 +89,6 @@ CONSTRUCTOR static bool eglAttachProcess()
#endif
libGLESv2 = loadLibrary(libGLESv2_lib);
gl::createDevice = (gl::Device*(*)())getProcAddress(libGLESv2, "createDevice");
gl::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*))getProcAddress(libGLESv2, "glCreateContext");
gl::makeCurrent = (void (*)(egl::Context*, egl::Display*, egl::Surface*))getProcAddress(libGLESv2, "glMakeCurrent");
gl::getProcAddress = (__eglMustCastToProperFunctionPointerType (*)(const char*))getProcAddress(libGLESv2, "glGetProcAddress");
......@@ -261,11 +260,8 @@ void error(EGLint errorCode)
namespace gl
{
Device *(*createDevice)() = 0;
egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext) = 0;
void (*bindTexImage)(egl::Surface *surface) = 0;
void (*makeCurrent)(egl::Context *context, egl::Display *display, egl::Surface *surface) = 0;
egl::Context *(*getCurrentContext)() = 0;
__eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname) = 0;
Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0;
Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) = 0;
......
......@@ -84,10 +84,8 @@ namespace sw
// libGLESv2 dependencies
namespace gl
{
class Device;
class Image;
extern Device *(*createDevice)();
extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext);
extern void (*makeCurrent)(egl::Context *context, egl::Display *display, egl::Surface *surface);
extern __eglMustCastToProperFunctionPointerType (*getProcAddress)(const char *procname);
......
......@@ -36,6 +36,8 @@
namespace gl
{
Device *Context::device = 0;
Context::Context(const egl::Config *config, const Context *shareContext) : mConfig(config)
{
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
......@@ -2307,6 +2309,17 @@ Image *Context::createSharedImage(EGLenum target, GLuint name, GLuint textureLev
return 0;
}
Device *Context::getDevice()
{
if(!device)
{
sw::Context *context = new sw::Context();
device = new gl::Device(context);
}
return device;
}
}
// Exported functions for use by EGL
......
......@@ -42,6 +42,7 @@ namespace gl
struct TranslatedAttribute;
struct TranslatedIndexData;
class Device;
class Buffer;
class Texture;
class Texture2D;
......@@ -371,6 +372,8 @@ public:
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
virtual Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
Device *getDevice();
private:
virtual ~Context();
......@@ -424,6 +427,8 @@ private:
bool mDitherStateDirty;
ResourceManager *mResourceManager;
static Device *device;
};
}
......
......@@ -89,6 +89,7 @@ namespace gl
setSourceBlendFactorAlpha(BLEND_ONE);
setDestBlendFactorAlpha(BLEND_ZERO);
setBlendOperationAlpha(BLENDOP_ADD);
setPointSpriteEnable(true);
for(int i = 0; i < 16; i++)
{
......@@ -668,19 +669,3 @@ namespace gl
synchronize();
}
}
// Exported functions for use by EGL
extern "C"
{
gl::Device *createDevice()
{
sw::Context *context = new sw::Context();
if(context)
{
return new gl::Device(context);
}
return 0;
}
}
\ No newline at end of file
......@@ -152,7 +152,6 @@ EXPORTS
createFrameBuffer @172
createBackBuffer @173
createDevice @174
createDepthStencil @175
Register
\ No newline at end of file
......@@ -148,9 +148,9 @@ egl::Display *getDisplay()
Device *getDevice()
{
egl::Display *display = getDisplay();
Context *context = getContext();
return display->getDevice();
return context ? context->getDevice() : 0;
}
}
......
......@@ -39,6 +39,8 @@
namespace gl
{
Device *Context::device = 0;
Context::Context(const egl::Config *config, const Context *shareContext) : mConfig(config)
{
mFenceHandleAllocator.setBaseHandle(0);
......@@ -3144,6 +3146,17 @@ Image *Context::createSharedImage(EGLenum target, GLuint name, GLuint textureLev
return 0;
}
Device *Context::getDevice()
{
if(!device)
{
sw::Context *context = new sw::Context();
device = new gl::Device(context);
}
return device;
}
}
// Exported functions for use by EGL
......
......@@ -43,6 +43,7 @@ namespace gl
struct TranslatedAttribute;
struct TranslatedIndexData;
class Device;
class Buffer;
class Shader;
class Program;
......@@ -423,6 +424,8 @@ public:
virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
virtual gl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
Device *getDevice();
private:
virtual ~Context();
......@@ -489,6 +492,8 @@ private:
bool mDitherStateDirty;
ResourceManager *mResourceManager;
static Device *device;
};
}
......
......@@ -89,6 +89,7 @@ namespace gl
setSourceBlendFactorAlpha(BLEND_ONE);
setDestBlendFactorAlpha(BLEND_ZERO);
setBlendOperationAlpha(BLENDOP_ADD);
setPointSpriteEnable(true);
for(int i = 0; i < 16; i++)
{
......@@ -783,19 +784,3 @@ namespace gl
synchronize();
}
}
// Exported functions for use by EGL
extern "C"
{
gl::Device *createDevice()
{
sw::Context *context = new sw::Context();
if(context)
{
return new gl::Device(context);
}
return 0;
}
}
\ No newline at end of file
......@@ -175,7 +175,6 @@ EXPORTS
createFrameBuffer @172
createBackBuffer @173
createDevice @174
createDepthStencil @175
Register
\ No newline at end of file
......@@ -148,9 +148,9 @@ egl::Display *getDisplay()
Device *getDevice()
{
egl::Display *display = getDisplay();
Context *context = getContext();
return display->getDevice();
return context ? context->getDevice() : 0;
}
}
......
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