gpu-gles: refactor for caanoo/wiz support
authornotaz <notasas@gmail.com>
Sat, 21 Jan 2012 21:22:30 +0000 (23:22 +0200)
committernotaz <notasas@gmail.com>
Sat, 21 Jan 2012 21:22:30 +0000 (23:22 +0200)
too bad it's unusable there.

Makefile.caanoo
frontend/plat_omap.c
frontend/plat_pollux.c
frontend/plugin_lib.h
plugins/gpu-gles/Makefile
plugins/gpu-gles/gpuDraw.c
plugins/gpu-gles/gpulib_if.c

index 5db03f3..a937f19 100644 (file)
@@ -1,7 +1,7 @@
 export ARM926=1
 export ARM_CORTEXA8=0
 # caanoo also covers Wiz
 export ARM926=1
 export ARM_CORTEXA8=0
 # caanoo also covers Wiz
-PLATFORM=caanoo
+export PLATFORM=caanoo
 
 PLAT_CLEAN = caanoo_clean
 
 
 PLAT_CLEAN = caanoo_clean
 
index 62f198b..998e1df 100644 (file)
@@ -177,6 +177,8 @@ void plat_init(void)
        g_menuscreen_w = w;
        g_menuscreen_h = h;
        g_menuscreen_ptr = vout_fbdev_flip(main_fb);
        g_menuscreen_w = w;
        g_menuscreen_h = h;
        g_menuscreen_ptr = vout_fbdev_flip(main_fb);
+       pl_rearmed_cbs.screen_w = w;
+       pl_rearmed_cbs.screen_h = h;
 
        w = 640;
        h = 512;
 
        w = 640;
        h = 512;
index 6247dc1..af12f1e 100644 (file)
@@ -610,6 +610,9 @@ void plat_init(void)
        psx_width = 320;
        psx_height = 240;
        psx_bpp = 16;
        psx_width = 320;
        psx_height = 240;
        psx_bpp = 16;
+
+       pl_rearmed_cbs.screen_w = 320;
+       pl_rearmed_cbs.screen_h = 240;
 }
 
 void plat_finish(void)
 }
 
 void plat_finish(void)
index e6d1f7d..e2f1d55 100644 (file)
@@ -53,6 +53,7 @@ struct rearmed_cbs {
        unsigned int *gpu_frame_count;
        unsigned int *gpu_hcnt;
        unsigned int flip_cnt; // increment manually if not using pl_vout_flip
        unsigned int *gpu_frame_count;
        unsigned int *gpu_hcnt;
        unsigned int flip_cnt; // increment manually if not using pl_vout_flip
+       unsigned int screen_w, screen_h; // gles plugin wants this
        struct {
                int   allow_interlace; // 0 off, 1 on, 2 guess
        } gpu_neon;
        struct {
                int   allow_interlace; // 0 off, 1 on, 2 guess
        } gpu_neon;
index 241fad0..06552ed 100644 (file)
@@ -8,7 +8,13 @@ SRC_STANDALONE += gpuDraw.c gpuFps.c gpuPlugin.c gpuPrim.c gpuTexture.c
 SRC_GPULIB += gpulib_if.c\r
 \r
 CFLAGS += -I$(PREFIX)include\r
 SRC_GPULIB += gpulib_if.c\r
 \r
 CFLAGS += -I$(PREFIX)include\r
-LDLIBS += -L$(PREFIX)lib -lGLES_CM\r
+LDLIBS += -L$(PREFIX)lib\r
+ifeq "$(PLATFORM)" "caanoo"\r
+CFLAGS += -DFAKE_WINDOW\r
+LDLIBS += -lopengles_lite -lstdc++\r
+else\r
+LDLIBS += -lGLES_CM\r
+endif\r
 \r
 BIN_STANDLALONE = gpuGLES.so\r
 BIN_GPULIB = gpu_gles.so\r
 \r
 BIN_STANDLALONE = gpuGLES.so\r
 BIN_GPULIB = gpu_gles.so\r
index d7d6761..ebb3bf0 100644 (file)
@@ -291,15 +291,17 @@ bool TestEGLError(const char* pszLocation)
        EGLint iErr = eglGetError();\r
        if (iErr != EGL_SUCCESS)\r
        {\r
        EGLint iErr = eglGetError();\r
        if (iErr != EGL_SUCCESS)\r
        {\r
-               printf("%s failed (%d).\n", pszLocation, iErr);\r
+               printf("%s failed (0x%x).\n", pszLocation, iErr);\r
                return FALSE;\r
        }\r
 \r
        return TRUE;\r
 }\r
 \r
                return FALSE;\r
        }\r
 \r
        return TRUE;\r
 }\r
 \r
-static void initEGL(void)\r
+static int initEGL(void)\r
 {\r
 {\r
+       NativeWindowType window = 0;\r
+\r
        printf ("GL init\n");\r
 \r
        EGLint numConfigs;\r
        printf ("GL init\n");\r
 \r
        EGLint numConfigs;\r
@@ -336,9 +338,10 @@ static void initEGL(void)
             if (!x11Display)\r
             {\r
                 printf("GLES Error: Unable to open X display\n");\r
             if (!x11Display)\r
             {\r
                 printf("GLES Error: Unable to open X display\n");\r
+                return -1;\r
             }\r
             x11Screen = XDefaultScreen( x11Display );\r
             }\r
             x11Screen = XDefaultScreen( x11Display );\r
-                               \r
+\r
             // Gets the display parameters so we can pass the same parameters to the window to be created.\r
             sRootWindow        = RootWindow(x11Display, x11Screen);\r
             i32Depth   = DefaultDepth(x11Display, x11Screen);\r
             // Gets the display parameters so we can pass the same parameters to the window to be created.\r
             sRootWindow        = RootWindow(x11Display, x11Screen);\r
             i32Depth   = DefaultDepth(x11Display, x11Screen);\r
@@ -347,7 +350,8 @@ static void initEGL(void)
             if (!px11Visual)\r
             {\r
                 printf("GLES Error: Unable to acquire visual\n");\r
             if (!px11Visual)\r
             {\r
                 printf("GLES Error: Unable to acquire visual\n");\r
-                       }\r
+                return -1;\r
+            }\r
             // Colormap of the specified visual type for the display.\r
             x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone );\r
             sWA.colormap = x11Colormap;\r
             // Colormap of the specified visual type for the display.\r
             x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone );\r
             sWA.colormap = x11Colormap;\r
