Commit Graph

1639 Commits

Author SHA1 Message Date
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
Adam Jackson f33d61cecb glx: Remove some unused declarations from glxclient.h
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:13 -04:00
Corentin Noël d326d32e24 glx: Prevent crashes when an extension isn't found
Avoid a NULL-pointer dereference.

Fixes: 2c8a85b712 ("glx: Stash a copy of the XExtCodes in the glx_display")
Signed-off-by: Corentin Noël <corentin.noel@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12751>
2021-09-08 11:46:51 +00:00
Vinson Lee 498d93f3dd glx: Fix unused-variable warning with macOS build.
../src/glx/tests/indirect_api.cpp:52:20: warning: unused variable 'nil' [-Wunused-variable]
static const void *nil = 0;
                   ^

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12607>
2021-09-01 09:03:53 +00:00
Sergii Melikhov 71e748ad24 dri2: Fix Null pointer dereferences
Fix defect reported by Coverity Scan CID-1490794

Fixes: 0d42033b26 ("glx/dri2: Require the driver to support v4 of __DRI_DRI2")
Signed-off-by: Sergii Melikhov <sergii.v.melikhov@globallogic.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12563>
2021-08-26 17:09:23 +03: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 2cd0991def glx/drisw: Remove some misplaced error checks
If the driver doesn't like these attributes it can reject them, it's not
libGL's job to verify them here.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson 0d42033b26 glx/dri2: Require the driver to support v4 of __DRI_DRI2
Mesa has supported this unconditionally since 10.1.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson bfad9e75c0 glx: Store the context vtable on the glx screen
Again this is rewriting part of driX_create_context_attribs to be
caller-agnostic, so that we can eventually unify it among the DRI
backends.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson 145992890c glx: Fix and simplify the share context compatibility check
We only end up with one DRI provider per screen, so the only way the
context vtable can differ is if they're not the same directness. Rewrite
the test in those terms to help us unify some of this code away in the
future. Also apply the same logic to the indirect context creation path.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12456>
2021-08-18 21:11:02 +00:00
Adam Jackson 34342cce89 glx/drisw: Nerf PutImage when loaderPrivate == NULL
This means the drawable was already destroyed. This can happen during
diplay teardown, destroying the context will make it current first so it
can flush rendering and destroy textures and such, and if the drawable
is already destroyed then flushing to nowhere would crash.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11423>
2021-07-15 15:10:17 +00:00
Yogesh Mohanmarimuthu 55d1b8f929 glx: create DRI screen for display GPU incase of prime
The created DRI screen can be used to allocate VRAM memory from
display GPU in case of prime.

v2: add comments to make code readable (Pierre-Eric)
    remove driver name match check
v3: keep old path for non-mesa driver (Michel Dänzer)
v4: fallback if driver not found for display GPU (Michel Dänzer)
    fallback if create screen fail for display gpu (Michel Dänzer)

Signed-off-by: Yogesh Mohanmarimuthu <yogesh.mohanmarimuthu@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10595>
2021-06-03 09:12:32 +00:00
Yogesh Mohanmarimuthu dac2c210d6 glx: Keep display fd open for prime
Keep the display fd open for creating DRI screen on display gpu in
case of prime.

v2: initialize psc->fd_display_gpu early (Michel Dänzer)
    fix display gpu fd leakage (Michel Dänzer)
v3: fix more display gpu fd leakage (Michel Dänzer)

Signed-off-by: Yogesh Mohanmarimuthu <yogesh.mohanmarimuthu@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10595>
2021-06-03 09:12: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 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