summaryrefslogtreecommitdiff
path: root/glx/glxext.c
AgeCommit message (Collapse)AuthorFilesLines
2016-06-21res: Account for GLXPixmap references tooAdam Jackson1-0/+19
GLX_EXT_tetxure_from_pixmap operates on a GLXPixmap, which takes a reference on the backing pixmap; that GLXPixmap might be long-lived, so we should account for it in ResQueryClientPixmapBytes. Acked-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-20glx: avoid memory leak when using indirect renderingGuilherme Quentel Melo1-0/+6
When multiple processes are using GL with indirect rendering a race condition can make drawables refcount never drop to zero. This situation could happen when there are many X clients using indirect GLX: 1 - client1: calls glXMakeCurrent 2 - client2: calls glXMakeCurrent This is the first context switch for this client. So old_context_tag=0 3 - client1: calls glXRender For the client, its context is already current. For the server side lastGLContext points to client2's context. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Guilherme Quentel Melo <gqmelo@gmail.com>
2016-05-11glx: Stop tracking hasUnflushedCommandsAdam Jackson1-1/+0
This is only meaningful for indirect contexts, and all it does is (maybe) prevent a flush when switching away from an indirect context. Indirect contexts aren't worth optimizing for, and Mesa tracks whether a flush is needed anyway. Careful readers will note that ReadPixels would reset the flag even though it doesn't imply a flush! Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-03-30glx: Enable GLX 1.4 unconditionallyAdam Jackson1-2/+0
Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-12-05glx: Fix crash when a client exits without deleting GL contextsJon TURNEY1-2/+3
With the previous patches applied, we now have crash due to use-after-free when a client exits without deleting all it's GL contexts On client exit, CloseDownClient first calls glxClientCallback() with ClientStateGone, which calls __glXFreeContext() directly. Subsequently CloseDownClient() frees all the clients resources, which leads to ContextGone() being called for a context resource where the context has already been freed. Fix this by modifiying glxClientCallback() to free the context resource. Also make __glXFreeContext() static, as calling it directly leads to this problem, instead the context resource should be released. With the previous patches applied, this can be demonstrated with e.g. glxinfo, which doesn't delete it's context before exit. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-12-05glx: Flush context which is being made non-current due to drawable going awayJon TURNEY1-0/+3
Some sequences of glean tests fail with GLXBadCurrentWindow when using indirect rendering, e.g. glean -t 'fpexceptions getString'. Flush a context which is being made non-current due to the drawable on which is it is current going away. Waiting until another context is made current is too late, as the drawable no longer exists. v2: Rewrite for direct GL dispatch v3: Inline FlushContext(), doesn't need to be a separate function e.g. LIBGL_ALWAYS_INDIRECT=1 ./glean -r results -o --quick -t "fpexceptions getString" fails with a BadContextTag error. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-05-22glx: Require at least one True/DirectColor visualAdam Jackson1-0/+21
Mesa no longer supports rendering to anything less. GLX 1.2 requires that the server advertise at least one GLX visual. GLX 1.3 and 1.4 are more subtle: they require at least one fbconfig capable of window rendering, and _also_ require that window-capable fbconfigs have a non-zero value for the GLX_VISUAL_ID. In either case we should refuse to init GLX if there's not at least one GL-capable visual on at least one screen. Signed-off-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-23glx: Unconditionally clear lastGLContext on loseCurrent().Eric Anholt1-2/+2
This hook calls unbindContext in the DRI driver interface, which unsets the dispatch table, regardless of whether the context argument was the current one or not. 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-23glx: Move GLX MakeCurrent lastGLContext updates next to makeCurrent().Eric Anholt1-1/+2
We want to make sure that lastGLContext is set correctly during makeCurrent, because we may have recursive GL context changes in the DRI2 interfaces due to glamor. 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-23glx: Move the GLX variable caching what GL context is current to dix.Eric Anholt1-19/+7
GLX is trying to track whether the context it wants is current, to avoid the glFlush() (and the rest of the overhead) that occurs on all MakeCurrent calls. However, its cache can be incorrect now that glamor exists. This is a step toward getting glamor to coordinate with 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-02-07__glGetProcAddress: explictly cast function pointers to void *Alan Coopersmith1-2/+2
Fixes Solaris Studio compiler warning & error: "glxext.c", line 557: warning: assignment type mismatch: pointer to void "=" pointer to function(void) returning void "glxext.c", line 559: error: operands have incompatible types: pointer to void ":" pointer to function(void) returning void Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2014-01-12Replace 'pointer' type with 'void *'Keith Packard1-2/+2
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer' is used throughout the X server for other things, and having duplicate names generates compiler warnings. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2013-12-13glx: Add null pointer protection to __glGetProcAddressAdam Jackson1-1/+3
This can't happen when GLX is the backing window system, but can elsewhere. We may as well protect against it at a high level. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-12-10glx: Untangle the prototypes around the GetProcAddress thunkAdam Jackson1-2/+2
Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2013-12-05present: Send GLX_BufferSwapComplete events from present extensionKeith Packard1-0/+3
This allows GL to support the GLX_INTEL_swap_event extension. v2: Return GLX_BLIT_COMPLETE_INTEL for unknown swap types Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-10-29glx: convert to direct GL dispatch (v2)Adam Jackson1-0/+13
We now expect to be linked against something that provides the GL API, instead of manually grubbing about in the DRI driver's dispatch table. Since the GLX we expose calls GL functions that are meant to be looked up dynamically, also add a way to thunk through to GetProcAddress. This includes a refresh of the generated sources, which requires a correspondingly new Mesa. The GetProcAddress stubs are at the moment merely enough to make this link against Mesa 9.2, but should really be provided for everything not in the OpenGL 1.2 ABI. v2: Explicitly hide the GetProcAddress stubs so we can't conflict with libGL symbols; fix leading tab/space issues [anholt] Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-10-29glx: Fix a corner case in DrawableGoneAdam Jackson1-1/+1
Losing the drawable does not change our notion of current client. Since the GL under us doesn't understand having a current context without current drawables (sigh), we do still need to loseCurrent so that we re-bind the context on the next request. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65030 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-10-29glx: Fix memory leak in context garbage collection (v2)Adam Jackson1-11/+22
I broke this, back in: commit a48dadc98a28c969741979b70b7a639f24f4cbbd Author: Adam Jackson <ajax@redhat.com> Date: Mon Mar 21 11:59:29 2011 -0400 glx: Reimplement context tags In that, I changed the glx client state to not explicitly track the list of current contexts for the client (since that was what we were deriving tags from). The bug was that I removed the code for same from glxClientCallback without noticing that it had the side effect of effectively de-currenting those contexts, so that ContextGone could free them. So, if you had a client exit with a context still current, the context's memory would leak. Not a huge deal for direct clients, but viciously bad for indirect, since the swrast context state at the bottom of Mesa is like 15M. Fix this by promoting Bool isCurrent to ClientPtr currentClient, so that we have a back-pointer to chase when walking the list of contexts when ClientStateGone happens. v2: Explicitly call __glXFreeContext on the ClientStateGone path. Our current context might be one we got from EXT_import_context and whose creating client has since died. Without the explicit call, the creating client's FreeClientResources would not free the context because it's still current, and the using client's FreeClientResources would not free the context because it's not an XID it created. This matches the logic from a48dadc. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-11glx: Remove a dead commentAdam Jackson1-4/+0
Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-07-25glx: drop GLX_LIBS from X server and workaround sdksyms.Dave Airlie1-0/+1
We've had reports of two copies of the GLX bits, one in the server and one in libglx.so causing problems, I didn't understand why the X server needed a copy so drop it, however then we have to fix a missing GlxExtensionInit that comes from sdksyms, so work around it by moving that one declaration into a header that sdksyms doesn't scan. Thanks to Jon Turney for debugging the actual problem. (copyright header from extinit.h that seems most appropriate put on top). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52402 Tested-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Tested-by: Jon TURNEY <jon.turney@dronecode.org.uk> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-12Revert bogus GlxPushProvider() in commit a1d41e3Jon TURNEY1-3/+0
a1d41e3 "Move extension initialisation prototypes into extinit.h" also includes a change to GlxExtensionInit to install the swrast GLX provider. Since b86aa74 "GLX: Insert swrast provider from GlxExtensionInit" already does this (correctly, by installing the swrast provider at the end of the chain, rather than at the beginning), and since this would seem to have the effect of making the swrast provider the most preferred provider, I'm guessing this wasn't intended. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2012-07-09Move extension initialisation prototypes into extinit.hDaniel Stone1-0/+4
Create extinit.h (and xf86Extensions.h, for Xorg-specific extensions) to hold all our extension initialisation prototypes, rather than duplicating them everywhere. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09GLX: Insert swrast provider from GlxExtensionInitDaniel Stone1-1/+7
Rather than making poor old miinitext.c do it, including making DMX have fake symbols just to keep it happy. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Stéphane Marchesin <stephane.marchesin@gmail.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2012-05-23glx: Use one function to add a context to all global tablesIan Romanick1-2/+9
Instead of having separate __glXAddContextToList and AddResource functions, just have one function that does both steps. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Reviewed-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-05-23glx: Don't track GLClientmajorVersion or GLClientminorVersionIan Romanick1-2/+0
Nothing uses these fields anywhere in the server. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Reviewed-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
2012-03-21Introduce a consistent coding styleKeith Packard1-172/+193
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-04-15glx: Fix lifetime tracking for pixmapsAdam Jackson1-9/+13
GLX pixmaps take a reference on the underlying pixmap; X and GLX pixmap IDs can be destroyed in either order with no error. Only windows need to be tracked under both XIDs. Fixes piglit/glx-pixmap-life. Reviewed-by: Michel Dänzer <michel@daenzer.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-28glx: minor cast cleanupAdam Jackson1-4/+3
Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-28glx: dead variable removalAdam Jackson1-8/+0
Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-28glx: Remove ->forceCurrent from the context vtableAdam Jackson1-1/+1
All the implementations of makeCurrent and forceCurrent are identical, so just use makeCurrent everywhere. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-28glx: Reimplement context tagsAdam Jackson1-31/+0
This would let you do a constant-time context lookup, but if that's your performance problem you have two problems. Just use the context's XID as the tag value instead. In order to do this, we have to defer destroying a context until it actually goes unreferenced, as you're allowed to mention a context tag after you've (ostensibly) destroyed the context, as long as it's still your current context. Thus, change DestroyContext to merely mark the context as dead if it's a current context, and call down to actual resource destruction (and XID reclamation) in StopUsingContext. Also, stop trying to delete context state from DrawableGone. This was always broken, as GLX does not say that contexts are destroyed when their drawables are destroyed. But with the above change to defer context destruction, this would trigger a server crash on client exit as we'd free the context state twice. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-11-30glx: Remove swap barrier and hyperpipe supportAdam Jackson1-18/+1
Never implemented in any open source driver. The implementation assumed explicit DDX driver knowledge of how the client-side driver worked, since at the time the server's GL renderer was not a DRI driver. But now, it is, so any implementation of these should be done with additional DRI driver API, like the swap control extension. Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Adam Jackson <ajax@redhat.com>
2010-09-28glx: Fix use after free in DrawableGoneKristian Høgsberg1-6/+5
(note that nearly identical patches were proposed by Kristian and Chris) Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reported-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Tested-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-06Remove more superfluous if(p) checks around free(p)Mikhail Gusarov1-6/+6
This patch has been generated by the following Coccinelle semantic patch: @@ expression E; @@ -if(E) { free(E); } +free(E); Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br> Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-05Change the devPrivates API to require dixRegisterPrivateKeyKeith Packard1-3/+3
This patch only changes the API, not the implementation of the devPrivates infrastructure. This will permit a new devPrivates implementation to be layed into the server without requiring simultaneous changes in every devPrivates user. Signed-off-by: Keith Packard <keithp@keithp.com> Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
2010-05-13Eliminate boilerplate around client->noClientException.Jamey Sharp1-1/+1
Just let Dispatch() check for a noClientException, rather than making every single dispatch procedure take care of it. Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-05-13Replace X-allocation functions with their C89 counterpartsMikhail Gusarov1-6/+6
The only remaining X-functions used in server are XNF*, the rest is converted to plain alloc/calloc/realloc/free/strdup. X* functions are still exported from server and x* macros are still defined in header file, so both ABI and API are not affected by this change. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-04-16glx: Track GLX 1.3 style GLX drawables under their X drawable ID as wellKristian Høgsberg1-0/+11
This ensures that the DrawableGone callback gets called as necessary when the X drawable goes away. Otherwise, using a GLX drawable (say, glXSwapBuffers) in indirect mode after the X drawable has been destroyed will crash the server. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Michel Dänzer <michel@daenzer.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-11GLX/DRI2: add INTEL_swap_event supportJesse Barnes1-0/+2
This allows clients to easily check for swap completion status in their main loop. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Adam Jackson <ajax@nwnk.net> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2010-01-11DRI2: add support for new DRI2 protocol requestsJesse Barnes1-0/+3
Support the new DRI2 2.2 protocol requests: DRI2SwapBuffers, DRI2GetMSC, DRI2WaitMSC, DRI2WaitSBC and DRI2SwapInterval. These requests allow the server to support the SGI_video_sync, SGI_swap_interval, and OML_sync_control GLX extensions if DDX support is present. The new DDX APIs are documented in dri2.h. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Adam Jackson <ajax@nwnk.net> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-12-18Add type name argument to CreateNewResourceTypeAlan Coopersmith1-8/+6
Convert all calls of CreateNewResourceType to pass name argument Breaks DIX ABI. ABI versions bumped: Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-18Check for failures from CreateNewResourceTypeAlan Coopersmith1-0/+3
Make sure to check return value before setting bitmask flags. For most calls, just fails to init the extension. Since Xinput already calls FatalError() on initialization failure, so does failure to allocate Xinput's resource type. Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2009-10-02glx: fixup deref of null pointer when glx screen init fails.Dave Airlie1-2/+2
I think this is what the original author wanted. Signed-off-by: Dave Airlie <airlied@redhat.com> Acked-by: Ian Romanick <ian.d.romanick@intel.com>
2009-09-29GLX: Enable GLX 1.4 on DRI2Ian Romanick1-1/+7
Return the minimum GLX version supported by all screens. Assume that DRI2 screens have all the required features for GLX 1.4. Assume that everyone else can only support GLX 1.2. Reviewed-by: Kristian Høgsberg <krh@redhat.com> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-06-24GLX: make function static.Dave Airlie1-1/+1
This function isn't called from anywhere else and I don't think it shuold be.
2009-06-23glx: Clean up more thoroughly if the drawable of a current context goes away.Michel Dänzer1-1/+24
Fixes crash when restarting compiz, due to cl->currentContexts[x] being stale.
2009-06-11glx: fix open-coded linked list removal functionDave Airlie1-5/+11
OMG stab stab stab, YALL. removal function was made of crack, actually truncated the list from the one after the find point. However fixing this makes glean makecurrent fail with a GLX error.
2009-05-19glx: Register names for the GLX resource types.Eamon Walsh1-0/+5
Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
2009-05-14glx: If a destroyed window is bound to the current context, make it not current.Michel Dänzer1-0/+4
Avoids subsequent crashes due to stale pointers to the DrawableRec, see https://bugs.freedesktop.org/show_bug.cgi?id=21132#c15 and previous comments. Signed-off-by: Michel Dänzer <daenzer@vmware.com>
2009-04-13glx: Fix drawable private leak on destroyKristian Høgsberg1-12/+30
When a drawable goes away, we don't destroy the GLX drawable in full, since it may be current for a context. This means that when the drawable is destroyed in full later, the backend doesn't get a chance to destroy resources associated with the drawable (the DRI2Drawable). With this patch, we destroy the GLX drawable in full when it goes away and then track down all contexts that reference it and NULL their pointers.