From: Adrián Arroyo Calle <adrian.arroyoca...@gmail.com> --- src/egl/drivers/dri2/egl_dri2.c | 7 ++ src/egl/drivers/dri2/platform_haiku.cpp | 172 +++++++++++++++++++++++++------ src/egl/main/SConscript | 14 ++- src/egl/main/egldisplay.c | 4 + 4 files changed, 160 insertions(+), 37 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 062fb54..5bda4fd 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -398,9 +398,16 @@ dri2_open_driver(_EGLDisplay *disp) "%.*s/tls/%s_dri.so", len, p, dri2_dpy->driver_name); dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); #endif + + if (dri2_dpy->driver == NULL) { +#ifndef HAVE_HAIKU_PLATFORM snprintf(path, sizeof path, "%.*s/%s_dri.so", len, p, dri2_dpy->driver_name); +#else + snprintf(path, sizeof path, + "lib%s.so",len,p,dri2_dpy->driver_name); +#endif dri2_dpy->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL); if (dri2_dpy->driver == NULL) _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror()); diff --git a/src/egl/drivers/dri2/platform_haiku.cpp b/src/egl/drivers/dri2/platform_haiku.cpp index ef85e27..22633ff 100644 --- a/src/egl/drivers/dri2/platform_haiku.cpp +++ b/src/egl/drivers/dri2/platform_haiku.cpp @@ -35,19 +35,57 @@ extern "C" { } #include <InterfaceKit.h> +static void +swrastCreateDrawable(struct dri2_egl_display * dri2_dpy, + struct dri2_egl_surface * dri2_surf, + int depth) +{ + +} + +static void +swrastDestroyDrawable(struct dri2_egl_display * dri2_dpy, + struct dri2_egl_surface * dri2_surf) +{ + +} + +static void +swrastGetDrawableInfo(__DRIdrawable * draw, + int *x, int *y, int *w, int *h, + void *loaderPrivate) +{ + +} + +static void +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + +} + +static void +swrastGetImage(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + +} static void haiku_log(EGLint level, const char *msg) { switch (level) { case _EGL_DEBUG: - printf("%s", msg); + fprintf(stderr,"%s", msg); break; case _EGL_INFO: - printf("%s", msg); + fprintf(stderr,"%s", msg); break; case _EGL_WARNING: - printf("%s", msg); + fprintf(stderr,"%s", msg); break; case _EGL_FATAL: fprintf(stderr,"%s", msg); @@ -57,23 +95,76 @@ haiku_log(EGLint level, const char *msg) } } -BWindow* -haiku_create_window() +/** + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + */ +static _EGLSurface * +dri2_haiku_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, + _EGLConfig *conf, void *native_surface, + const EGLint *attrib_list) +{ + + return NULL; +} + +/** + * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). + */ +static _EGLSurface * +dri2_haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, void *native_window, + const EGLint *attrib_list) +{ + return NULL; +} + +static _EGLSurface * +dri2_haiku_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, void *native_pixmap, + const EGLint *attrib_list) { - BWindow* win = new BWindow(BRect(100, 100, 500, 500), "EGL Test", - B_TITLED_WINDOW, 0); - return win; + return NULL; } +static _EGLSurface * +dri2_haiku_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, const EGLint *attrib_list) +{ + return NULL; +} + +static EGLBoolean +dri2_haiku_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +{ + return EGL_TRUE; +} static EGLBoolean dri2_haiku_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy, - _EGLDisplay *disp) + _EGLDisplay *dpy) { - if (!_eglGetArraySize(disp->Configs)) { + /*EGLint config_attrs[] = { + EGL_NATIVE_VISUAL_ID, 0, + EGL_NATIVE_VISUAL_TYPE, 0, + EGL_NONE + }; + static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 }; + dri2_add_config(dpy,dri2_dpy->driver_configs[0],1, + EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT | + EGL_SWAP_BEHAVIOR_PRESERVED_BIT,config_attrs,rgb_masks);*/ + struct dri2_egl_config *conf; + _EGLConfig base; + _eglInitConfig(&base, dpy, 1); + + if (!_eglValidateConfig(&base, EGL_FALSE)) { + _eglLog(_EGL_DEBUG, "DRI2: failed to validate config"); + return NULL; + } + _eglLinkConfig(&conf->base); + if (!_eglGetArraySize(dpy->Configs)) { _eglLog(_EGL_WARNING, "DRI2: failed to create any config"); return EGL_FALSE; } - + return EGL_TRUE; } @@ -81,14 +172,15 @@ extern "C" EGLBoolean dri2_initialize_haiku(_EGLDriver *drv, _EGLDisplay *dpy) { - struct dri2_egl_display_vtbl dri2_haiku_display_vtbl = {}; + printf("\nINITIALIZING HAIKU\n"); + struct dri2_egl_display_vtbl dri2_haiku_display_vtbl; struct dri2_egl_display *dri2_dpy; dri2_haiku_display_vtbl.authenticate = NULL; - dri2_haiku_display_vtbl.create_window_surface = NULL; - dri2_haiku_display_vtbl.create_pixmap_surface = NULL; - dri2_haiku_display_vtbl.create_pbuffer_surface = NULL; - dri2_haiku_display_vtbl.destroy_surface = NULL; + dri2_haiku_display_vtbl.create_window_surface = dri2_haiku_create_window_surface; + dri2_haiku_display_vtbl.create_pixmap_surface = dri2_haiku_create_pixmap_surface; + dri2_haiku_display_vtbl.create_pbuffer_surface = dri2_haiku_create_pbuffer_surface; + dri2_haiku_display_vtbl.destroy_surface = dri2_haiku_destroy_surface; dri2_haiku_display_vtbl.create_image = NULL; dri2_haiku_display_vtbl.swap_interval = dri2_fallback_swap_interval; dri2_haiku_display_vtbl.swap_buffers = NULL; @@ -99,47 +191,61 @@ dri2_initialize_haiku(_EGLDriver *drv, _EGLDisplay *dpy) dri2_haiku_display_vtbl.create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image; dri2_haiku_display_vtbl.get_sync_values = dri2_fallback_get_sync_values; - printf("INITIALIZING HAIKU"); + printf("INITIALIZING HAIKU\n"); _eglSetLogProc(haiku_log); loader_set_logger(_eglLog); - dri2_dpy = (struct dri2_egl_display*) calloc(1, sizeof(*dri2_dpy)); + dri2_dpy = (struct dri2_egl_display*) calloc(1, sizeof(struct dri2_egl_display)); if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - + dpy->DriverData=(void*) dri2_dpy; if (!dpy->PlatformDisplay) { - /* OPEN DEVICE */ - dri2_dpy->bwindow = (void*)haiku_create_window(); - dri2_dpy->own_device = true; + // OPEN DEVICE + //dri2_dpy->bwindow = (void*)haiku_create_window(); + //dri2_dpy->own_device = true; } else { - dri2_dpy->bwindow = (BWindow*)dpy->PlatformDisplay; + //dri2_dpy->bwindow = (BWindow*)dpy->PlatformDisplay; } - - dri2_dpy->driver_name = strdup("Haiku OpenGL"); - if (!dri2_load_driver_swrast(dpy)) - return EGL_FALSE; + + //dri2_dpy->driver_name = strdup("swrast"); + //if (!dri2_load_driver_swrast(dpy)) + // goto cleanup_conn; dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER; dri2_dpy->swrast_loader_extension.base.version = __DRI_SWRAST_LOADER_VERSION; - //dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo; - //dri2_dpy->swrast_loader_extension.putImage = swrastPutImage; - //dri2_dpy->swrast_loader_extension.getImage = swrastGetImage; + dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo; + dri2_dpy->swrast_loader_extension.putImage = swrastPutImage; + dri2_dpy->swrast_loader_extension.getImage = swrastGetImage; dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base; dri2_dpy->extensions[1] = NULL; dri2_dpy->extensions[2] = NULL; - if (dri2_dpy->bwindow) { + /*if (dri2_dpy->bwindow) { if (!dri2_haiku_add_configs_for_visuals(dri2_dpy, dpy)) - return EGL_FALSE; - } + goto cleanup_configs; + }*/ + dri2_haiku_add_configs_for_visuals(dri2_dpy,dpy); dpy->VersionMajor=1; dpy->VersionMinor=4; dri2_dpy->vtbl = &dri2_haiku_display_vtbl; + return EGL_TRUE; + + cleanup_configs: + _eglCleanupDisplay(dpy); + dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); + cleanup_driver: + dlclose(dri2_dpy->driver); + cleanup_conn: + free(dri2_dpy->driver_name); + cleanup_dpy: + free(dri2_dpy); + + return EGL_FALSE; } diff --git a/src/egl/main/SConscript b/src/egl/main/SConscript index a8725ca..9bf463b 100644 --- a/src/egl/main/SConscript +++ b/src/egl/main/SConscript @@ -19,10 +19,16 @@ if env['platform'] == 'windows': 'KHRONOS_DLL_EXPORTS', ]) else: - env.Append(CPPDEFINES = [ - '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11', - '_EGL_OS_UNIX', - ]) + if env['platform'] == 'haiku': + env.Append(CPPDEFINES = [ + '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_HAIKU', + '_EGL_OS_UNIX', + ]) + else: + env.Append(CPPDEFINES = [ + '_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11', + '_EGL_OS_UNIX', + ]) env.Append(CPPPATH = [ '#/include', diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 259ab6b..a167ae5 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -178,6 +178,10 @@ _eglNativePlatformDetectNativeDisplay(void *nativeDisplay) /* If not matched to any other platform, fallback to x11. */ return _EGL_PLATFORM_X11; #endif + +#ifdef HAVE_HAIKU_PLATFORM + return _EGL_PLATFORM_HAIKU; +#endif } return _EGL_INVALID_PLATFORM; -- 1.7.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev