Commit Graph

101 Commits

Author SHA1 Message Date
Manuel Stoeckl 19f62b4303 dri: add [ax]bgr16161616 to format lookup tables
Note: The format __DRI_IMAGE_FORMAT_ABGR16161616 was already
in the dri2_format_table, but had been hidden from outside view,
for lack of an official DRM fourcc. Since its fourcc has now been
assigned, it is safe to reveal the format.

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14580>
2022-07-27 07:27:10 +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
Pierre-Eric Pelloux-Prayer 42c149e36b gallium/dri: add missing PIPE_BIND_DRI_PRIME handling
e9c3dbd046 added PIPE_BIND_DRI_PRIME but it was only set when
importing a prime buffer.

This commit adds handling of this flag in the other codepath = the
one where the prime buffer is allocated by the render GPU.

With this change PIPE_BIND_DRI_PRIME is still only set for the
render GPU - the display GPU will never see this flag; a future
commit will rename it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14615>
2022-02-08 00:13:07 +00:00
Qiang Yu df6ff88fd0 loader/dri3: support glx pbuffer swap
Double buffered pbuffer need to update the front buffer,
otherwise we always get wrong value when glReadPixels().

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 e0311746cd loader/dri3: stop doing anything in swap buffer for some drawable
We are sure to have a back buffer in swap buffer now.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Singed-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 d67d1dddbe loader/dri3: rename dri3_fake_front_buffer
Sometimes this is the real front buffer depends on the place
called. Since it's the same LOADER_DRI3_FRONT_ID slot, just
name it dri3_front_buffer.

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 c7d5e91b6b loader/dri3: replace is_pixmap with drawable type
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 d19013a199 loader/dri3: setup present event with drawable type info
If we already know the drawable type, setup event in a simpler way.

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 6508e5b4a1 loader/dri3: pack window present event setup into a function
For simplicity and 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 9faa2892b9 loader/dri3: remove unused present capability query
The query result is not used anywhere.

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 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 24aa03e9e8 loader/dri3: fix piglit egl-copy-buffer test
In the test no front buffer has been allocated on the client
side, so we get a segfault when access it directly.

eglCopyBuffers() just need to do server side copy, so we don't
really need to create a client side front buffer to perform
the copy.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
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/13868>
2021-11-30 01:58:42 +00:00
Pierre-Eric Pelloux-Prayer e9c3dbd046 gallium/dri: let the driver know if the imported image is DRI_PRIME buffer
Use createImageFromFds2 together with __DRI_IMAGE_PRIME_LINEAR_BUFFER, so
the driver's resource_from_handle hook will be aware that this specific
image is the linear buffer.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13362>
2021-10-18 16:24:00 +02:00
Qiang Yu e55e61758c loader/dri3: fix swap out of order when changing swap interval
This fixes SPECVIEWPERF13 creo test case hang:
  1. Client: send present pixmap request (serial=1) when swap_interval==1
     and increase send_sbc=1
  2. Server: pend the request before vblank arrives
  3. Client: set swap_interval=0 (so set XCB_PRESENT_OPTION_ASYNC),
     send another present pixmap request (serial=2), increase send_sbc=2
  4. Server: handle the async request immediately and send complete event
     (serial=2)
  5. Client: handle the event and set recv_sbc=event->serial=2
  6. Server: vblank arrives so handle pending request and send complete
     event (serial=1)
  7. Client: handle the event and set recv_sbc=event->serial=1
  8. Client: someone call loader_dri3_swapbuffer_barrier() and waiting
     on recv_sbc==send_sbc, but no one will set recv_sbc=2 again

So basically it's caused by swap happens out of order. This commit
fixes the problem by waiting on the pending sync swaps all done when
switching to async mode, so move 6&7 before 3.