@@ -357,7 +361,7 @@ static void initEGL(void)
 \r
             // Display capabilities list.\r
             ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;\r
 \r
             // Display capabilities list.\r
             ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;\r
-                                                          \r
+\r
             // Creates the X11 window\r
             x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY,\r
                                         0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);\r
             // Creates the X11 window\r
             x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY,\r
                                         0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);\r
@@ -385,6 +389,7 @@ static void initEGL(void)
             XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);\r
 \r
             display = eglGetDisplay( (EGLNativeDisplayType)x11Display );\r
             XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);\r
 \r
             display = eglGetDisplay( (EGLNativeDisplayType)x11Display );\r
+            window = x11Window;\r
 #else\r
             display = eglGetDisplay( (EGLNativeDisplayType)0 );\r
 #endif\r
 #else\r
             display = eglGetDisplay( (EGLNativeDisplayType)0 );\r
 #endif\r
@@ -392,40 +397,48 @@ static void initEGL(void)
        if( display == EGL_NO_DISPLAY )\r
        {\r
                printf( "GLES EGL Error: GL No Display\n" );\r
        if( display == EGL_NO_DISPLAY )\r
        {\r
                printf( "GLES EGL Error: GL No Display\n" );\r
+               return -1;\r
        }\r
 \r
        if( !eglInitialize( display, &majorVersion, &minorVersion ) )\r
        {\r
                printf( "GLES EGL Error: eglInitialize failed\n" );\r
        }\r
 \r
        if( !eglInitialize( display, &majorVersion, &minorVersion ) )\r
        {\r
                printf( "GLES EGL Error: eglInitialize failed\n" );\r
+               return -1;\r
        }\r
 \r
        if( !eglChooseConfig( display, attribList, &config, 1, &numConfigs ) )\r
        {\r
                printf( "GLES EGL Error: eglChooseConfig failed\n" );\r
        }\r
 \r
        if( !eglChooseConfig( display, attribList, &config, 1, &numConfigs ) )\r
        {\r
                printf( "GLES EGL Error: eglChooseConfig failed\n" );\r
+               return -1;\r
        }\r
 \r
        context = eglCreateContext( display, config, NULL, NULL );\r
        if( context==0 )\r
        {\r
                printf( "GLES EGL Error: eglCreateContext failed\n" );\r
        }\r
 \r
        context = eglCreateContext( display, config, NULL, NULL );\r
        if( context==0 )\r
        {\r
                printf( "GLES EGL Error: eglCreateContext failed\n" );\r
+               return -1;\r
        }\r
 \r
        }\r
 \r
-#if defined(USE_X11)\r
-            surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)x11Window, NULL );\r
-#else\r
-            surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)0, NULL );\r
+#ifdef FAKE_WINDOW\r
+       // broken Caanoo libs won't accept NULL window\r
+       window = (NativeWindowType)1;\r
 #endif\r
 #endif\r
+       surface = eglCreateWindowSurface( display, config, window, NULL );\r
+       if (!TestEGLError("eglCreateWindowSurface"))\r
+               return -1;\r
+\r
+       eglMakeCurrent( display, surface, surface, context );\r
+       if (!TestEGLError("eglMakeCurrent"))\r
+               return -1;\r
 \r
 \r
-    eglMakeCurrent( display, surface, surface, context );\r
-    if (!TestEGLError("eglMakeCurrent"))\r
-        printf("error eglMakeCurrent");\r
-    else\r
-        printf("GLES Window Opened\n");\r
+       printf("GLES init ok\n");\r
+       return 0;\r
 }\r
 \r
 int GLinitialize() \r
 {\r
 }\r
 \r
 int GLinitialize() \r
 {\r
- initEGL();\r
+ if(initEGL()!=0)\r
+  return -1;\r
 \r
  //----------------------------------------------------// \r
 \r
 \r
  //----------------------------------------------------// \r
 \r
index 569fff4..ce32aad 100644 (file)
@@ -626,11 +626,14 @@ void vout_update(void)
  }
 }
 
  }
 }
 
+static struct rearmed_cbs *cbs;
+
 long GPUopen(void **dpy)
 {
  int ret;
 
 long GPUopen(void **dpy)
 {
  int ret;
 
- iResX = 800; iResY = 480;
+ iResX = cbs->screen_w;
+ iResY = cbs->screen_h;
  rRatioRect.left   = rRatioRect.top=0;
  rRatioRect.right  = iResX;
  rRatioRect.bottom = iResY;
  rRatioRect.left   = rRatioRect.top=0;
  rRatioRect.right  = iResX;
  rRatioRect.bottom = iResY;
@@ -657,8 +660,6 @@ long GPUclose(void)
  return 0;
 }
 
  return 0;
 }
 
-static struct rearmed_cbs *cbs;
-
 /* acting as both renderer and vout handler here .. */
 void renderer_set_config(const struct rearmed_cbs *cbs_)
 {
 /* acting as both renderer and vout handler here .. */
 void renderer_set_config(const struct rearmed_cbs *cbs_)
 {