Commit Graph

91 Commits

Author SHA1 Message Date
Adam Jackson 768238fdc0 glx: Fix drawable refcounting for naked Windows
driFetchDrawable is only ever called from the MakeCurrent path, which
means it has to handle the case of pre-GLX-1.3 Windows being named as
the drawable. When it finds the drawable in the hash, it increments its
refcount before returning it, so for a GLXWindow it would be 2 on first
return, one from glXCreateWindow and one from glXMakeCurrent. But when
it does not find the drawable and creates one for the naked Window, the
reference count on first return would only be 1. As a result, if this
context was then ever bound to a different drawable, the old Window's
DRI drawable state (like the back buffer) would be destroyed.

Fixes piglit's glx-multi-window-single-context and glx-make-current for
a variety of drivers.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6713
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17479>
2022-07-13 12:25:30 -04:00
Adam Jackson 31b04e420b glx/dri: Fix DRI drawable release at MakeCurrent time
We want to release the drawables of the context we're coming from, but
we were releasing them from the context we're switching to. This is
probably not a big deal normally because both contexts are likely to be
on the same display, which is all that driReleaseDrawables is really
sensitive to. But if the contexts are on different Displays this would
go quite wrong.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17176>
2022-06-27 20:03:26 +00:00
Qiang Yu 1dac5454ea glx: keep native window glx drawable by driconf option
DRI3 window back buffer is a client resource, so it's destroyed
when context switch drawable for native window.

But some application like Abaqus may leave a dirty back buffer
and reuse it when switch back. So add a driconf option for these
kind of app to keep the entire GLX drawable for native window.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14926>
2022-02-22 07:10:40 +00:00
Qiang Yu 4a420c50f2 glx: merge drawable release to the same function
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14926>
2022-02-22 07:10:40 +00:00
Adam Jackson 538356e3e6 glx: Use the new no-error driver interface
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12474>
2022-02-04 18:36:24 +00:00
Qiang Yu c50bdacbda glx: fix regression for drawable type detection
Newer version of XServer supporting GLX_DRAWABLE_TYPE query also
support query with raw X11 window ID besides GLXWindow ID. So we
should not limit the suppported type to GLXPbuffer when query
success.

Otherwise can't start GLX application on newer XServer with:

  libGL error: GLX drawable type is not supported
  libGL error: GLX drawable type is not supported
  X Error of failed request:  GLXBadContext
    Major opcode of failed request:  149 (GLX)
    Minor opcode of failed request:  5 (X_GLXMakeCurrent)
    Serial number of failed request:  35
    Current serial number in output stream:  35

Fixes: 6625c960c5 ("glx: check drawable type before create drawble")

Tested-by: Mike Lothian <mike@fireburn.co.uk>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14120>
2021-12-09 00:52:17 +00:00
Qiang Yu 887f5a6320 glx: add drawable type argument when create drawable
For distinguish different behavior of pixmap and pbuffer
in latter commits.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13750>
2021-12-07 03:26:13 +00:00
Qiang Yu 6625c960c5 glx: check drawable type before create drawble
If glxDrawable is not a X window ID, we can only support
GLXPbuffer now.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13750>
2021-12-07 03:26:13 +00:00
Adam Jackson fee4f7ef43 glx: Simplify context API profile computation
GLX_ARB_create_context_profile has some clever language that sets the
default to core profile but silently degrades back to compat for pre-3.2
GLs. We can just do that, rather than track whether the user specified a
profile.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson a521b502b9 glx/dri: Collect the GLX context attributes in a struct
dri2_convert_glx_attribs had way too many arguments, let's fix that.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson f5d6a1b916 Revert "glx: s/Display */struct glx_display */ over internal API"
This broke texture-from-pixmap in OBS Studio so I must have done
something wrong and also we need better tfp testing.

This reverts commit b02b26b87c.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4718
Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10593>
2021-05-03 15:00:41 -04:00
Adam Jackson b02b26b87c glx: s/Display */struct glx_display */ over internal API
We'd like to avoid __glXInitialize as much as possible since it involves
taking a global lock. This means converting internal APIs to operate as
much as possible in terms of something other than a Display *, since if
that's all you have then you're forced to call __glXInitialize to get to
the glx_display.

