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