Commit Graph

1654 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
Yonggang Luo 9caa6bb71a glx: Convert tab to space in applegl_glx.c
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17784>
2022-07-29 12:57:26 +00:00
Yonggang Luo 7d35d560ac glx: __glX_tls_Context should use __THREAD_INITIAL_EXEC
Error message on OSX:
../src/glx/tests/fake_glx_screen.cpp:101:20: error: thread-local declaration of '__glX_tls_Context' with dynamic initialization follows declaration with static initialization
thread_local void *__glX_tls_Context = &dummyContext;
                   ^
../src/glx/glxclient.h:655:36: note: previous declaration is here
extern __THREAD_INITIAL_EXEC void *__glX_tls_Context;

Fixes: be00a7c8ac ("glx: using C++11 keyword thread_local")

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17784>
2022-07-29 12:57:26 +00:00
jheaff1 2e71e23188 build(glx): Fix build by adding missing deps
dri3_glx.c includes xshmfence and glxcmds.c includes xf86vm, neither of
which are listed as dependencies of the glx lib in the meson.build file.
Consequently, those files would fail to compile on machines that did not
have xshmfence and xf86vm installed globally. This commit rectifies the
issue by adding the missing dependencies

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17585>
2022-07-18 21:12:26 +00:00
Adam Jackson c123ab2137 kopper: Implement {EGL,GLX}_EXT_buffer_age
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17527>
2022-07-18 19:31:29 +00:00
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
Emma Anholt 679e9697a9 kopper: Respect the vblank_mode env var.
We were defaulting to a swap interval of 1, but we can follow dri2/dri3's
lead and respect the driconf var.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17470>
2022-07-12 21:57:23 +00:00
Emma Anholt ff18be0872 glx: Unify dri2/dri3 vblank_mode logic.
We need it from kopper, as well.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17470>
2022-07-12 21:57:23 +00:00
Emma Anholt f3d3368065 kopper: Fix the return value of kopperSetSwapInterval().
Compare to dri2SetSwapInterval() and dri3_set_swap_interval()
implementations of the same method.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17470>
2022-07-12 21:57:23 +00:00
Adam Jackson 82fea22607 glx: Fix return values from __glXGetDrawableAttribute
This is intended to return true on attribute-found.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17422>
2022-07-12 18:43:24 +00:00
Adam Jackson 11c30fcad0 glx/dri2: Stop tracking the protocol version in the display state
We only use it at init time, no need to keep it around.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17422>
2022-07-12 18:43:24 +00:00
Adam Jackson 1255d370b7 glx: Remove excess screen parameter from CreateContext
This is effectively looked up from the config anyway, which we're
already passing in.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17422>
2022-07-12 18:43:24 +00:00
Adam Jackson 215200d8f1 glx: Remove unused __glXSetupForCommand from __glXIsDirect
This was needed when we emitted an xlib request here, but xcb knows the
GLX major opcode for the connection already.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17422>
2022-07-12 18:43:24 +00:00
Adam Jackson 61834ae898 glx: Remove some can't-happen checks from protocolDestroyDrawable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17422>
2022-07-12 18:43:24 +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
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
Dave Airlie 68e8940114 glx/drisw: use xcb instead of X to query connection
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17155>
2022-06-22 03:28:21 +00:00
Mike Blumenkrantz ea005c9e04 glx/drisw: invalidate drawables upon binding context if flush extension exists
this forces surface resize as expected

cc: mesa-stable

fixes #6706

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17147>
2022-06-22 02:18:37 +00:00
Mike Blumenkrantz 23b63e536e glx/drisw: store the flush extension to the screen
cc: mesa-stable

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17147>
2022-06-22 02:18:37 +00:00
Yonggang Luo be00a7c8ac glx: using C++11 keyword thread_local
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
2022-06-15 17:37:16 +00:00
Adam Jackson 4d0179af32 glx/dri2: Require DRI2 >= 1.3 for working buffer invalidation
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10808>
2022-05-17 20:31:50 +00:00
Pierre-Eric Pelloux-Prayer 8779a5b84c glx: set max values for pbuffer width / height
Without this change the values are always 0. This breaks
Maya which uses this value to create a pbuffer (and then
fails).

This commit is based on b91e1e38e8 which does the same
for EGL.

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16496>
2022-05-17 07:21:34 +00:00
Adam Jackson b6ea787903 glx/kopper: Enable GLX_EXT_swap_control etc.
This requires newly tracking the max swap interval since kopper can't do
abs(interval) > 1 yet.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15800>
2022-05-04 15:06:51 +00:00
Adam Jackson c865416f44 glx/kopper: Wire up a way for SwapBuffers to fail
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16038>
2022-04-27 21:50:16 +00:00
Adam Jackson bab8d97ea9 glx: Learn about kopper
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14541>
2022-04-07 00:17:40 +00:00
Yonggang Luo 24bc6c51e1 glx/egl: improve dri null screen related error messages.
Convert from `failed to create dri screen` to more exact error message
for easier debugging

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15480>
2022-03-21 09:31:31 +00:00
Eric Engestrom 5dbbc0f0a8 Revert "glx: Fix build errors with --enable-mangling (v2)"
This reverts commit a27f2d991b.