The contortions in DRI2 displease me, but DRI2 displeases me, so.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10418>
2021-04-29 20:34:25 +00:00
Tapani Pälli fc40854937 glx: revert "Downgrade sRGB-ful fbconfigs"
This reverts f0861c80 which causes regression on multiple apps that
require a sRGB capable visual.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4690
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10498>
2021-04-28 09:27:13 +00:00
Adam Jackson 01ba8a8d02 glx: Implement GLX_EXT_no_config_context
This is the GLX counterpart to EGL_KHR_no_config_context. Contexts may
now be created without reference to an fbconfig, in which case it is
treated as compatible with any fbconfig (and thus any GLX drawable).

Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8999>
2021-04-23 21:15:19 +00:00
Adam Jackson f3d14e7616 glx: Add and use DebugMessageF convenience macro
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 1cb664c15c glx: s/dri_message/glx_message/
Move this up to the generic glx code, there's nothing DRI-specific about
this and it'll let us clean up some ad-hockery elsewhere.

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 5a613c55eb dri: Try harder to infer the drawable fbconfig if needed
This code would work for GLXWindows but not for bare Windows, which I
guess you could argue is a server bug but which we can fix on the client
side with a little effort. We change __glXGetDrawableAttribute to
additionally return false if we failed to find the requested attribute
(which is safe, all the other callers discard the return value). Then
when inferring the fbconfig, if the attribute wasn't found, we ask for
the window attributes to find the visual ID and use that to find the
fbconfig.

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 b1cb0af596 glx: Remove some #if 0'd DRI config attribute fetch
We've never read any of this out. The transparency stuff we've never
implemented and the shift/mask stuff doesn't vary independently enough
to need to match on.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9992>
2021-04-13 22:58:58 +00:00
Adam Jackson f0861c803e glx: Downgrade sRGB-ful fbconfigs
Again, NVIDIA supports this on every fbconfig, Mesa alternates it on and
off for some reason but only on some drivers, and in particular llvmpipe
doesn't try to create sRGB-ful fbconfigs. Nerf it out of the fbconfig.

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1648>
2021-04-08 21:43:04 +00:00
Adam Jackson 6b93746b56 glx: Downgrade tfp mipmap-capable fbconfigs
Again, NVIDIA does this but Mesa doesn't. Just disable it in the
fbconfig so apps can't try to use it.

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1648>
2021-04-08 21:43:04 +00:00
Adam Jackson 000035222e glx: Downgrade aux-buffer-ful fbconfigs
Mesa's never supported this, but NVIDIA does, on every fbconfig. Just
disable it if we see it.

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1648>
2021-04-08 21:43:04 +00:00
Adam Jackson 8917ca8af5 glx: Don't downgrade the visual caveat from the server
Mesa marks accumful fbconfigs as slow (for no especially good reason,
it's only accum operations that aren't accelerated, and we could fix
that). NVIDIA doesn't. All that mismatching on this attribute can do is
prevent a config from working exactly as well as it possibly can.

Trust the server's opinion here (but warn if you ask for warnings).

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1648>
2021-04-08 21:43:04 +00:00
Adam Jackson 7934b283dd glx: Stop pretending to validate the pbuffer fbconfig attributes
For hardware drivers we've never set this to anything interesting so
there's no benefit to validating it. For drisw we're at the mercy of
whatever the X server sent to us anyway, and it's not like any server is
going to vary two fbconfigs by _just_ these values.

Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1648>
2021-04-08 21:43:04 +00:00
Adam Jackson 63822802ef glx: Handle create_context in terms of create_context_attribs
For the DRI backends we factor this out to a dri_common_create_context
method. Indirect gets the same transformation but doesn't use the common
method since it can't rely on DRI being built.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7660>
2020-12-01 18:40:18 +00:00
Adam Jackson e6e3d8951a glx: Move glXGet{ScreenDriver,DriverConfig} to common code
These no longer reference anything specific to a particular DRI
protocol.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7219>
2020-10-21 10:24:31 -04:00
Adam Jackson 3bb7ebfc75 glx: move __glXGetUST into the DRI1 code
This is only used from the __DRI_SYSTEM_TIME loader extension, which
only the DRI1 drivers ever looked for.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7219>
2020-10-21 10:24:31 -04:00
Adam Jackson a14e3b43be Revert "glx: Implement GLX_EXT_no_config_context"
This reverts commit 0d635ccc91.