Attach the xtrace when problem happens:

  005:<:003e: 72: Present-Request(148,1): Pixmap window=0x03000002 pixmap=0x0300000b serial=1 valid=0x00000000 update=0x00000000 x_off=0 y_off=0 target_crtc=0x00000000 wait_fence=0x00000000 idle_fence=0x0300000c options=0 target_msc=4294967296 divisor=0 remainder=0 notifies=;
  ...
  005:<:0041: 72: Present-Request(148,1): Pixmap window=0x03000002 pixmap=0x03000011 serial=2 valid=0x00000000 update=0x00000000 x_off=0 y_off=0 target_crtc=0x00000000 wait_fence=0x00000000 idle_fence=0x03000012 options=Async target_msc=0 divisor=0 remainder=0 notifies=;
  005:>:0041: Event Generic(35) Present(148) IdleNotify(2) event=0x03000006 window=0x03000002 serial=2 pixmap=0x03000011 idle_fence=0x03000012
  005:>:0041: Event Generic(35) Present(148) CompleteNotify(1) kind=Pixmap(0x00) mode=Copy(0x00) event=0x03000006 window=0x03000002 serial=2 ust=7505462213117739011 msc=3565046193979392
  005:>:0041: Event Generic(35) Present(148) IdleNotify(2) event=0x03000006 window=0x03000002 serial=1 pixmap=0x0300000b idle_fence=0x0300000c
  005:>:0041: Event Generic(35) Present(148) CompleteNotify(1) kind=Pixmap(0x00) mode=Copy(0x00) event=0x03000006 window=0x03000002 serial=1 ust=7505533793042694147 msc=3565050488946688

Cc: mesa-stable
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13019>
2021-09-30 03:27:14 +00:00
Pierre-Eric Pelloux-Prayer 09dc0fb2ee loader/dri3: avoid reusing the same back buffer with DRI_PRIME
For DRI_PRIME setup where the dGPU -> iGPU copy can happen asynchronously,
we need to ensure that we're not continuously reusing the same back buffer.

The existing code relies on XCB_PRESENT_EVENT_IDLE_NOTIFY to decide if
a buffer is busy or idle. If this event is received before the hardware
is done using the buffer, then it will reuse the same buffer and introduce
a dependency between the copy and the next frame.

This commit mitigates this by trying to allocate a different back buffer
when called from dri3_get_buffer (not from dri3_find_back_alloc, because it
seems that it expects dri3_get_buffer - see 0cc4c7e33e).

An alternative would be to query the busy-ness using is_resource_busy
but this complicates the code to achieve the same result.

One affected app is Unigine Superposition, and this change improves the
score by 0% - 5% depending on the settings.

This behavior is enabled if PIPE_CAP_PREFER_BACK_BUFFER_REUSE is 0.

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
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
Lionel Landwerlin f1a66e7c90 loader/dri3: create linear buffer with scanout support
If we have a different GPU dealing with display, we fallback to
exchanging linear buffers with the compositor. We should specify in
creating the linear buffer that this could be used for display.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4706
Cc: mesa-stable
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/11942>
2021-07-28 15:53:36 +00:00
Adam Jackson 7e9424d91b loader/dri3: Don't churn through xfixes regions in SwapBuffers
Regions are not expensive objects on the server side, it's very slightly
cheaper to update an existing one than to create a new one, and we can
garbage collect them when the drawable is destroyed. Worse, XID reuse
bugs exist, so the more we can do to not churn through XIDs the better.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11461>
2021-06-24 03:18:06 +00:00
Adam Jackson 34e4622983 loader/dri3: Properly initialize the XFIXES extension
The server starts off assuming the only XFIXES request the client might
known is FixesQueryVersion, and based on the version number the client
supplies it unlocks additional requests. If you forget to do this then
xcb_xfixes_create_region will throw BadRequest and you will be very
confused. libXfixes would hide this for you in extension setup but xcb
is not so forgiving.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11461>
2021-06-24 03:18:06 +00:00
Yogesh Mohanmarimuthu 0e856b95c5 loader: allocate VRAM in display GPU in case of prime
Allocates VRAM in display GPU in case of prime. Then the dma_buf is imported
into prime GPU.

