Commit Graph

55 Commits

Author SHA1 Message Date
Yonggang Luo aa0b857544 glx: Remove usage of USE_ELF_TLS
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17213>
2022-07-29 23:59:12 +00:00
Adam Jackson 92b2e479b8 glx: Remove the remains of GLX_MESA_multithread_makecurrent
This hasn't actually been exported for a while. I think I probably broke
this in

    commit 63a6b719d9
    Author: Adam Jackson <ajax@redhat.com>
    Date:   Tue Dec 5 11:10:09 2017 -0500

        glx: GLX_MESA_multithread_makecurrent is direct-only

in which I made it no longer default to having client support, but
failed to instruct dri{2,3,sw} to enable it. In any case, it was never
widely used, there is no EGL equivalent, and we've had zero complaints
about it getting nerfed.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17473>
2022-07-12 10:02:46 +00:00
Thomas H.P. Andersen 7daba1fe65 replace 0 with NULL for NULL pointers
This updates many places where 0 is used as NULL pointer.

There are a few warnings left when I build the default
configuration but they either relate to code
outside of mesa or where "None" is used instead.

Found with static analysis (smatch)

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12174>
2022-01-10 22:53:32 +00:00
Emma Anholt 75a9cb1033 util: Add a helper macro for defining initial-exec variables.
I'm going to add another case for Android shortly, and then we can keep
the logic all in one spot.

Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10389>
2021-06-02 03:10:49 +00:00
Adam Jackson 12fd68a0dc glx: Return the right GLX opcode in synthetic MakeCurrent errors
If you're trying to figure out why an operation failed it helps if
the error matches the function you thought you called.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10381>
2021-04-22 18:11:52 +00:00
Adam Jackson fc9b3b260e Revert "glx: Lift sending the MakeCurrent request to top-level code"
This provokes crashes in Cinnamon for some reason that I haven't
diagnosed yet.

This reverts commit 80b67a3b44.

Fixes: 80b67a3b44 glx: Lift sending the MakeCurrent request to top-level code
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4639
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10260>
2021-04-15 19:48:10 +00:00
Adam Jackson 80b67a3b44 glx: Lift sending the MakeCurrent request to top-level code
Somewhat terrifyingly, we never sent this for direct contexts, which
means the server never knew the context/drawable bindings. To handle
this sanely, pull the request code up out of the indirect backend, and
rewrite the context switch path to call it as appropriate.  This
attempts to preserve the existing behavior of not calling unbind() on
the context if its refcount would not drop to zero.

Of course, you can't just do this indiscriminately, because this is GLX
and extant X servers have bugs and everything is terrible. To wit:

- For 1.20.x prior to 1.20.6, you can bind a direct context once, but
the second time you try to modify the context's binding you will get
GLXBadContextTag. This includes unbinding the context. And "deleting"
the context will leak memory, because it will still appear to be
current.

- For 1.19 and earlier, glXMakeCurrent(dpy, None, ctx) should be legal
for GL 3.0+ contexts, but the server will throw BadMatch.

To guard against this, we only send the request for indirect contexts
unless the server is known good, and only mention one context at a time
in such a request; if switching between contexts, we first unbind the
old, and then bind the new. Note that the second VendorRelease() version
is to catch XFree86 4.x and Xorg [67].x, which almost certainly have the
above bugs. Other servers might report different version numbers here,
but we can't do direct rendering against them, so this should be safe.

Fixes: mesa/mesa#4418
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9992>
2021-04-13 22:58:58 +00:00
Adam Jackson 8b6d3f2c78 Revert "glx: Lift sending the MakeCurrent request to top-level code"
Apparently this provokes crashes elsewhere in code unrelated to
MakeCurrent. I hate GLX so very very much.

This reverts commit 999c2aed88.

Gitlab: https://gitlab.freedesktop.org/mesa/mesa/issues/1207
2019-09-26 11:07:42 -04:00
Adam Jackson 999c2aed88 glx: Lift sending the MakeCurrent request to top-level code
Somewhat terrifyingly, we never sent this for direct contexts, which
means the server never knew the context/drawable bindings. To handle
this sanely, pull the request code up out of the indirect backend, and
rewrite the context switch path to call it as appropriate.  This
attempts to preserve the existing behavior of not calling unbind() on
the context if its refcount would not drop to zero.

Of course, you can't just do this indiscriminately, because this is GLX
and extant X servers have bugs and everything is terrible. To wit:

- For 1.20.x prior to 1.20.6, you can bind a direct context once, but
the second time you try to modify the context's binding you will get
GLXBadContextTag. This includes unbinding the context. And "deleting"
the context will leak memory, because it will still appear to be
current.

- For 1.19 and earlier, glXMakeCurrent(dpy, None, ctx) should be legal
for GL 3.0+ contexts, but the server will throw BadMatch.

To guard against this, we only send the request for indirect contexts
unless the server is known good, and only mention one context at a time
in such a request; if switching between contexts, we first unbind the
old, and then bind the new. Note that the second VendorRelease() version
is to catch XFree86 4.x and Xorg [67].x, which almost certainly have the
above bugs. Other servers might report different version numbers here,
but we can't do direct rendering against them, so this should be safe.

Fixes glx-make-context, glx-multi-window-single-context and
glx-query-drawable-glx_fbconfig_id-window. Sufficiently old piglit will
regress on glx-make-glxdrawable-current (throwing BadMatch), which is
fixed by mesa/piglit!116.
2019-09-23 20:39:01 -04:00
Adam Jackson 01e437988d glx: Move vertex array protocol state into the indirect backend
Only relevant for indirect contexts, so let's get that code out of the
common path.
2019-09-23 20:21:01 -04:00
Bas Nieuwenhuizen 9f37c9903b mesa: Rename GLX_USE_TLS to USE_ELF_TLS.
These days it is not GLX only and it does not work with all TLS
implementations.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2019-08-03 20:18:17 +02:00
Adam Jackson d257ec0136 glx: Don't allow glXMakeContextCurrent() with only one valid drawable
Drawable and readable need to either both be None or both be non-None.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-07-09 12:03:18 -04:00
Adam Jackson 75d5d22fb7 glx: Use __glXSendError instead of open-coding it
This also fixes a bug, the error path through MakeCurrent didn't
translate the error code by the extension's error base.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2017-12-01 15:46:46 -05:00
Colin McDonald d57c85c1bf glx: Call __glXInitVertexArrayState() with a usable gc.
For each indirect context the indirect vertex array state must be initialised
by __glXInitVertexArrayState in indirect_vertex_array.c.  As noted in the
routine header it requires that the glx context has been setup prior to the
call, in order to test the server version and extensions.

Currently __glXInitVertexArrayState is called from indirect_bind_context in
indirect_glx.c, as follows:

   state = gc->client_state_private;
   if (state->array_state == NULL) {
      glGetString(GL_EXTENSIONS);
      glGetString(GL_VERSION);
      __glXInitVertexArrayState(gc);
   }

But, the gc context is not yet usable at this stage, so the server queries
fail, and __glXInitVertexArrayState is called without the server version and
extension information it needs.  This breaks multi-texturing as
glXInitVertexArrayState doesn't get GL_MAX_TEXTURE_UNITS.  It probably also
breaks setup of other arrays: fog, secondary colour, vertex attributes.

To fix this I have moved the call to __glXInitVertexArrayState to the end of
MakeContextCurrent in glxcurrent.c, where the glx context is usable.

Fixes a regression caused by commit 4fbdde889c. Fixes ARB_vertex_program
usage in the arbvparray Mesa demo when run with indirect GLX and also
the tex-skipped-unit piglit test when run with indirect GLX.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Acked-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61907
2016-07-08 14:02:56 -07:00
Kyle Brenneman 22a9e00aab glx: Implement the libglvnd interface.
With reference to the libglvnd branch:

https://cgit.freedesktop.org/mesa/mesa/log/?h=libglvnd

This is a squashed commit containing all of Kyle's commits, all but two
of Emil's commits (to follow), and a small fixup from myself to mark the
rest of the glX* functions as _GLX_PUBLIC so they are not exported when
building for libglvnd. I (ajax) squashed them together both for ease of
review, and because most of the changes are un-useful intermediate
states representing the evolution of glvnd's internal API.

Co-author: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 16:29:49 +01:00
Emil Velikov a385d18598 glx: remove support for non-multithreaded platforms
Implicitly required for a while, although commit 9385c592c6 (mapi:
remove u_thread.h) was the one that put the final nail on the
coffin.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2015-03-11 23:28:26 +00:00
Emil Velikov 42144170d1 glx: remove final reference to THREADS
Left over from commit 18db13f5865(mapi: THREADS was always defined,
remove it)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2015-03-11 23:28:26 +00:00
Emil Velikov 8f2eaae10c Revert "glx: remove final reference to THREADS"
This reverts commit 8b15a883e0.

Not meant to go in yet. Lacking review.
2015-03-06 17:07:23 +00:00
Emil Velikov 5e3276f5c7 Revert "glx: remove support for non-multithreaded platforms"
This reverts commit 38591295cd.

Not meant to go in yet. Lacking review.
2015-03-06 17:07:11 +00:00
Emil Velikov 38591295cd glx: remove support for non-multithreaded platforms
Implicitly required for a while, although commit 9385c592c6 (mapi:
remove u_thread.h) was the one that put the final nail on the
coffin.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-06 16:46:18 +00:00
Emil Velikov 8b15a883e0 glx: remove final reference to THREADS
Left over from commit 18db13f5865(mapi: THREADS was always defined,
remove it)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-03-06 16:46:18 +00:00
Jon TURNEY 5a459a036e Fix build of appleglx
Define GLX_USE_APPLEGL, as config/darwin used to, to turn on specific code to
use the applegl direct renderer

Convert src/glx/apple/Makefile to automake

Since the applegl libGL is now built by linking libappleglx into libGL, rather
than by linking selected files into a special libGL:

- Remove duplicate code in apple/glxreply.c and apple/apple_glx.c.  This makes
apple/glxreply.c empty, so remove it

- Some indirect rendering code is already guarded by !GLX_USE_APPLEGL, but we
need to add those guards to indirect_glx.c, indirect_init.c (via it's
generator), render2.c and vertarr.c so they don't generate anything

Fix and update various includes

glapi_gentable.c (which is only used on darwin), should be included in shared
glapi as well, to provide _glapi_create_table_from_handle()

Note that neither swrast nor indirect is supported in the APPLEGL path at the
moment, which makes things more complex than they need to be.  More untangling
is needed to allow that

v2: Correct apple/Makefile.am for srcdir != builddir

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-05-23 15:24:07 +01:00
Brian Paul 02cb04c68f mesa: remove remaining uses of _glthread_GetID()
It was really only used in the radeon driver for a debug printf.
And evidently, libGL.so referenced it just to work around some sort
of linker issue.

This patch removes the two calls to the function and the function
itself.

Fixes undefined _glthread_GetID symbol in libGL reported by 'nm'.
Though, the missing symbol doesn't cause any issues on my system but
it does cause glxinfo to fail on one of our test systems.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2014-03-05 11:05:48 -07:00
Adam Jackson e166a58c43 glx: Generate fewer errors in MakeContextCurrent
For a few reasons.

1: In the (current) common case, these conditionals are never true. All
we're doing by checking them is slowing down MakeCurrent.  The server
does these checks already anyway.

2: GLX >= 3.0 contexts may legally be made current without a bound
framebuffer.

This does not fix piglit/glx-create-context-current-no-framebuffer, but
is a prerequisite for fixing it.

Cc: "9.1 9.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-10-08 13:24:20 -04:00
Matt Turner 814345f54b build: Use AX_PTHREAD's HAVE_PTHREAD preprocessor definition 2012-10-01 15:23:04 -07:00
Stéphane Marchesin 75be6b76ee glx: Fix compile. 2011-06-20 17:19:00 -07:00
Jeremy Huddleston 4fbdde889c glx: Bind to our context before __glXSetCurrentContext
We want to bind to our context before calling __glXSetCurrentContext or
messing with the gc rect in order to properly handle error conditions.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-20 16:54:58 -07:00
Jeremy Huddleston 517614141b glx: Destroy the old context only after the new one has been bound
This fixes a regression introduced by 49d7e48b33

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-20 16:54:58 -07:00
Stéphane Marchesin bf69ce37f0 glx: implement drawable refcounting.
The current dri context unbind logic will leak drawables until the process
dies (they will then get released by the GEM code). There are two ways to fix
this: either always call driReleaseDrawables every time we unbind a context
(but that costs us round trips to the X server at getbuffers() time) or
implement proper drawable refcounting. This patch implements the latter.

