summaryrefslogtreecommitdiff
path: root/glamor/glamor_egl.c
AgeCommit message (Collapse)AuthorFilesLines
2014-07-30Fix files including xorg-server.h by mistakeKeith Packard1-1/+0
A few files in the server are including xorg-server.h, which is only for use by Xorg server drivers. This fixes those errors and then adds a check to make sure it doesn't happen again. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23glamor: Explain the weird EGL_NO_CONTEXT code.Eric Anholt1-0/+7
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23glamor: Replace glamor_get/put_context() with just glamor_make_current().Eric Anholt1-21/+6
Now that we have the DIX global state for the current context, we don't need to track nesting to try to reduce MakeCurrent overhead. v2: Fix a mistaken replacement of a put_context with make_current in glamor_fill_spans_gl() (caught by keithp). Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> (v1) Reviewed-by: Adam Jackson <ajax@redhat.com> (v1)
2014-04-23glamor: Stop unsetting the EGL context in put_context().Eric Anholt1-5/+1
This matches the Xephyr behavior. Now that we know when to reset the context in the presence of GLX, we don't need to try to keep our stuff from being smashed by GLX. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23glamor: Use lastGLContext to coordinate the context with GLX.Eric Anholt1-8/+6
This gets us some more context changes that are needed to make sure the two sides render to the right drawables and manipulate the right objects. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23glamor: Fix a missing set of the GL context.Eric Anholt1-5/+12
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-08dri3: Fix dri3_open API change by adding new dri3_open_clientKeith Packard1-6/+6
Xwayland will eventually need the current client in dri3_open. Simply changing that API is not an option though as other drivers that implement DRI3 will not have a matching function signature and will crash when called. Add a new dri3_open_client function pointer and bump DRI3_SCREEN_INFO_VERSION so that drivers can be aware of the new function which will be used in preference to the old function when available. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anhole <eric@anholt.net>
2014-04-01dri3: Allow asynchronous implementation for dri3_openKristian Høgsberg1-1/+2
By passing the client pointer to the dri3_open implementation, we allow the clients to implement the open callback asynchronously. If the client ignore count is positive after returning from dri3_open, we assume that authentication is in progress and doesn't send the reply. The code to send the reply is moved into a helper function, which the implementation can call upon receiving its authenticaion reply. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-03-17glamor: Return the stride/size for glamor_dri3_name_from_pixmap(), too.Eric Anholt1-2/+2
Just like for a caller of glamor_dri3_fd_from_pixmap(), otherwise the consumer of that named buffer has no idea what GL chose for the stride. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17glamor: Drop the body of the function for enabling DRI3 extensions.Eric Anholt1-6/+1
The flag is already being set at glamor_egl_screen_init() time, so no need for the driver to separately call this. That said, leave the function around to keep the ABI compatibility. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17glamor: Move the EGL image to the normal pixmap private.Eric Anholt1-49/+40
There's no reason to hide EGL from the rest of glamor, now that we have epoxy. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-17glamor: Use epoxy_has_egl_extension() instead of rolling our own.Eric Anholt1-24/+7
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Markus Wick <markus@selfnet.de>
2014-03-05glamor: Add support for DRI3.Eric Anholt1-0/+85
The render-nodes case is untested. v2: Add a flag for wayland to suppress the native DRI3 support. Wayland isn't running as a master itself, so it can't do the auth on its own and has to ask the compositor to do it for us. Dropped XXX about randr provider -- the conclusion from discussion with keithp was that if the driver's dri3_open for a provider on a different screen, that's a core dri3 bug. v3: Don't put quite so much under GLAMOR_NO_DRI3, and add a comment explaining what this is about. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-03-05glamor: Rename the DRI-related pixmap functions.Eric Anholt1-6/+6
There was confusion over whether they should have egl in the name, and they had DRI3 in the name even though they're useful to have without DRI3. v2: Just rename glamor_name_from_pixmap for now -- I'd accidentally conflict-resolved in adding new parameters from a later commit. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14glamor: Move the EGL DRI3 code to GLAMOR_HAS_GBM.Eric Anholt1-5/+5
There's nothing dependent on the presence of DRI3 code in the server for this, but it does rely on GBM. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-02-14glamor: Put in a pluggable context switcher for GLX versus EGL.Eric Anholt1-26/+32
The GLX side just gets the context from the current state. That's also something I want to do for EGL, so that the making a context is separate from initializing glamor, but I think I need the modesetting driver in the server before I think about hacking on that more. The previous code was rather incestuous, along with pulling in xf86 dependencies to our dix code. The new code just initializes itself from the current state. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-02-14glamor: Convert to using libepoxy.Eric Anholt1-81/+35
Libepoxy hides all the GL versus GLES2 dispatch handling for us, with higher performance. v2: Squash in the later patch to drop the later of two repeated glamor_get_dispatch()es instead (caught by keithp) Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27glamor: Use dix-config.h not project config.hAdam Jackson1-3/+1
v2: Also edit the one in glamor_egl.c (by anholt) v3: Also edit the one in glamor_eglmodule.c (by anholt) Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27glamor/egl: Remove glapi awarenessAdam Jackson1-21/+3
We only needed this because glx was directly bashing glapi tables. Since that's not the case anymore, we should just MakeCurrent like a real GL app. v2: Hand-resolve against rebase onto newer server (by anholt) Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27glamor: Remove compat code for building out of tree.Eric Anholt1-12/+4
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2014-01-27glamor: Apply x-indent.sh.Eric Anholt1-587/+580
Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2013-12-18Fix glamor_egl->egl_create_image_khr makes pointer from integerGaetan Nadon1-1/+1
This is a warning, but a real problem can occur on some system. Reported-by: Fabio Pedretti <fabio.ped@libero.it> Reviewed-by: Axel Davy <davyaxel@free.fr> Signed-off-by: Gaetan Nadon <memsize@videotron.ca> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Add DRI3 support to glamorAxel Davy1-0/+225
This implements some DRI3 helpers to help the DDXs using glamor to support DRI3. Signed-off-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Fixed some compilation warning/error or error checking.Zhigang Gong1-1/+3
There is one compilation error ,cast int to pointer, when built without libgbm, reported by Gaetan Nadon. And some error checking after memory allocation, reported by Seth Arnold. There are still some similar issues in the largepixmap implementation. They are relatively more complicate due to the heavy usage of RegionXXX APIs which may allocate implicitly. Will fix them in the future. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Tested-by: Gaetan Nadon <memsize@videotron.ca>
2013-12-18Allow to create textured pixmaps from gbm_bo without using gem namesAxel Davy1-0/+34
This implements glamor_egl_create_textured_pixmap_from_gbm_bo, which is similar to glamor_egl_create_textured_pixmap, except it takes a gbm_bo as argument. Signed-off-by: Axel Davy <axel.davy@ens.fr> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamoregl: Use xf86ScreenToScrn()Michel Dänzer1-10/+10
Fixes crashes when glamor is used for a GPU screen with xserver 1.13 or newer. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57200#c17 Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-12-18Silence compilation warnings.Zhigang Gong1-8/+3
After increase to gcc4.7, it reports more warnings, now fix them. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com> Tested-by: Junyan He<junyan.he@linux.intel.com>
2013-12-18Prefer KHR_surfaceless_context EGL extension over KHR_surfaceless_opengl/gles2.Michel Dänzer1-3/+10
Current Mesa Git only advertises the former instead of the latter. Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Print space between name of missing EGL extension and 'required'.Michel Dänzer1-1/+1
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Synch with xorg 1.13 change.Zhigang Gong1-5/+11
As xorg 1.13 change the scrn interaces and remove those global arrays. Some API change cause we can't build. Now fix it. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Added strict warning flags to CFLAGS.Zhigang Gong1-10/+9
We miss the strict warning flags for a long time, now add it back. This commit also fixed most of the warnings after enable the strict flags. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Fixed all unused variables warnings.Zhigang Gong1-2/+1
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Added --enable-debug configuration option.Zhigang Gong1-1/+2
For release version, we disable asserts. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18For DRI swap buffers.Zhigang Gong1-4/+55
This commit added two APIs to support the DRI swap buffer. one is glamor_egl_exchange_buffers() which can swap two pixmaps' underlying KHRimages/fbos/texs. The DDX layer should exchange the DRM bos to make them consistent to each other. Another API is glamor_egl_create_textured_screen_ext(), which extent one more parameters to track the DDX layer's back pixmap pointer. This is for the triple buffer support. When using triple buffer, the DDX layer will keep a back pixmap rather then the front pixmap and the pixmap used by the DRI2 client. And during the closing screen stage, we have to dereference all the back pixmap's glamor resources. Thus we have to extent this API to register it when create new screen. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Fixup glx supportChris Wilson1-20/+32
Renaming glamor_priv->dispatch and wrapping the access to the dispatch table with a function that also ensured the context was bound. dispatch = glamor_get_dispatch(glamor_priv); ... glamor_put_dispatch(glamor_priv); So that we catch all places where we attempt to call into GL withouta context. As an optimisation we can then do glamor_get_context(); glamor_put_context() around the rendering entry points to reduce the frequency of having to restore the old context. (Along with allowing the context to be recursively acquired and making the old context part of the glamor_egl state.) Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18GLX: Enable glx support.Zhigang Gong1-6/+53
If we are using MESA as our GL library, then both xserver's GLX and glamor are link to the same library. As xserver's GLX has its own _glapi_get/set_context/dispatch etc, and it is a simplified version derived from mesa thus is not sufficient for mesa/egl's dri loader which is used by glamor. Then if glx module is loaded before glamoregl module, the initialization of mesa/egl/opengl will not be correct, and will fail at a very early stage, most likely fail to map the element buffer. Two methodis to fix this problem, first is to modify the xserver's glx's glapi.c to fit mesa's requirement. The second is to put a glamor.conf as below, to the system's xorg.conf path. Section "Module" Load "glamoregl" EndSection Then glamor will be loaded firstly, and the mesa's libglapi.so will be used. As current xserver's dispatch table is the same as mesa's, then the glx's dri loader can work without problem. We took the second method as it don't need any change to xorg.:) Although this is not a graceful implementation as it depends on the xserver's dispatch table and the mesa's dispatch table is the same and the context set and get is using the same method. Anyway it works. As by default, xserver will enable GLX_USE_TLS. But mesa will not enable it, you may need to enable that when build mesa. Three pre-requirements to make this glamor version work: 0. Make sure xserver has commit 66e603, if not please pull the latest master branch. 1. Rebuild mesa by enable GLX_USE_TLS. 2. Put the glamor.conf to your system's xorg.conf path and make sure it loaded prior to glx module. Preliminary testing shows indirect glxgears works fine. If user want to use GLES2 for glamor by using MESA, GLX will not work correctly. If you are not using normal MESA, for example PVR's private GLES implementation, then it should be ok to use GLES2 glamor and the GLX should work as expected. In this commit, I use gbm to check whether we are using MESA or non-mesa. Maybe not the best way. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Refine CloseScreen and FreeScreen processes.Zhigang Gong1-42/+75
This commit move the calling to glamor_close_screen from glamor_egl_free_screen to glamor_egl_close_screen, as this is the right place to do this. We should detach screen fbo and destroy the corresponding KHR image at glamor_egl_close_screen stage. As latter DDX driver will call DestroyPixmap to destroy screen pixmap, if the fbo and image are still there but glamor screen private data pointer has been freed, then it causes segfault. This commit also introduces a new flag GLAMOR_USE_EGL_SCREEN. if DDX driver is using EGL layer then should set this bit when call to glamor_init and then both glamor_close_screen and glamor_egl_close_screen will be registered correctly, DDX layer will not need to call these two functions manually. This way is also the preferred method within Xorg domain. As interfaces changed, bump the version to 0.3.0. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com> Tested-by: Peng Li <peng.li@intel.com>
2013-12-18glamor: check driver support GEM or notLi Peng1-6/+26
glamor calls DRM_IOCTL_GEM_FLINK to get a name for a buffer object. It only works for driver that support GEM, such as intel i915 driver. But for pvr driver who doesn't has GEM, we can't do it this way. According to Chris's comments, we check the has_gem as the following method: Here we just try to flink handle 0. If that fails with ENODEV or ENOTTY instead of ENOENT (or EINVAL on older kernels), set has_gem=0. Signed-off-by: Li Peng <peng.li@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamor_egl: Add support for the platform doesn't have gbm.Zhigang Gong1-0/+8
Maybe we should use eglGetDisplayDRM to get display, but current PVR's driver is using eglGetDisplay. Signed-off-by: Peng Li <peng.li@intel.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamor_egl: Don't call eglDestroyImageKHR directly.Zhigang Gong1-1/+5
Some implementation doesn't have it. Signed-off-by: Peng Li <peng.li@intel.com> Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamor-fbo-pool: Implement fbo cache mechanism.Zhigang Gong1-5/+2
We classify the cache according to the texture's format/width/height. As openGL doesn't allow us to change a texture's format/width/height after the internal texture object is already allocated, we can't just calculate the size and then according ths size to put the fbo to an bucket which is just like SNA does. We can only put the fbo to the corresponding format/width/height bucket. This commit only support the exact size match. The following patch will remove this restriction, just need to handle the repeat/tile case when the size is not exactly match. Should use fls instead of ffs when decide the width/height bucket, thanks for Chris to point this out. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamor_set_pixmap_texture/screen_pixmap: Remove useless parameters.Zhigang Gong1-34/+12
As after we got a texture, no matter the texture is created on the glamor_create_pixmap or on the egl layer, we all already know the texture's width and height there. We don't need to pass them in. This commit also simply the glamor_egl_create_textured_screen to reuse the egl_create_textured_pixmap. And also remove the useless root image from the egl private structure. As now the root image is bound to the screen image, we don't take care it separately here. It will be freed at the screen closing. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Fixed a configure bug.Zhigang Gong1-0/+4
Should check the enable-glamor-gles2 before use the variable. And should include the config.h as the GLAMOR_GLES2 macro is defined there. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Flush gl operations when destroy an textured image.Zhigang Gong1-1/+6
Before destroy an image which was attached to a texture. we must call glFlush to make sure the operation on that texture has been done. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Remove useless egl functions.Zhigang Gong1-5/+0
We only need to create image fron external name rather than use drm_image_mesa to create drm image, so remove them. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Correct the logic of glamor_egl_create_textured_pixmap.Zhigang Gong1-48/+10
Discussed with Chris and found the previous logic is not good. Now change it in this commit, this API will just try to create a textured pixmap from the handle provided by DDX driver, if failed simply return FALSE without touch the pixmap. And the DDX driver can choose how to do next step. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18glamor-for-ddx: Exports all rendering/drawing functions.Zhigang Gong1-18/+39
This commit exports all the rest rendering/drawing functions to the DDX drivers. And introduce some new pixmap type. For a pixmap which has a separated texture, we never fallback it to the DDX layer. This commit also adds the following new functions: glamor_composite_rects, glamor_get_image_nf which are needed by UXA framework. Just a simple wrapper function of miXXX. Will consider to optimize them next few weeks. This commit also Fixed a glyphs rendering bug pointed by Chris. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Classfy glamor pixmap to different types.Zhigang Gong1-7/+10
During the integration with intel driver, we introduce two new type of pixmap, one is TEXTURE_DRM, the other is DRM_ONLY. TEXTURE_DRM means we create a texture bind to the DRM buffer successfully. And then the texture and the external BO is consistent. DRM_ONLY means that we failed to create a texture from the external DRM BO. We need to handle those different types carefully, so we have to track them in the data structure. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Can't create KHR image if the depth is uncompatible.Zhigang Gong1-10/+12
Currently, KHR image only support one color format ARGB32. For all other format, we have to fail to create corresponding image and texture here. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2013-12-18Added a missed header file.Zhigang Gong1-1/+2
Pointed by Chris, we must add xorg-server.h at the top of each file before we include any other xorg header files. Otherwise, it may cause incorrect XID length. This commit also fixes one compilation warning in X86_64 platform. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>