v2: add comments to make code more readable (Pierre-Eric)
    removed if check limiting p2p only for matching driver name
v3: keep old path for non mesa driver (Michel Dänzer)
v4: destroy linear_buffer_display_gpu after import (Michel Dänzer)
    fall back if linear_buffer_display_gpu alloc fail (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
Lucas Stach 8fd5b16efc loader/dri3: convert to loader_dri_create_image
Get rid of the code duplication and makes it easier to hook in a
new createImageWithModifiers2, but obscures the code flow a bit.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
2021-05-19 16:54:19 +00:00
Adam Jackson 36ea1758fd loader: Silence a warning at -Og
../src/loader/loader_dri3_helper.c: In function ‘dri3_free_buffers’:
   ../src/loader/loader_dri3_helper.c:2022:46: warning: ‘n_id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    2022 |    for (buf_id = first_id; buf_id < first_id + n_id; buf_id++) {

Can't happen, mark it unreachable.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8724>
2021-02-18 20:59:43 +00:00
Pierre-Eric Pelloux-Prayer bd182777c8 egl: implement EGL_EXT_protected_surface support
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5096>
2020-11-02 10:15:47 +01:00
Michel Dänzer 31e9de9c8a loader/dri3: Allocate up to 4 back buffers for page flips
With swap interval 0, i.e. sync-to-vblank disabled.

This can be necessary for unthrottled drawing with Xwayland:

1) One buffer can be scanned out
2) One buffer can be pending in the kernel for a page flip
3) One buffer can be pending in the Wayland compositor

Therefore, with 3 buffers, the frame-rate could be capped much lower
than the throughput the GPU is capable of, in the worst case at the
Wayland compositor refresh rate.

(The native Wayland EGL backend always uses up to 4 buffers)

Leave the maximum number of buffers at 3 for swap interval != 0, it's
sufficient in that case to always be able to queue one frame ahead of
time.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1455
https://gitlab.gnome.org/GNOME/mutter/-/issues/1462

Cc: mesa-stable
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7033>
2020-10-22 15:52:33 +00:00
Michel Dänzer 16a7cc4d44 loader/dri3: Keep current number of back buffers if frame was skipped
We'd previously take the copy path. If we were actually flipping (in
which case skipped frames are more likely to occur), we'd ping-pong
between a smaller and larger number of back buffers, and frame-rate
could vary / take a dip due to the buffer management overhead.

While I'm not sure this is actually possible to hit at this point, it
definitely will be with the next change.

Cc: mesa-stable
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7033>
2020-10-22 15:52:33 +00:00
Michel Dänzer 60585fc4e3 loader/dri3: Only allocate additional buffers if needed
Previously, we would always allocate 3 buffers for page flipping. But 2
buffers can suffice for clients which always wait for buffer swaps to
complete before starting a new frame.

Therefore, keep track of the maximum number of buffers separately from
the current number, and only bump the latter if both current buffers are
busy.

Cc: mesa-stable
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7033>
2020-10-22 15:52:33 +00:00
Adam Jackson 5e9e457383 glx/dri3: Implement GLX_EXT_swap_control_tear
Not wired up for DRI2 because it would require server-side support,
which I'm not especially interested in writing.

Fixes: mesa/mesa#96
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6671>
2020-09-10 14:48:19 -04:00
Eric Engestrom 326eb56718 egl/x11_dri3: implement EGL_KHR_swap_buffers_with_damage
Passes all of `dEQP-EGL.functional.swap_buffers_with_damage.*`:

    Passed:        36/54 (66.7%)
    Failed:        0/54 (0.0%)
    Not supported: 18/54 (33.3%)
    Warnings:      0/54 (0.0%)
    Waived:        0/54 (0.0%)

