* commit '737facef2204df476f2d27023d26119479d0a066': EGL translator: fixes shared context on windows
This commit is contained in:
@@ -23,7 +23,8 @@ EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) :
|
|||||||
m_initialized(false),
|
m_initialized(false),
|
||||||
m_configInitialized(false),
|
m_configInitialized(false),
|
||||||
m_isDefault(isDefault),
|
m_isDefault(isDefault),
|
||||||
m_nextEglImageId(0)
|
m_nextEglImageId(0),
|
||||||
|
m_globalSharedContext(NULL)
|
||||||
{
|
{
|
||||||
m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace);
|
m_manager[GLES_1_1] = new ObjectNameManager(&m_globalNameSpace);
|
||||||
m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace);
|
m_manager[GLES_2_0] = new ObjectNameManager(&m_globalNameSpace);
|
||||||
@@ -31,6 +32,15 @@ EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault) :
|
|||||||
|
|
||||||
EglDisplay::~EglDisplay() {
|
EglDisplay::~EglDisplay() {
|
||||||
android::Mutex::Autolock mutex(m_lock);
|
android::Mutex::Autolock mutex(m_lock);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Destroy the global context if one was created.
|
||||||
|
// (should be true for windows platform only)
|
||||||
|
//
|
||||||
|
if (m_globalSharedContext != NULL) {
|
||||||
|
EglOS::destroyContext( m_dpy, m_globalSharedContext);
|
||||||
|
}
|
||||||
|
|
||||||
if(m_isDefault) {
|
if(m_isDefault) {
|
||||||
EglOS::releaseDisplay(m_dpy);
|
EglOS::releaseDisplay(m_dpy);
|
||||||
}
|
}
|
||||||
@@ -264,7 +274,6 @@ EGLContext EglDisplay::addContext(ContextPtr ctx ) {
|
|||||||
if(m_contexts.find(hndl) != m_contexts.end()) {
|
if(m_contexts.find(hndl) != m_contexts.end()) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_contexts[hndl] = ctx;
|
m_contexts[hndl] = ctx;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -294,3 +303,28 @@ bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLNativeContextType EglDisplay::getGlobalSharedContext(){
|
||||||
|
android::Mutex::Autolock mutex(m_lock);
|
||||||
|
#ifndef _WIN32
|
||||||
|
return (EGLNativeContextType)m_manager[GLES_1_1]->getGlobalContext();
|
||||||
|
#else
|
||||||
|
if (!m_globalSharedContext) {
|
||||||
|
//
|
||||||
|
// On windows we create a dummy context to serve as the
|
||||||
|
// "global context" which all contexts share with.
|
||||||
|
// This is because on windows it is not possible to share
|
||||||
|
// with a context which is already current. This dummy context
|
||||||
|
// will never be current to any thread so it is safe to share with.
|
||||||
|
// Create that context using the first config
|
||||||
|
if (m_configs.size() < 1) {
|
||||||
|
// Should not happen! config list should be initialized at this point
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
EglConfig *cfg = (*m_configs.begin());
|
||||||
|
m_globalSharedContext = EglOS::createContext(m_dpy,cfg,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_globalSharedContext;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
ImagePtr getImage(EGLImageKHR img);
|
ImagePtr getImage(EGLImageKHR img);
|
||||||
EGLImageKHR addImageKHR(ImagePtr);
|
EGLImageKHR addImageKHR(ImagePtr);
|
||||||
bool destroyImageKHR(EGLImageKHR img);
|
bool destroyImageKHR(EGLImageKHR img);
|
||||||
|
EGLNativeContextType getGlobalSharedContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size);
|
int doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size);
|
||||||
@@ -81,8 +82,9 @@ private:
|
|||||||
GlobalNameSpace m_globalNameSpace;
|
GlobalNameSpace m_globalNameSpace;
|
||||||
ObjectNameManager *m_manager[MAX_GLES_VERSION];
|
ObjectNameManager *m_manager[MAX_GLES_VERSION];
|
||||||
android::Mutex m_lock;
|
android::Mutex m_lock;
|
||||||
ImagesHndlMap m_eglImages;
|
ImagesHndlMap m_eglImages;
|
||||||
unsigned int m_nextEglImageId;
|
unsigned int m_nextEglImageId;
|
||||||
|
EGLNativeContextType m_globalSharedContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -641,7 +641,9 @@ EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig con
|
|||||||
nativeShared = sharedCtxPtr->nativeType();
|
nativeShared = sharedCtxPtr->nativeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,static_cast<EGLNativeContextType>(dpy->getManager(version)->getGlobalContext()));
|
EGLNativeContextType globalSharedContext = dpy->getGlobalSharedContext();
|
||||||
|
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,globalSharedContext);
|
||||||
|
|
||||||
if(nativeContext) {
|
if(nativeContext) {
|
||||||
ContextPtr ctx(new EglContext(nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
|
ContextPtr ctx(new EglContext(nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
|
||||||
return dpy->addContext(ctx);
|
return dpy->addContext(ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user