Signed-off-by: Antoine Labour <piman@chromium.org>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2011-06-17 11:20:19 -07:00
Jeremy Huddleston 3b23cf43a4 glx: Remove some GLX_USE_APPLEGL guards around glapi
Now that we're using glapi, we don't need some GLX_USE_APPLEGL ifdef-foo

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-08 12:03:10 -07:00
Jeremy Huddleston 3843bbcb4c glx: Dead code removal
Remove a redundant ifndef GLX_USE_APPLEGL

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-05 20:52:15 -04:00
Jeremy Huddleston 8593bb32ea apple: ifdef out come glapi-foo on darwin
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-05 20:52:14 -04:00
Brian Paul 76a43c5fba glx: fix null pointer deref in __glXGenerateError()
The gc var would be NULL if called from line 238.  Instead, get
the opcode from __glXSetupForCommand(dpy) as done in other places.
And remove the unused gc parameter.

Fixes a bug reported by "John Doe" on 3/9/2011.

NOTE: This is a candidate for the 7.10 branch.
2011-03-10 08:50:52 -07:00
Eric Anholt 49d7e48b33 mesa: Add new MESA_multithread_makecurrent extension.
This extension allows a client to bind one context in multiple threads
simultaneously.  It is then up to the client to manage synchronization of
access to the GL, just as normal multithreaded GL from multiple contexts
requires synchronization management to shared objects.
2011-02-26 12:43:15 -08:00
Kristian Høgsberg 94118fe2d4 glx: Optimize out no-op make current calls
This make a lot more sense now that we might have to recreate the
glx drawables for legacy code paths.
2010-09-09 13:18:43 -04:00
Kristian Høgsberg 659dab6be6 glx: Fix use after free problem 2010-09-08 18:54:48 -04:00
Kristian Høgsberg 16887d042a glx: Drop broken drawable garbage collection
Doesn't work for pixmaps, was looking up the GLX XID and was never thread
safe.  Instead, just destroy the client side structures when the
drawable is no long current for a context.
2010-09-08 09:20:42 -04:00
Kristian Høgsberg 3ea3f5e0a5 glx: Set an all NULL vtable for dummyContext
This reverts 6a6e6d7b0a and initializes
dummyContext with an all NULL vtable.  The context vtable pointer is
supposed to always be non-NULL, but the vtable entries can be NULL.
2010-09-07 14:32:28 -04:00
Kristian Høgsberg f485ee724d glx: Compare old ctx against dummyCtx, not NULL
https://bugs.freedesktop.org/show_bug.cgi?id=29302
2010-07-29 18:49:10 -04:00
Kristian Høgsberg 6849916170 glx: Split indirect and applegl implementations into different files 2010-07-28 16:45:25 -04:00
Kristian Høgsberg c491e585e4 glx: Move bind and unbind to context vtable 2010-07-28 16:45:25 -04:00
Kristian Høgsberg c356f5867f glx: Rename __GLXcontext and __GLXdisplayPrivate to struct types. 2010-07-28 16:45:25 -04:00
Kristian Høgsberg 66fc35cde9 glx: Rename __GLXscreenConfigs to struct glx_screen
Because double underscores in private type names is painful.
2010-07-28 16:42:00 -04:00
Kristian Høgsberg 38c51a7653 glx: Use _X_EXPORT instead of our own PUBLIC macro
We're an X client library, so we can use Xfuncproto.h.
2010-07-28 16:42:00 -04:00
Kristian Høgsberg 6ddf66e923 glx: Rename __GLcontextModes to struct glx_config
With this rename, we use 'config' consitently to refer to GLX configurations
instead of the modes/configs/visual mess before.
2010-07-28 16:42:00 -04:00
Kristian Høgsberg c796bb0cc3 glx: Move context destroy to context vtable 2010-07-23 22:05:52 -04:00
Kristian Høgsberg 31819830b6 glx: Allocate the __GLXcontext in the DRI drivers 2010-07-22 22:16:32 -04:00
Kristian Høgsberg e3e8196c02 glx: Move drawHash to display private
The XIDs are display wide so the natural location of the hash is here.
This way we don't have to lookup in each of the screen hashes.
2010-07-19 22:45:51 -04:00
Kristian Høgsberg f972115d33 glx: Add screen privates for dri drivers and moved some fields there
GLXscreenConfigs is badly named and a dumping ground for a lot of stuff.
This patch creates private screen structs for the dri drivers and moves
some of their fields over there.
2010-07-19 22:45:50 -04:00
Jeremy Huddleston 80b280db88 apple: Change ifdefs for DRI to be DRI && !APPLE
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00