The "not supported" ones are the `preserve_buffer_*` tests, which is not
supported on X11/DRI3.

Cc: 20.2 <mesa-stable>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3030
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6132>
2020-08-19 12:47:58 +00:00
Michel Dänzer 31392f8371 Revert "loader/dri3: Check for window destruction in dri3_wait_for_event_locked"
This reverts commit d7d7687829.

It caused freezes with e.g. kwin_x11 due to hitting the 1s timeout.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3214
Reopens: https://gitlab.freedesktop.org/mesa/mesa/-/issues/116
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5722>
2020-07-03 09:55:50 +00:00
Michel Dänzer d7d7687829 loader/dri3: Check for window destruction in dri3_wait_for_event_locked
If the underlying X11 window gets destroyed, the event we're waiting
for may never be delivered, in which case xcb_wait_for_special_event
would hang indefinitely.

Solution:

1. Use xcb_poll_for_special_event to check if an event has arrived yet.
2. If not, Wait up to ~1s for XCB's file descriptor to become readable;
   if it does, go back to step 1.
3. If the file descriptor didn't become readable, make a round-trip to
   the X server to check that the window still exists. Go back to step
   1 if it does, otherwise bail.

Also add an early bail-out when it's known that the window was
destroyed.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/116
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5368>
2020-06-29 17:05:52 +00:00
Michel Dänzer 7c226116c6 loader/dri3: Use dri3_wait_for_event_locked in loader_dri3_wait_for_msc
Before, if one thread ended up waiting in dri3_wait_for_event_locked
and another one in loader_dri3_wait_for_msc at the same time, one thread
could end up processing an event the other thread was waiting for, which
could result in the latter thread waiting longer than necessary
(possibly indefinitely).

Noticed by inspection.

v2:
* Drop xcb_flush call from loader_dri3_wait_for_msc in favour of the one
  in dri3_wait_for_event_locked (Kenneth Graunke)

Fixes: 7b0e8264dd "loader/dri3: Try to make sure we only process our
                     own NotifyMSC events"

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5368>
2020-06-29 17:05:52 +00:00
Michel Dänzer ee77951714 loader/dri3: Add dri3_wait_for_event_locked full_sequence out parameter
Preparation for the next commit, no functional change intended.

Cc: mesa-stable
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5368>
2020-06-29 17:05:52 +00:00
Eric Engestrom 04e8eaf4e8 util: rename xmlpool.h to driconf.h
To make it clearer what it is and does.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5440>
2020-06-22 21:50:12 +00:00
Eric Engestrom 2ef983dca6 driconf: drop now unused translation facility
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5440>
2020-06-22 21:50:12 +00:00
Lionel Landwerlin fc2552b644 loader: fix close on uninitialized file descriptor value
Using a drm syscall layer faking a kernel driver :

  ==581460== Conditional jump or move depends on uninitialised value(s)
  ==581460==    by 0x48A4C2B: close (drm-hooks.cpp:185)
  ==581460==    by 0x5A815F1: dri3_alloc_render_buffer (loader_dri3_helper.c:1469)
  ==581460==    by 0x5A82050: dri3_get_buffer (loader_dri3_helper.c:1827)
  ==581460==    by 0x5A82662: loader_dri3_get_buffers (loader_dri3_helper.c:2028)
  ==581460==    by 0x6C78109: intel_update_image_buffers (brw_context.c:1870)
  ==581460==    by 0x6C77805: intel_update_renderbuffers (brw_context.c:1499)
  ==581460==    by 0x6C7789D: intel_prepare_render (brw_context.c:1520)
  ==581460==    by 0x6C773D4: intelMakeCurrent (brw_context.c:1341)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 069fdd5f9f ("egl/x11: Support DRI3 v1.1")
