From b06b71050a70354c69ac5fc86a1c23ba89b2305f Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 24 Jan 2010 05:11:54 +0000 Subject: [PATCH] ok. work on native pixmap suppport. have problmes - not sure why. see comments (create/destory glx pixmap needed for updates to work, but this makes rendering dead-slow. without it rendering is fast, but updates dont happen (useless). anyone know why glxcreatepixmap is needed as well as bindteximage+release (and destroy pixmap) vs just bind/unbind? SVN revision: 45508 --- .../engines/gl_common/evas_gl_common.h | 3 +- .../engines/gl_common/evas_gl_context.c | 14 +++-- .../modules/engines/gl_common/evas_gl_image.c | 2 +- .../engines/gl_common/evas_gl_texture.c | 15 +++-- .../src/modules/engines/gl_x11/evas_engine.c | 57 +++++++++++++++---- .../src/modules/engines/gl_x11/evas_x_main.c | 6 -- 6 files changed, 70 insertions(+), 27 deletions(-) diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h index d695cb8fb7..8ec2b2b78b 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_common.h @@ -199,6 +199,7 @@ struct _Evas_GL_Image void *data; } func; unsigned char yinvert : 1; + unsigned char loose : 1; } native; unsigned char dirty : 1; @@ -293,7 +294,7 @@ void evas_gl_common_shader_program_init(Evas_GL_Program *p, void evas_gl_common_rect_draw(Evas_GL_Context *gc, int x, int y, int w, int h); Evas_GL_Texture *evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im); -Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha); +Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha, Evas_GL_Image *im); Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha); void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im); void evas_gl_common_texture_free(Evas_GL_Texture *tex); diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c index f3091b58b1..65a6d5b8e8 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_context.c @@ -905,6 +905,8 @@ shader_array_flush(Evas_GL_Context *gc) if (gc->shader.cur_tex != gc->shader.current.cur_tex) { + if (gc->shader.cur_tex) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); } @@ -943,10 +945,8 @@ shader_array_flush(Evas_GL_Context *gc) } if (gc->shader.blend != gc->shader.current.blend) { - if (gc->shader.blend) - glEnable(GL_BLEND); - else - glDisable(GL_BLEND); + if (gc->shader.blend) glEnable(GL_BLEND); + else glDisable(GL_BLEND); } if (gc->shader.smooth != gc->shader.current.smooth) { @@ -1049,6 +1049,12 @@ shader_array_flush(Evas_GL_Context *gc) if (gc->array.im->native.func.unbind) gc->array.im->native.func.unbind(gc->array.im->native.func.data, gc->array.im); +/* + gc->shader.cur_tex = 0; + glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); + if (gc->shader.cur_tex) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); + */ } gc->shader.current.cur_prog = gc->shader.cur_prog; diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c index e21fb85e5d..1dd6da809f 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_image.c @@ -200,7 +200,7 @@ evas_gl_common_image_native_enable(Evas_GL_Image *im) } im->cs.space = EVAS_COLORSPACE_ARGB8888; - im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha); + im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha, im); im->tex_only = 1; } diff --git a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c index 7823b1caee..8e785c1237 100644 --- a/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c +++ b/legacy/evas/src/modules/engines/gl_common/evas_gl_texture.c @@ -306,7 +306,7 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma } static Evas_GL_Texture_Pool * -_pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int format) +_pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int format, Evas_GL_Image *im) { Evas_GL_Texture_Pool *pt; @@ -327,12 +327,19 @@ _pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma // is this really needed for gl-es? // glTexImage2D(GL_TEXTURE_2D, 0, intformat, w, h, 0, format, // GL_UNSIGNED_BYTE, 0); +#else + if (im->native.loose) + { + if (im->native.func.bind) + im->native.func.bind(im->native.func.data, im); + } #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex); return pt; } @@ -356,7 +363,7 @@ pt_unref(Evas_GL_Texture_Pool *pt) } Evas_GL_Texture * -evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha) +evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha, Evas_GL_Image *im) { Evas_GL_Texture *tex; Eina_List *l_after = NULL; @@ -369,9 +376,9 @@ evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha) tex->references = 1; tex->alpha = alpha; if (alpha) - tex->pt = _pool_tex_native_new(gc, w, h, rgba_ifmt, rgba_fmt); + tex->pt = _pool_tex_native_new(gc, w, h, rgba_ifmt, rgba_fmt, im); else - tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt); + tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt, im); if (!tex->pt) { free(tex); diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c index 0506f7a729..d9edd392f3 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c @@ -1024,6 +1024,15 @@ struct _Native #endif }; +// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW +// (i am sure this is the reason) not to mention seemingly superfluous. but +// i need to enable it for it to work on fglrx at least. havent tried nvidia. +// +// why is this the case? does anyone know? has anyone tried it on other gfx +// drivers? +// +//#define GLX_TEX_PIXMAP_RECREATE 1 + static void _native_bind_cb(void *data, void *image) { @@ -1040,6 +1049,7 @@ _native_bind_cb(void *data, void *image) # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT if (glsym_glXBindTexImage) { +#ifdef GLX_TEX_PIXMAP_RECREATE const int pixmap_att[] = { GLX_TEXTURE_TARGET_EXT, @@ -1051,8 +1061,10 @@ _native_bind_cb(void *data, void *image) n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc, n->pixmap, pixmap_att); - glsym_glXBindTexImage(re->win->disp, n->glx_pixmap, - GLX_FRONT_LEFT_EXT, NULL); +#endif + if (!im->native.loose) + glsym_glXBindTexImage(re->win->disp, n->glx_pixmap, + GLX_FRONT_LEFT_EXT, NULL); } # endif #endif @@ -1074,10 +1086,13 @@ _native_unbind_cb(void *data, void *image) # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT if (glsym_glXReleaseTexImage) { - glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap, - GLX_FRONT_LEFT_EXT); + if (!im->native.loose) + glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap, + GLX_FRONT_LEFT_EXT); +#ifdef GLX_TEX_PIXMAP_RECREATE glXDestroyPixmap(re->win->disp, n->glx_pixmap); n->glx_pixmap = 0; +#endif } # endif #endif @@ -1100,8 +1115,12 @@ _native_free_cb(void *data, void *image) # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT if (n->glx_pixmap) { - glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap, - GLX_FRONT_LEFT_EXT); + if (im->native.loose) + { + if (glsym_glXReleaseTexImage) + glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap, + GLX_FRONT_LEFT_EXT); + } glXDestroyPixmap(re->win->disp, n->glx_pixmap); n->glx_pixmap = 0; } @@ -1176,18 +1195,19 @@ eng_image_native_set(void *data, void *image, void *native) eglChooseConfig(re->win->egl_disp, config_attrs, &egl_config, 1, &num_config); - n->egl_surface = eglCreatePixmapSurface(re->win->egl_disp, - egl_config, pm, - NULL); - evas_gl_common_image_native_enable(im); n->pixmap = pm; n->visual = vis; im->native.yinvert = 1; + im->native.loose = 0; im->native.data = n; im->native.func.data = re; im->native.func.bind = _native_bind_cb; im->native.func.unbind = _native_unbind_cb; im->native.func.free = _native_free_cb; + n->egl_surface = eglCreatePixmapSurface(re->win->egl_disp, + egl_config, pm, + NULL); + evas_gl_common_image_native_enable(im); } } #else @@ -1254,18 +1274,33 @@ eng_image_native_set(void *data, void *image, void *native) n = calloc(1, sizeof(Native)); if (n) { - evas_gl_common_image_native_enable(im); +#ifndef GLX_TEX_PIXMAP_RECREATE + const int pixmap_att[] = + { + GLX_TEXTURE_TARGET_EXT, + GLX_TEXTURE_2D_EXT, + GLX_TEXTURE_FORMAT_EXT, + GLX_TEXTURE_FORMAT_RGBA_EXT, + 0 + }; +#endif memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); n->pixmap = pm; n->visual = vis; memcpy(&(n->fbc), fbc, sizeof(GLXFBConfig)); n->fbc = *fbc; im->native.yinvert = yinvert; + im->native.loose = 0; im->native.data = n; im->native.func.data = re; im->native.func.bind = _native_bind_cb; im->native.func.unbind = _native_unbind_cb; im->native.func.free = _native_free_cb; +#ifndef GLX_TEX_PIXMAP_RECREATE + n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc, + n->pixmap, pixmap_att); +#endif + evas_gl_common_image_native_enable(im); } } } diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_x_main.c b/legacy/evas/src/modules/engines/gl_x11/evas_x_main.c index 901cecfe6a..69fefffc20 100644 --- a/legacy/evas/src/modules/engines/gl_x11/evas_x_main.c +++ b/legacy/evas/src/modules/engines/gl_x11/evas_x_main.c @@ -133,15 +133,9 @@ eng_window_new(Display *disp, } // GLX #else - -#if 1 if (!context) context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE); gw->context = context; -#else - gw->context = glXCreateContext(disp, gw->visualinfo, context, GL_TRUE); - if (!context) context = gw->context; -#endif glXMakeCurrent(gw->disp, gw->win, gw->context); #endif