As of a0829cf23b ("GL: drop symbols mangling support"), this
extra complexity isn't needed anymore.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2298>
2022-03-14 22:14:25 +00:00
Mike Blumenkrantz 95708c13ee glx/drisw: handle GL_RESET_NOTIFICATION_STRATEGY
fixes (llvmpipe):
KHR-NoContext.gl45.robustness.lose_context_on_reset

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15061>
2022-02-28 16:10:00 +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
Qiang Yu bf09c08e31 glx: fix pbuffer refcount init
glXMakeCurrent* may miss release pbuffer if pbuffer is created
with refcount=0. This won't happen when pbuffer had different
GLX id and X pixmap id.

cc: mesa-stable

Fixes: bc8a51a79a ("glx: no need to create extra pixmap for pbuffer")

Acked-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
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
Thomas H.P. Andersen 2a5b867594 glx: remove a set but not used variable
total_sent was never used. It was introduced in
fdb07636f2

Fixes a warning in clang

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14252>
2021-12-22 17:02:00 +00:00
Adam Jackson c77e5af7a3 glx: Fix GLX_NV_float_buffer fbconfig handling
Since we didn't record this attribute from the server, we wouldn't
account for it in glXChooseFBConfig, and glXGetFBConfigAttrib wouldn't
know about it.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14221>
2021-12-16 22:05:20 +00:00
Pierre-Eric Pelloux-Prayer 1cb5c1775b glx: fix querying GLX_FBCONFIG_ID for Window
This commit fixes apps using the following sequence:
1. XCreateWindow(dpy) -> win
2. glXCreateContextAttribsARB(dpy, ...) -> ctx
3. glXMakeCurrent(dpy, win, ctx)
4. glXQueryDrawable(dpy, win, GLX_FBCONFIG_ID, ...)

glXQueryDrawable returned 0 (while correctly returning a valid
GLXFCONFIG_ID for other types of drawables).

This commit adds the same dance as driInferDrawableConfig to get
the GLX visual from the Window, and then the GLXFBCONFIG_ID of
this visual.

This fixes:
* piglit: glx-query-drawable --attr=GLX_FBCONFIG_ID --type=WINDOW
* Maya which uses the config ID from step 4 as an input to
glXChooseFBConfig.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14174>
2021-12-16 01:21:36 +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
Adam Jackson b713fca495 glapi: Remove remnants of EXT_paletted_texture and the imaging subset
The GLX code had to special case these for uninteresting reasons, but we
don't support them anymore in Mesa so all this would do is keep them
sorta-working over GLX protocol. Given that Mesa hasn't supported them
on the renderer side since ~2011 let's stop pretending they're real. If
we get around to modernizing the indirect GLX code (hah) we can revisit
these then.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14085>
2021-12-08 03:42:44 +00:00
Qiang Yu 13bf30583c loader/dri3: add drawable type set by GLX and EGL
Drawable type include more information which can be used
to distinguish pixmap and pbuffer which both treated as
pixmap before.

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 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
Qiang Yu bc8a51a79a glx: no need to create extra pixmap for pbuffer
XServer already created a pixmap with same id as pbuffer,
so that other client can use the pbuffer id to do
glXMakeCurrent(). But with a hidden pixmap, we can't do
this.

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 cee1dd92bd glx/dri3: fix glXQueryContext does not return GLX_RENDER_TYPE value
Cc: mesa-stable
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
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/13772>
2021-11-19 01:37:27 +00:00
Marek Olšák 83278b5661 glx: add a workaround to glXDestroyWindow for Viewperf2020/Sw
This fixes:
    X Error of failed request:  GLXBadWindow
      Major opcode of failed request:  152 (GLX)
      Minor opcode of failed request:  32 (X_GLXDestroyWindow)
      Serial number of failed request:  9667
      Current serial number in output stream:  9674

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13611>
2021-11-17 21:26:54 +00:00
Pierre-Eric Pelloux-Prayer fc3ef76eec glx/drirc: add a force_direct_glx_context option
Some applications may request an indirect context but this feature is
disabled by default on Xorg and thus context creation will fail.

This commit adds a drirc setting to force the creation of direct glx
context, regardless of what the app is requesting.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13246>
2021-11-04 13:59:00 +01:00
Dylan Baker e73096bd6d meson: use gtest protocol for gtest based tests when possible
With the `gtest` protocol meson will add some extra arguments to the
test to generate better junit results, which may be useful. This
protocol is only available in meson 0.55.0+, so keep using the default
`exitcode` protocol for meson older than that.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8484>
2021-10-16 03:22:24 +00:00
Pierre-Eric Pelloux-Prayer e67083caf4 gallium: add PIPE_CAP_PREFER_BACK_BUFFER_REUSE
This will be used in the next commit.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12788>
2021-09-29 08:14:57 +00:00
Adam Jackson ecc6d78b05 glx: Don't strip off window/pixmap support from float fbconfigs
The X server doesn't get this wrong. It's not the client's job to
correct what the server says here. And if anyone ever implements HDR for
X11, you might in fact want to be able to use floats with a window.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13002>
2021-09-27 09:36:51 -04:00
Adam Jackson 71d8ac2bf8 glx: Clarify a debug message
In GLX a "tag" usually means a context tag, "fbconfig attribute" is a
bit more obvious.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13002>
2021-09-27 09:36:47 -04:00
Adam Jackson aec9bf7319 glx: Move __glFreeAttributeState next to its one caller
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13002>
2021-09-27 09:36:44 -04:00