Commit 43989208 by Nicolas Capens Committed by Nicolas Capens

Implemented EGL_EXT_platform_base and EGL_KHR_platform_gbm.

BUG=18314459 Change-Id: I361dba91a2fec3d9c923c660e64b5cc25beeb72b Reviewed-on: https://swiftshader-review.googlesource.com/1421Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 1b4f08b8
...@@ -29,29 +29,43 @@ namespace egl ...@@ -29,29 +29,43 @@ namespace egl
typedef std::map<EGLNativeDisplayType, Display*> DisplayMap; typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
DisplayMap displays; DisplayMap displays;
egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) egl::Display *Display::getPlatformDisplay(EGLenum platform, EGLNativeDisplayType displayId)
{ {
if(displayId == EGL_DEFAULT_DISPLAY) if(platform == EGL_UNKNOWN) // Default
{ {
#if defined(__unix__) #if defined(__unix__)
displayId = XOpenDisplay(NULL); platform = EGL_PLATFORM_X11_EXT;
#endif #endif
} }
if(displayId == EGL_DEFAULT_DISPLAY)
{
if(platform == EGL_PLATFORM_X11_EXT)
{
#if defined(__unix__)
displayId = XOpenDisplay(NULL);
#else
return error(EGL_BAD_PARAMETER, (egl::Display*)EGL_NO_DISPLAY);
#endif
}
}
else
{
// FIXME: Check if displayId is a valid display device context for <platform>
}
if(displays.find(displayId) != displays.end()) if(displays.find(displayId) != displays.end())
{ {
return displays[displayId]; return displays[displayId];
} }
// FIXME: Check if displayId is a valid display device context egl::Display *display = new egl::Display(platform, displayId);
egl::Display *display = new egl::Display(displayId);
displays[displayId] = display; displays[displayId] = display;
return display; return display;
} }
Display::Display(EGLNativeDisplayType displayId) : displayId(displayId) Display::Display(EGLenum platform, EGLNativeDisplayType displayId) : platform(platform), displayId(displayId)
{ {
mMinSwapInterval = 1; mMinSwapInterval = 1;
mMaxSwapInterval = 1; mMaxSwapInterval = 1;
...@@ -449,14 +463,19 @@ bool Display::isValidSurface(egl::Surface *surface) ...@@ -449,14 +463,19 @@ bool Display::isValidSurface(egl::Surface *surface)
bool Display::isValidWindow(EGLNativeWindowType window) bool Display::isValidWindow(EGLNativeWindowType window)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return IsWindow(window) == TRUE; return IsWindow(window) == TRUE;
#else #else
XWindowAttributes windowAttributes; if(platform == EGL_PLATFORM_X11_EXT)
Status status = XGetWindowAttributes(displayId, window, &windowAttributes); {
XWindowAttributes windowAttributes;
return status == True; Status status = XGetWindowAttributes(displayId, window, &windowAttributes);
return status == True;
}
#endif #endif
return false;
} }
bool Display::hasExistingWindowSurface(EGLNativeWindowType window) bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
...@@ -509,19 +528,29 @@ DisplayMode Display::getDisplayMode() const ...@@ -509,19 +528,29 @@ DisplayMode Display::getDisplayMode() const
ReleaseDC(0, deviceContext); ReleaseDC(0, deviceContext);
#else #else
Screen *screen = XDefaultScreenOfDisplay(displayId); if(platform == EGL_PLATFORM_X11_EXT)
displayMode.width = XWidthOfScreen(screen); {
displayMode.height = XHeightOfScreen(screen); Screen *screen = XDefaultScreenOfDisplay(displayId);
unsigned int bpp = XPlanesOfScreen(screen); displayMode.width = XWidthOfScreen(screen);
displayMode.height = XHeightOfScreen(screen);
unsigned int bpp = XPlanesOfScreen(screen);
switch(bpp) switch(bpp)
{ {
case 32: displayMode.format = sw::FORMAT_X8R8G8B8; break; case 32: displayMode.format = sw::FORMAT_X8R8G8B8; break;
case 24: displayMode.format = sw::FORMAT_R8G8B8; break; case 24: displayMode.format = sw::FORMAT_R8G8B8; break;
case 16: displayMode.format = sw::FORMAT_R5G6B5; break; case 16: displayMode.format = sw::FORMAT_R5G6B5; break;
default: default:
ASSERT(false); // Unexpected display mode color depth ASSERT(false); // Unexpected display mode color depth
} }
}
else if(platform == EGL_PLATFORM_GBM_MESA)
{
displayMode.width = 0;
displayMode.height = 0;
displayMode.format = sw::FORMAT_X8R8G8B8;
}
else UNREACHABLE();
#endif #endif
return displayMode; return displayMode;
......
...@@ -30,7 +30,7 @@ namespace egl ...@@ -30,7 +30,7 @@ namespace egl
public: public:
~Display(); ~Display();
static egl::Display *getDisplay(EGLNativeDisplayType displayId); static egl::Display *getPlatformDisplay(EGLenum platform, EGLNativeDisplayType displayId);
bool initialize(); bool initialize();
void terminate(); void terminate();
...@@ -59,10 +59,11 @@ namespace egl ...@@ -59,10 +59,11 @@ namespace egl
const char *getExtensionString() const; const char *getExtensionString() const;
private: private:
Display(EGLNativeDisplayType displayId); Display(EGLenum platform, EGLNativeDisplayType displayId);
DisplayMode getDisplayMode() const; DisplayMode getDisplayMode() const;
const EGLenum platform;
const EGLNativeDisplayType displayId; const EGLNativeDisplayType displayId;
EGLint mMaxSwapInterval; EGLint mMaxSwapInterval;
......
...@@ -105,7 +105,7 @@ EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) ...@@ -105,7 +105,7 @@ EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id)
try try
{ {
return egl::Display::getDisplay(display_id); return egl::Display::getPlatformDisplay(EGL_UNKNOWN, display_id);
} }
catch(std::bad_alloc&) catch(std::bad_alloc&)
{ {
...@@ -180,7 +180,10 @@ const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) ...@@ -180,7 +180,10 @@ const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name)
{ {
if(dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) if(dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS)
{ {
return success("EGL_EXT_client_extensions"); return success("EGL_KHR_platform_gbm "
"EGL_KHR_platform_x11 "
"EGL_EXT_client_extensions "
"EGL_EXT_platform_base");
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -1191,6 +1194,32 @@ EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) ...@@ -1191,6 +1194,32 @@ EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
return EGL_FALSE; return EGL_FALSE;
} }
EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list)
{
TRACE("(EGLenum platform = 0x%X, void *native_display = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)", platform, native_display, attrib_list);
try
{
return egl::Display::getPlatformDisplay(platform, (EGLNativeDisplayType)native_display);
}
catch(std::bad_alloc&)
{
return error(EGL_BAD_ALLOC, EGL_NO_DISPLAY);
}
return EGL_NO_DISPLAY;
}
EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list)
{
return eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)native_window, attrib_list);
}
EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list)
{
return eglCreatePixmapSurface(dpy, config, (EGLNativePixmapType)native_pixmap, attrib_list);
}
__eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname) __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname)
{ {
TRACE("(const char *procname = \"%s\")", procname); TRACE("(const char *procname = \"%s\")", procname);
...@@ -1209,6 +1238,9 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const cha ...@@ -1209,6 +1238,9 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const cha
EXTENSION(eglCreateImageKHR), EXTENSION(eglCreateImageKHR),
EXTENSION(eglDestroyImageKHR), EXTENSION(eglDestroyImageKHR),
EXTENSION(eglGetPlatformDisplayEXT),
EXTENSION(eglCreatePlatformWindowSurfaceEXT),
EXTENSION(eglCreatePlatformPixmapSurfaceEXT),
#undef EXTENSION #undef EXTENSION
}; };
......
LIBRARY libEGL LIBRARY libEGL
EXPORTS EXPORTS
eglBindAPI @14 eglBindAPI @14
eglBindTexImage @20 eglBindTexImage @20
eglChooseConfig @7 eglChooseConfig @7
eglCopyBuffers @33 eglCopyBuffers @33
eglCreateContext @23 eglCreateContext @23
eglCreatePbufferFromClientBuffer @18 eglCreatePbufferFromClientBuffer @18
eglCreatePbufferSurface @10 eglCreatePbufferSurface @10
eglCreatePixmapSurface @11 eglCreatePixmapSurface @11
eglCreateWindowSurface @9 eglCreateWindowSurface @9
eglDestroyContext @24 eglDestroyContext @24
eglDestroySurface @12 eglDestroySurface @12
eglGetConfigAttrib @8 eglGetConfigAttrib @8
eglGetConfigs @6 eglGetConfigs @6
eglGetCurrentContext @26 eglGetCurrentContext @26
eglGetCurrentDisplay @28 eglGetCurrentDisplay @28
eglGetCurrentSurface @27 eglGetCurrentSurface @27
eglGetDisplay @2 eglGetDisplay @2
eglGetError @1 eglGetError @1
eglGetProcAddress @34 eglGetProcAddress @34
eglInitialize @3 eglInitialize @3
eglMakeCurrent @25 eglMakeCurrent @25
eglQueryAPI @15 eglQueryAPI @15
eglQueryContext @29 eglQueryContext @29
eglQueryString @5 eglQueryString @5
eglQuerySurface @13 eglQuerySurface @13
eglReleaseTexImage @21 eglReleaseTexImage @21
eglReleaseThread @17 eglReleaseThread @17
eglSurfaceAttrib @19 eglSurfaceAttrib @19
eglSwapBuffers @32 eglSwapBuffers @32
eglSwapInterval @22 eglSwapInterval @22
eglTerminate @4 eglTerminate @4
eglWaitClient @16 eglWaitClient @16
eglWaitGL @30 eglWaitGL @30
eglWaitNative @31 eglWaitNative @31
; Extensions ; Extensions
eglCreateImageKHR eglCreateImageKHR
eglDestroyImageKHR eglDestroyImageKHR
eglGetPlatformDisplayEXT
; Functions that don't change the error code, for use by client APIs eglCreatePlatformWindowSurfaceEXT
clientGetCurrentContext eglCreatePlatformPixmapSurfaceEXT
; Functions that don't change the error code, for use by client APIs
clientGetCurrentContext
clientGetCurrentDisplay clientGetCurrentDisplay
\ No newline at end of file
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