Gitlab: https://gitlab.freedesktop.org/mesa/mesa/issues/1207
2019-09-26 11:07:13 -04:00
Adam Jackson 0d635ccc91 glx: Implement GLX_EXT_no_config_context
This is the GLX counterpart to EGL_KHR_no_config_context. Contexts may
now be created without reference to an fbconfig, in which case it is
treated as compatible with any fbconfig (and thus any GLX drawable).

Khronos: https://github.com/KhronosGroup/OpenGL-Registry/pull/102
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2019-09-23 20:39:01 -04:00
Kevin Strasser d4a9010338 glx: Add fields for color shifts
glx doesn't read the masks from the dri config directly, but for consistency
add shifts to the glxconfig.

Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2019-08-21 18:36:57 +00:00
Eric Engestrom e7e3fd5c03 glx: drop unnecessary pointer deref for function calls
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-08-04 11:26:20 +01:00
Grigori Goronzy acfd88204e glx: add support for GLX_ARB_create_context_no_error (v3)
v2: Only reject no-error contexts for too-old GL if we're actually
trying to create a no-error context (Adam Jackson)
v3: Fix share contexts (Adam Jackson)

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-03-12 19:12:21 -04:00
Eric Anholt d971a4230d loader: Factor out the common driver opening logic from each loader.
I copied the code from egl_dri2.c, but the functionality was equivalent
between all the loaders other than their particular environment variables.

v2: Drop the logging function equivalent to loader_default_logger()
    (requested by Eric, Emil).  Move the SCons workaround across.  Drop
    the now-unused driGetDriverExtensions() declaration that was lost in a
    rebase.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> (v1)
Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v1)
2018-11-16 17:49:17 -08:00
Eric Anholt c2b515379b glx: Move DRI extensions pointer loading to driOpenDriver().
The only thing you do with a dri driver handle is get the extensions
pointer, so just fold it in to simplify the callers.

v2: Add the declaration of driGetDriverExtensions() that got lost in a
    rebase.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> (v1)
Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v1)
2018-11-16 15:38:18 -08:00
Eric Anholt 7076e9f116 glx: Remove an old DEFAULT_DRIVER_DIR default.
You can tell by "Mesa/configs/default" how old this is.  Your build system
really has to provide the DEFAULT_DRIVER_DIR, or other loaders will break.

v2: Move the bad (non-prefix-dependent) define to the SConscript to avoid
    breaking it.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> (v1)
Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v1)
2018-11-16 15:37:47 -08:00
Adam Jackson a48a6b8a40 glx: Prepare driFetchDrawable for no-config contexts
When we look up the DRI drawable state we need to associate an fbconfig
with the drawable. With GLX_EXT_no_config_context we can no longer infer
that from the context and must instead query the server.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2017-12-01 15:53:52 -05:00
Neil Roberts ba7679f48d glx: Implement GLX_ARB_context_flush_control
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
2017-11-06 16:09:02 -05:00
Thomas Hellstrom 2437ebd705 dri: Introduce SWAP_METHOD tokens
We shouldn't be using GLX tokens in the dri subsystem, so define dri
SWAP_METHOD tokens and translate when necessary. Unfortunately the X server
uses the dri swap method value untranslated as the GLX fbconfig swapMethod,
so we can't enumerate these tokens arbitrarily, but rather need to make them
have the same values as the corresponding GLX tokens.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-08-10 09:15:33 +02:00
Thomas Hellstrom 48bd91785a glx: Fix swap method config matching
Due to bugs in dri swap method reporting, neither the fbconfigs received from
the server nor the value reported from driconfigs were correct. Now that's been
fixed and we can enable config swapmethod matching again.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-08-10 09:15:33 +02:00
Christian Gmeiner 0c73a3b7d0 dri: make use of loader_get_extensions_name(..) helper
Changes since v1:
 - removed not needed includes
 - use the loader version of the helper

