addition to evas gl backend.
Working on different mobile devices, we've noticed that the cost of context
switch (MakeCurrent) in GL can be very expensive depending on the driver
implementation. To minimize the poorly written driver's context switch
overhead, I've implemented a state tracking layer on top of the driver
implemented GL.
Essentially, this layer wraps all the GL/Glue(GLX/EGL) APIs and manages its own
state changes. Internally, only one real GL context is created and logical
contexts are created every time a user requests context creation. The logical
contexts keep track of its states and sets only the necessary states
(the ones that are different than the current ones)
when there is a MakeCurrent request. The real MakeCurrent gets called when
there is a Surface/Window change request.
The GL library is dlopened and all the APIs are dlsym'ed and wrapped
accordingly. All the GL functions are in evas_gl_core.{h,c}.
Here's a very simply flow of the code.
- all the APIs are exported as function pointers (*glsym_glBegin),
(*glsm_eglCreatContext), and etc.
- all the native GL/Glue(GLX/EGL) APIs are dlsym'ed as _sym_glBegin,
_sym_eglCreateContext, and etc.
- all the fastpath APIs are implmemnted as fpgl_glBegin,
fpgl_eglCreateContext, and etc.
- if faspath is seletected, the exported APIs are set accordingly
ie. glsym_glBegin = fpgl_glBegin;
- default mode is the regular gl symbols are directly set.
ie. glsym_glBegin = _sym_glBegin;
I have an Environment variable where you can set it to three different Modes
EVAS_GL_FASTPATH = 0 // Default mode. Regular GL symbols are directly loaded
EVAS_GL_FASTPATH = 1 // Fastpath mode. Takes the path described above.
EVAS_GL_FASTPATH = 2 // Wrapped mode. All the regular GL functions are
wrapped once. This can be used for various
purposes
Since all the GL symbols are now loaded in this library, I took out all
the gl symbol loading parts in the evas gl backend as you'll see in the patch.
The changes to the engine and the backend itself is pretty minor.
There are still some known issues to hammer out but I thought we're at a good
place for an initial version so that my source doesn't diverge too much.
Known Issues and To Do's
* Current GL Fastpath version doesn't support multiple threads. Instead of
having one global real context, I would need to do it for each thread. I'll
get on this soon.
* Issues running Evas GL on certain conditions. When running the elementary
test (with gl engine), if you run ELMGLview test that runs in ON_DEMAND mode,
everything works fine. BUT, when you run the ELMGLView test in ALWAYS
mode, the subsequent elm tests shows blank screen. When you destroy the
GLView window, everything else comes on fine.
* Resource protection code. This actually applies to Evas GL code in general
as well. Since all the resources are shared among all the contexts that get
created, I would like to eventually have a resource protecting mechanism that
prevents access to resources outside of its context unless specifically
specified.
I'm attaching three files
- evas_gl_core.h, evas_gl_core.c, fastpath.patch
To get the code running...
- copy evas_gl_core.{c,h} to src/modules/engine/gl_common/
- apply the fastpath.patch
- compile/install evas
- to run with fastpath GL (ie. % EVAS_GL_FASTPATH=1 ./evasgl_sample1)
SVN revision: 65891
Subject: [E-devel] [E-Devel][Patch] Evas GL Color Format Enum change
(and ElmGLview changes accordingly)
I'm submitting a patch that changes the color format for Evas GL.
When I first wrote Evas_GL, I just had EVAS_GL_RGB_8 and EVAS_GL_RGBA_8 and etc
but it was misleading for some people. It was more of a filler since I couldn't decide on
a name. I'm finally changing it to make it more clear.
SVN revision: 64491
Subject: [E-devel] [Patch] modify gl engine's animated function
related with cache entry
I modified the gl engine code related with animated images
This is very trivial. Evas image object passes images to the engine.
In the software engine, it is a cache entry , but in the GL engine, it is
an Evas_GL Image. So I modified the gl engine code to get the cache entry
from the gl image.
SVN revision: 64143
Subject: Re: [E-devel] [E-Devel][Review][Patch] Evas GL Extensions + a
bug fix
Here's an initial attempt at the GL extensions issue for Evas GL.
I have been in discussion with a few EFL developers regarding how we should
provide extensions. Essentially, there are two ways to go about doing this.
1. provide evas_gl_proc_address_get() function as it is done in other
glue layers
2. provide all the extension functions in the EVAS_GL_API struct.
#1 approach is how it's done in other glue layers and the driver implementor can
provide new extensions easily. It is however pretty annoying to get the
function prototypes right and use the function pointers and etc.
#2 approach provides all the extension functions in the struct so it's
definitely easier to use. Adding new extensions can be a pain as people may
have to wait for new version releases.
For now, we thought it was OK to just throw them in the struct as in
#2 and try it out. So, I've implemented this approach. As for the extensions,
I've basically included all the extensions in gl2ext.h as EvasGL currently
provides all the GLES 2.0 functions. In order to display the right
information, I had to override glGetString() with GL_EXTENSIONS as parameter to properly
display the supported extensions.
Also, I've added a few EGL extensions that have been
modified for EvasGL use. For example, eglCreateImage/eglDestroyImage has been
defined as folllows.
EvasGLImage (*evasglCreateImage) (int target, void* buffer, int*
attrib_list); void
(*evasglDestroyImage)
(EvasGLImage image);
const char *evas_gl_string_query() function was added to return a string of
supported EvasGL extensions. So essentially, a user can search this string to see
if the desired extension is supported. if it is, he can use the functions. He can
always check if the function pointers are NULL as well.
Take a look at the pach and let me know what you think.
______________
While I was adding the extension code, I've added a few fixes/ changes
to the EvasGL.
1. glDeletBuffers bug
- When I wad destroying evasgl context, I was deleting the context FBO with
glDeleteBuffers instead of glDeleteFramebuffers. This code in effect was
deleting BOs in other contexts and we had some funky behaviors as a
result. The
bug has been fixed.
2. make_current
- I've made some changes to the make current code and also added a resource
context to the engine data. the resource context is used for creating surface
texture/ fbos when surface/ context is created. Before, i was using evas'
context but thought it'd be a good idea to use a separate context.
SVN revision: 64139
Subject: [E-devel] [Review] [Patch] Evas_GL bug fixes/updates
I've fixed some minor issues that I've been pushing off for later.
The patch does the following:
1. Evas_GL and Evas had an issue where the viewport parameters were
being reset in the wrong context. Previously, this issue was temporarily
patched by flushing evas' pipeline and setting
evas_gl_common_context_use(NULL) in EvasGL's
make current. I know, it was pretty hacky. It turns out that in
evas_engine,
there was a code evas_gl_common_context_resize(NULL) without doing
eng_window_use() first. So i've added that part and problem went was
resolved properly. :-)
2. Naturally, I've taken out the temporary patch from 1.
3. I've added code that took care of glBindFramebuffer(..., fbo) where
the
fbo had to be saved and restored in case the user wanted to use his
own fbo.
Also, I've had to take care of the case when fbo is 0 since 0 need to
point
to evas_gl surface.
4. I've updated make_current a little as well.
SVN revision: 62780
Subject: [E-devel] [Patch] evas gl engine's texture creation
Hello.
1. _pool_tex_dynamic_new function, it didnt set pt to NULL when secsym_eglCreateImage function failed.
In this case, it returns wrong pt pointer and it has possibility to make crash.
So I add free pt code and return NULL code into _pool_tex_dynamic_new function.
2. I modified eng_image_data_get of gl engine.
If Evas_GL_Image's texture creation failed and evas_gl_image's cache image was droped,
Im->im can be NULL. So I add check code.
Example: evas_gl_common_image_content_hint_set
1) EVAS_IMAGE_CONTENT_HINT_DYNAMIC , it drop cache image
2) if evas_gl_common_texture_dynamic_new failed
3) then, im->im =NULL, im->tex=NULL
In this situation, if application call's evas_object_image_data_get function,
It make crash in evas_cache_image_load_data function.
3. I think function's related with evas_object's engine data have to be return NULL if it failed.
If function's returns null, evas object code can handle error more easily.
But evas object's code was implemented differently each case. Does my suggestion right?
I add engine data null check code to evas_object_image based on upper consumtion.
If it is wrong , the patch code related with evas object image have to be removed.
If it is right , I will survey other evas object type also.
SVN revision: 62775
Subject: [E-devel] [Patch] Map/Unmap image for zero-copy texture
this modifies the zero copy texture feature to map and unmap on get and put
data to allow the put to "flush gpu caches".
SVN revision: 62493
Subject: RE: [E-devel] [Patch] Animation gif feature patch
Animated gif suport in evas and api's to handle animated images and
frame flipping. from jy.
SVN revision: 62331
Dear all,
eng_image_stride_get() of gl backend get fault stride value.
In case of using dynamic image, it get from dyn.w*4.
But, dyn.stride was already got from secsym_eglGetImageAttribSEC() in _pool_tex_dynamic_new().
dyn.stride can be changed according to DDK.
So, the stride needs to get from dyn.stride.
Please find enclosed file.
Thanks.
SVN revision: 61463
Dear all,
There is a below issue.
Problem : Evas gl engine call eglWaitNative() and eglWaitGL() before/after eglSwapBuffers().
The sync APIs are not call only in case of SGX_DDK.
Resolution : It is necessary to check MALI string too.
So, I fixed it.
Please find enclosed file.
Thanks.
SVN revision: 61226
Subject: evas_gl_api_get patch.
Here's a patch that simply overrides the GL functions for Evas_GL
except for two functions that I provide on my own. It may have some symbol
resolving warnings but that'll all go away eventually when we do everything
via dlsym or getProcAddress.
You can apply the patch to the latest revision of evas. (I've just
updated them) I'm also attaching a sample GLES program that uses
evas_gl_api_get. You don't need to link it to -lGL.
SVN revision: 59092
Subject: [E-devel] [Review] [Patch] Evas - OpenGL on Evas: surface
texture creation patch
I'm attaching a patch that addresses the awkward usage case. It's something
that didn't bother me initially but the more I look at it, i think
it's a little off. :-)
The initial version of the evas_gl that I've submitted had the
following use case.
evasgl = evas_gl_new(e);
sfc = evas_gl_surface_create(...);
ctx = evas_gl_context_create(...);
// Make current triggers surface texture and FBO to be created
evas_gl_make_current(evasgl, sfc, ctx);
// Then you can do a surface_get to retrieve the proper texture and set it
evas_gl_native_surface_get(evasgl, sfc, &ns);
evas_object_image_native_surface_set(img_obj, &ns);
The unnatural thing about this use case is that you have to call the make_current
one time in order for evas_gl to generate a surface texture. This is because
you need a context to create a texture. Unfortunately, this makes the usage
case really awkward.
So, instead, I've decided to get rid of the need for calling the make_current
by generating a surface texture when evas_gl_surface_create() is called
by using the evas' gl context. This works because the newly created context
shares resources with evas. in fact, this is what i'm currently doing with surface
deletion anyway so I thought this solution was reasonable.
Here's how it looks after you get rid of the make_current:
evasgl = evas_gl_new(e);
sfc = evas_gl_surface_create(...);
ctx = evas_gl_context_create(...);
evas_gl_native_surface_get(evasgl, sfc, &ns);
evas_object_image_native_surface_set(img_obj, &ns);
The patch is pretty small and straightforward.
SVN revision: 58892
(part of the evas-gl work)
the patch basically checks to see if the current context is evas' gl context
and if it is, it'll call evas_gl_common_context_flush(). I think this
is the proper
SVN revision: 58786
More work, proudly supported by Samsung. Filters!
So now you can apply a whole host of cheesy visual effects to objects at
runtime. This is the first commit, there are a couple of more to come as I
tweak the filters, and fix blur with GL[1].
Please direct bugs to me nash@nash.id.au.
[1] You'd think shaders would be good at this.. but no, generic blur and GL
are like trying to get an apple product to work with Linux.
SVN revision: 58726