working on new gl engine feature. inactive right now.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 12 Aug 2010 06:02:15 +0000 (06:02 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 12 Aug 2010 06:02:15 +0000 (06:02 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@51027 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_image.c
src/modules/engines/gl_common/evas_gl_common.h
src/modules/engines/gl_common/evas_gl_context.c
src/modules/engines/gl_x11/evas_x_main.c

index b687a36..0743aa6 100644 (file)
@@ -1936,6 +1936,7 @@ evas_object_image_scale_hint_set(Evas_Object *obj, Evas_Image_Scale_Hint hint)
    MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
    return;
    MAGIC_CHECK_END();
+   if (o->scale_hint == hint) return;
 #ifdef EVAS_FRAME_QUEUING
    if (o->scale_hint != hint)
      {
@@ -1990,6 +1991,14 @@ evas_object_image_content_hint_set(Evas_Object *obj, Evas_Image_Content_Hint hin
    MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
    return;
    MAGIC_CHECK_END();
+   if (o->content_hint == hint) return;
+#ifdef EVAS_FRAME_QUEUING
+   if (o->content_hint != hint)
+     {
+        if (o->engine_data)
+          evas_common_pipe_op_image_flush(o->engine_data);
+     }
+#endif   
    o->content_hint = hint;
 }
 
index 4026cb8..fa77dd7 100644 (file)
 #endif
 
 #ifndef GL_TEXTURE_RECTANGLE_NV
-#define GL_TEXTURE_RECTANGLE_NV 0x84F5
+# define GL_TEXTURE_RECTANGLE_NV 0x84F5
 #endif
 #ifndef GL_BGRA
-#define GL_BGRA 0x80E1
+# define GL_BGRA 0x80E1
+#endif
+
+#ifndef EGL_MAP_GL_TEXTURE_2D_SEC
+# define EGL_MAP_GL_TEXTURE_2D_SEC 0x3201
+#endif
+#ifndef  EGL_MAP_GL_TEXTURE_HEIGHT_SEC
+# define EGL_MAP_GL_TEXTURE_HEIGHT_SEC 0x3202
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_WIDTH_SEC
+# define EGL_MAP_GL_TEXTURE_WIDTH_SEC 0x3203
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_FORMAT_SEC
+# define EGL_MAP_GL_TEXTURE_FORMAT_SEC 0x3204
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_RGB_SEC
+# define EGL_MAP_GL_TEXTURE_RGB_SEC 0x3205
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_RGBA_SEC
+# define EGL_MAP_GL_TEXTURE_RGBA_SEC 0x3206
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC
+# define EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC 0x3206
+#endif
+#ifndef EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC
+# define EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC 0x3207
+#endif
+#ifdef EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC
+# define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC 0x3208
 #endif
 
 #define SHAD_VERTEX 0
@@ -98,6 +126,7 @@ struct _Evas_GL_Shared
       Eina_Bool bgra : 1;
       Eina_Bool tex_npo2 : 1;
       Eina_Bool tex_rect : 1;
+      Eina_Bool sec_image_map : 1;
       // tuning params - per gpu/cpu combo?
       int cutout_max;
       int pipes_max;
@@ -399,6 +428,15 @@ void (*glsym_glBindFramebuffer)      (GLenum a, GLuint b);
 void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e);
 void (*glsym_glDeleteFramebuffers)   (GLsizei a, const GLuint *b);
 
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+void *(*secsym_eglCreateImage)               (void *a, void *b, GLenum c, void *d, const int *e);
+void  (*secsym_eglDestroyImage)              (void *a, void *b);
+void  (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b);
+void  (*secsym_eglMapImageSEC)               (void *a, void *b);
+void  (*secsym_eglUnmapImageSEC)             (void *a, void *b);
+void  (*secsym_eglGetImageAttribSEC)         (void *a, void *b, int c, int *d);
+#endif
+
 #define GL_ERRORS 1
 
 #ifdef GL_ERRORS
index 51c3e9b..110b8ba 100644 (file)
@@ -9,6 +9,19 @@ void (*glsym_glBindFramebuffer)      (GLenum a, GLuint b) = NULL;
 void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e) = NULL;
 void (*glsym_glDeleteFramebuffers)   (GLsizei a, const GLuint *b) = NULL;
 
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+// just used for finding symbols :)
+typedef void (*_eng_fn) (void);
+static _eng_fn  (*secsym_eglGetProcAddress)          (const char *a) = NULL;
+
+void *(*secsym_eglCreateImage)               (void *a, void *b, GLenum c, void *d, const int *e) = NULL;
+void  (*secsym_eglDestroyImage)              (void *a, void *b) = NULL;
+void  (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
+void  (*secsym_eglMapImageSEC)               (void *a, void *b) = NULL;
+void  (*secsym_eglUnmapImageSEC)             (void *a, void *b) = NULL;
+void  (*secsym_eglGetImageAttribSEC)         (void *a, void *b, int c, int *d) = NULL;
+#endif
+
 static void
 sym_missing(void)
 {
@@ -47,6 +60,44 @@ gl_symbols(void)
    FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersEXT");
    FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersARB");
    FALLBAK(glsym_glDeleteFramebuffers);
+
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+#undef FINDSYM
+#define FINDSYM(dst, sym) \
+   if ((!dst) && (secsym_eglGetProcAddress)) dst = secsym_eglGetProcAddress(sym); \
+   if (!dst) dst = dlsym(RTLD_DEFAULT, sym)
+// yes - gl core looking for egl stuff. i know it's odd. a reverse-layer thing
+// but it will work as the egl/glx layer calls gl core common stuff and thus
+// these symbols will work. making the glx/egl + x11 layer do this kind-of is
+// wrong as this is not x11 (output) layer specific like the native surface
+// stuff. this is generic zero-copy textures for gl
+
+   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddress");
+   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressEXT");
+   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressARB");
+   FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressKHR");
+   
+   FINDSYM(secsym_eglCreateImage, "eglCreateImage");
+   FINDSYM(secsym_eglCreateImage, "eglCreateImageEXT");
+   FINDSYM(secsym_eglCreateImage, "eglCreateImageARB");
+   FINDSYM(secsym_eglCreateImage, "eglCreateImageKHR");
+   
+   FINDSYM(secsym_eglDestroyImage, "eglDestroyImage");
+   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageEXT");
+   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageARB");
+   FINDSYM(secsym_eglDestroyImage, "eglDestroyImageKHR");
+   
+   FINDSYM(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES");
+   
+   FINDSYM(secsym_eglMapImageSEC, "eglMapImageSEC");
+//   FALLBAK(secsym_eglMapImageSEC);
+   
+   FINDSYM(secsym_eglUnmapImageSEC, "eglUnmapImageSEC");
+//   FALLBAK(secsym_eglUnmapImageSEC);
+   
+   FINDSYM(secsym_eglGetImageAttribSEC, "eglGetImageAttribSEC");
+//   FALLBAK(secsym_eglGetImageAttribSEC);
+#endif   
 }
 
 static void shader_array_flush(Evas_GL_Context *gc);
@@ -354,6 +405,7 @@ Evas_GL_Context *
 evas_gl_common_context_new(void)
 {
    Evas_GL_Context *gc;
+   const char *s;
    int i;
 
 #if 1
@@ -388,24 +440,43 @@ evas_gl_common_context_new(void)
         if (ext)
           {
              fprintf(stderr, "EXT:\n%s\n", ext);
-             if ((strstr((char*) ext, "GL_ARB_texture_non_power_of_two")) ||
-                 (strstr((char*) ext, "OES_texture_npot")) ||
-                 (strstr((char*) ext, "GL_IMG_texture_npot")))
+             if ((strstr((char *)ext, "GL_ARB_texture_non_power_of_two")) ||
+                 (strstr((char *)ext, "OES_texture_npot")) ||
+                 (strstr((char *)ext, "GL_IMG_texture_npot")))
                shared->info.tex_npo2 = 1;
-             if ((strstr((char*) ext, "GL_NV_texture_rectangle")) ||
-                 (strstr((char*) ext, "GL_EXT_texture_rectangle")) ||
-                 (strstr((char*) ext, "GL_ARB_texture_rectangle")))
+             if ((strstr((char *)ext, "GL_NV_texture_rectangle")) ||
+                 (strstr((char *)ext, "GL_EXT_texture_rectangle")) ||
+                 (strstr((char *)ext, "GL_ARB_texture_rectangle")))
                shared->info.tex_rect = 1;
 #ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
-             if ((strstr((char*) ext, "GL_EXT_texture_filter_anisotropic")))
+             if ((strstr((char *)ext, "GL_EXT_texture_filter_anisotropic")))
                glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, 
                            &(shared->info.anisotropic));
 #endif
 #ifdef GL_BGRA
-             if ((strstr((char*) ext, "GL_EXT_bgra")) ||
-                 (strstr((char*) ext, "GL_EXT_texture_format_BGRA8888")))
+             if ((strstr((char *)ext, "GL_EXT_bgra")) ||
+                 (strstr((char *)ext, "GL_EXT_texture_format_BGRA8888")))
                shared->info.bgra = 1;
 #endif
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+             // FIXME: there should be an extension name/string to check for
+             // not just symbols in the lib
+             i = 0;
+             if (getenv("EVAS_GL_NO_MAP_IMAGE_SEC"))
+                i = atoi(getenv("EVAS_GL_NO_MAP_IMAGE_SEC"));
+             if (!i)
+               {
+                  // test for all needed symbols - be "conservative" and
+                  // need all of it
+                  if ((secsym_eglCreateImage) &&
+                      (secsym_eglDestroyImage) &&
+                      (secsym_glEGLImageTargetTexture2DOES) &&
+                      (secsym_eglMapImageSEC) &&
+                      (secsym_eglUnmapImageSEC) &&
+                      (secsym_eglGetImageAttribSEC))
+                     shared->info.sec_image_map = 1;
+               }
+#endif             
           }
         glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
                       &(shared->info.max_texture_units));
@@ -417,6 +488,16 @@ evas_gl_common_context_new(void)
         shared->info.cutout_max = 512;
         shared->info.pipes_max = 32;
         
+        // per gpu hacks. based on impirical measurement of some known gpu's
+        s = glGetString(GL_RENDERER);
+        if (s)
+          {
+             if      (strstr(s, "PowerVR SGX 540"))
+                shared->info.pipes_max = 32;
+             else if (strstr(s, "NVIDIA Tegra"))
+                shared->info.pipes_max = 1;
+          }
+        
         if (getenv("EVAS_GL_CUTOUT_MAX"))
            shared->info.cutout_max = atoi(getenv("EVAS_GL_CUTOUT_MAX"));
         if (getenv("EVAS_GL_PIPES_MAX"))
@@ -428,26 +509,28 @@ evas_gl_common_context_new(void)
                 shared->info.pipes_max = 1;
           }
         
-        
-        fprintf(stderr, "max tex size %ix%i\n"
+        fprintf(stderr,
+                "max tex size %ix%i\n"
                 "max units %i\n"
                 "non-power-2 tex %i\n"
                 "rect tex %i\n"
                 "bgra : %i\n"
                 "max ansiotropic filtering: %3.3f\n"
+                "egl sec map image: %i\n"
                 "\n"
                 "cutout max: %i\n"
                 "pipes max: %i\n"
                 , 
-                shared->info.max_texture_size, shared->info.max_texture_size,
-                shared->info.max_texture_units,
+                (int)shared->info.max_texture_size, (int)shared->info.max_texture_size,
+                (int)shared->info.max_texture_units,
                 (int)shared->info.tex_npo2,
                 (int)shared->info.tex_rect,
                 (int)shared->info.bgra,
                 (double)shared->info.anisotropic,
+                (int)shared->info.sec_image_map,
                 
-                shared->info.cutout_max,
-                shared->info.pipes_max
+                (int)shared->info.cutout_max,
+                (int)shared->info.pipes_max
                 );
         
         glDisable(GL_DEPTH_TEST);
index c113890..ff6d4d8 100644 (file)
@@ -289,6 +289,17 @@ eng_window_new(Display *disp,
         fprintf(stderr, "version: %s\n", version);
         
         if (strstr(vendor, "NVIDIA"))
+           // FIXME: also same as tegra2 - maybe check renderer too
+           // 
+           // vendor: NVIDIA Corporation
+           // renderer: NVIDIA Tegra
+           // version: OpenGL ES 2.0
+           // 
+           // vs (for example)
+           // 
+           // vendor: NVIDIA Corporation
+           // renderer: GeForce GT 220/PCI/SSE2
+           // version: 3.2.0 NVIDIA 195.36.24
           {
              gw->detected.loose_binding = 1;
           }