v2 [Emil Velikov]
 - Keep the includes - they are required.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15 18:15:16 +00:00
Emil Velikov fb10c89877 Revert "dri: make use of dri_get_extensions_name(..) helper"
This reverts commit 1a21d21580.

Pushed the wrong version of the patch.
2016-11-15 18:15:15 +00:00
Christian Gmeiner 1a21d21580 dri: make use of dri_get_extensions_name(..) helper
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15 15:56:52 +00:00
Ilia Mirkin 5ac7f0433b glx: update to updated version of EXT_create_context_es2_profile
The EXT spec has been updated to:
 - logically combine the es2_profile and es_profile exts
 - allow any legal version to be requested

dEQP tests request a specific ES version when using GLX, so this allows
dEQP upstream to run against GLX with the appropriate X server patch
(which had similar disabling logic).

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Adam Jackson <ajax@redhat.com> (v3)

v1 -> v2:
 - distinguish between DRI_API_GLES{,2,3}
 - add GLX_EXT_create_context_es_profile client-side support
v2 -> v3:
 - fix error in computing mask
2016-02-03 15:44:51 -05:00
Kyle Brenneman d35391cfda glx: Don't hard-code the name "libGL.so.1" in driOpenDriver (v3)
Add a macro GL_LIB_NAME to hold the filename that configure comes up with
based on the --with-gl-lib-name and --enable-mangling options.

In driOpenDriver, use the GL_LIB_NAME macro instead of hard-coding
"libGL.so.1".

v2: Add an #ifndef/#define for GL_LIB_NAME so that non-autoconf builds will
    work.
v3: Fix the library filename in the Makefile.

Signed-off-by: Kyle Brenneman <kbrenneman@nvidia.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
2015-10-02 13:25:05 +01:00
Rhys Kidd dc7a1effc4 mesa/glx: Resolve GCC sign-compare warning.
mesa/src/glx/dri_common.c: In function 'scalarEqual':
mesa/src/glx/dri_common.c:259:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (i = 0; i < ARRAY_SIZE(attribMap); i++)
                  ^

Signed-off-by: Rhys Kidd <rhyskidd@gmail.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
2015-08-18 11:34:43 -07:00
Marek Olšák a6f39ec1c5 Revert "Match swrast modes more loosely."
This reverts commit f3728a16c9.

It broke glxgears on radeonsi. The window was just black.
2015-07-23 21:53:06 +02:00
Tom Hughes f3728a16c9 Match swrast modes more loosely.
https://bugs.freedesktop.org/show_bug.cgi?id=90817

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-07-23 15:57:53 +01:00
Courtney Goeltzenleuchter 0406f59eeb mesa: glx: Reduce error log level
The code that parses LIBGL_DRIVERS_PATH was printing an
error for every attempted dlopen. It's not an error to
have to check multiple items in the path, only an error if
no suitable library is found. Reduced the load error to
a warning to match behavior of dynamic linker.

Signed-off-by: Courtney Goeltzenleuchter <courtney@LunarG.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-06-12 10:19:00 -06:00
Marek Olšák 0d5ec2c615 Revert "glx: load dri driver with RTLD_LOCAL so dlclose never fails to unload"
This reverts commit e3cc0d90e1.

It breaks too many apps and completely breaks my desktop too.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79469

We'll probably need to re-release all stable versions after this is committed.

Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
2014-06-02 12:56:12 +02:00
Jerome Glisse e3cc0d90e1 glx: load dri driver with RTLD_LOCAL so dlclose never fails to unload
There is no reason anymore to load with RTLD_GLOBAL and for some driver
this even result in dlclose failing to unload leading to catastrophic
failure with swrast fallback.

Cc: "10.1 10.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
2014-05-29 13:32:21 -04:00
Emil Velikov ef342aad80 glx/dri_common: use the implemented version of __DRIsystemTimeExtension
... over the one provided by the headers.
Explicitly set extension members to improve clarity.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-02-23 16:42:17 +00:00