Reviewed-by: Eric Anholt <eric@anholt.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3152>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3152>
2019-12-19 00:51:36 +02:00
Tapani Pälli 8b6b5ce669 dri: add __DRI_IMAGE_FORMAT_SXRGB8
Add format definition and required plumbing to create images.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3077>
2019-12-17 09:28:25 +00:00
Kenneth Graunke 396b410959 dri: Avoid swapbuffer throttling in glXCopySubBufferMESA
We were supplying __DRI2_THROTTLE_SWAPBUFFER, rather than the obvious
choice of __DRI2_THROTTLE_COPYSUBBUFFER.  This meant that we hit the
swap-based frame throttling.  glXCopySubBuffer doesn't seem like it's
intended to be a frame boundary, so we'd like to avoid this throttling.

Tested-by: Michel Dänzer <mdaenzer@redhat.com> # DRI3 only
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-10-05 13:19:37 +00:00
Michel Dänzer b012f06d66 dri3: Pass __DRI2_THROTTLE_COPYSUBBUFFER from loader_dri3_copy_drawable
0 is __DRI2_THROTTLE_SWAPBUFFER, which doesn't really make sense here.

Avoids dri_flush() throttling twice for the same glFlush call with front
buffer rendering, as described in
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2057 .

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2019-10-04 10:55:43 +02:00
Erik Faye-Lund 0103d4747a loader/dri3: do not blit outside old/new buffers
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-10-03 18:58:34 +00:00
Eric Anholt 272f9cfe6a dri: Use DRM_FORMAT_* instead of defining our own copy.
We have only two defines that aren't from DRM_FORMAT_*: SARGB and
SABGR.  Keep only those as __DRI_IMAGE_FOURCC and garbage collect the
rest.

While this header is also used from the X server, the X server doesn't
use any __DRI_IMAGE enums.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
2019-09-11 13:05:10 -07:00
Kevin Strasser a427c20080 dri: Add fp16 formats
Add dri formats for RGBA ordered 64 bpp IEEE 754 half precision floating
point. Leverage existing offscreen render support for
MESA_FORMAT_RGBA_FLOAT16 and MESA_FORMAT_RGBX_FLOAT16.

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.velikov@collabora.com>
2019-08-21 18:36:57 +00:00
Eric Engestrom f1374805a8 drm-uapi: use local files, not system libdrm
There was an issue recently caused by the system header being included
by mistake, so let's just get rid of this include path and always
explicitly #include "drm-uapi/FOO.h"

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2019-02-14 11:20:00 +00:00
Michel Dänzer c0a540f320 loader/dri3: Use strlen instead of sizeof for creating VRR property atom
sizeof counts the terminating null character as well, so that also
contributed to the ID computed for the X11 atom. But the convention is
for only the non-null characters to contribute to the atom ID.

Fixes: 2e12fe425f "loader/dri3: Enable adaptive_sync via
                     _VARIABLE_REFRESH property"
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-02-05 17:18:44 +00:00
Rob Clark c56fe4118a loader: fix the no-modifiers case
Normally modifiers take precendence over use flags, as they are more
explicit.  But if the driver supports modifiers, but the xserver does
not, then we should fallback to the old mechanism of allocating a buffer
using 'use' flags.

Fixes: 069fdd5f9f
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2019-01-22 16:33:27 -05:00
Tapani Pälli c292414765 dri3: initialize adaptive_sync as false before configQueryb
Fixes following errors from valgrind output:

   ==23388== Conditional jump or move depends on uninitialised value(s)
   ==23388==    at 0x48B4924: loader_dri3_drawable_init (loader_dri3_helper.c:381)
   ==23388==    by 0x48A97D2: dri3_create_drawable (dri3_glx.c:386)
   ==23388==    by 0x489E190: driFetchDrawable (dri_common.c:369)
   ==23388==    by 0x48A9187: dri3_bind_context (dri3_glx.c:195)
   ==23388==    by 0x488B75C: MakeContextCurrent (glxcurrent.c:220)
   ==23388==    by 0x488B8DB: glXMakeCurrent (glxcurrent.c:267)
   ==23388==    by 0x10A987: ??? (in /usr/bin/glxgears)
   ==23388==    by 0x4BEB412: (below main) (in /usr/lib64/libc-2.28.so)
   ==23388==
   ==23388== Conditional jump or move depends on uninitialised value(s)
   ==23388==    at 0x48B5A40: loader_dri3_swap_buffers_msc (loader_dri3_helper.c:923)
   ==23388==    by 0x48A9B7E: dri3_swap_buffers (dri3_glx.c:587)
   ==23388==    by 0x4887A81: glXSwapBuffers (glxcmds.c:857)
   ==23388==    by 0x10ADED: ??? (in /usr/bin/glxgears)
   ==23388==    by 0x4BEB412: (below main) (in /usr/lib64/libc-2.28.so)

Fixes: 2e12fe425f "loader/dri3: Enable adaptive_sync via _VARIABLE_REFRESH property"
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2019-01-08 08:15:07 +02:00
Nicholas Kazlauskas 2e12fe425f loader/dri3: Enable adaptive_sync via _VARIABLE_REFRESH property
The DDX driver can be notified of adaptive sync suitability by
flagging the application's window with the _VARIABLE_REFRESH property.

This property is set on the first swap the application performs
when adaptive_sync is set to true in the drirc.

It's performed here instead of when the loader is initialized for
two reasons:

(1) The window's drawable can be missing during loader init.
    This can be observed during the Unigine Superposition benchmark.

(2) Adaptive sync will only be enabled closer to when the application
    actually begins rendering.

If adaptive_sync is false then the _VARIABLE_REFRESH property
is deleted on loader init.

The property is only managed on the glx DRI3 backend for now. This
should cover most common applications and games on modern hardware.

Vulkan support can be implemented in a similar manner but would likely
require splitting the function out into a common helper function.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2018-12-28 16:44:47 +01:00
Kirill Burtsev a539316485 loader: free error state, when checking the drawable type
Currently we distinguish if the drawable is a window or pixmap by
checking xcb_present_select_input throws an error or not.

Yet, we don't always free the error state returned by xcb.

Cc: Kirill Burtsev <kirill.burtsev@qt.io>
Cc: Boyan Ding <boyan.j.ding@gmail.com>
Fixes: 6bd9ba7d07 ("loader: Add dri3 helper")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
[Emil: add commit message, fixes tag]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-12-10 16:19:55 +00:00
Michel Dänzer c20ba1be18 loader/dri3: Also wait for front buffer fence if we triggered it
In that case, we have to wait for the fence to synchronize with the
corresponding drawing we triggered in the X server.

Fixes incorrect display with the i965 driver and some applications, e.g.
solvespace.

Bugzilla: https://bugs.freedesktop.org/108097
Fixes: aefac10fec "loader/dri3: Only wait for back buffer fences in
                     dri3_get_buffer"
Tested-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
2018-10-18 16:52:06 +02:00
Michel Dänzer e34dd4f508 loader/dri3: Don't wait for fence of old buffer when re-allocating it
We only need to wait for the fence before drawing to a buffer, not
before reading from it.

This might avoid hangs when re-allocating the fake front buffer, similar
to the previous change. But I haven't seen any evidence that this was
actually happening in practice.

Tested-by: Olivier Fourdan <ofourdan@redhat.com>
2018-09-12 16:55:09 +02:00
Michel Dänzer aefac10fec loader/dri3: Only wait for back buffer fences in dri3_get_buffer
We don't need to wait before drawing to the fake front buffer, as front
buffer rendering by definition is allowed to produce artifacts.

Fixes hangs in some cases when re-using the fake front buffer, due to it
still being busy (i.e. in use for presentation).

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/106404
Bugzilla: https://bugs.freedesktop.org/107757
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
2018-09-12 16:53:58 +02:00