Commit Graph

3332 Commits

Author SHA1 Message Date
Michel Dänzer
121a6de72d Keep track of damage event related flushes per-client v2
This further reduces the compositing slowdown due to flushing overhead,
by only flushing when the X server actually sends XDamageNotify events
to a client, and there hasn't been a flush yet in the meantime.

v2: Use ScreenPrivateKey, fixes invalid memory access with GPU screens
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-08-17 18:14:40 +09:00
Michel Dänzer
9090309e05 Wait for pending flips to complete before turning off an output or CRTC
At least with older kernels, the flip may never complete otherwise,
which can result in us hanging in drmmode_set_mode_major.

Fixes: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-ati/+bug/1577170

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-08-03 18:17:50 +09:00
Michel Dänzer
9a1afbf61f Use EventCallback to avoid flushing every time in the FlushCallback
We only need to flush for XDamageNotify events.

Significantly reduces compositing slowdown due to flushing overhead, in
particular with glamor.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-08-01 18:51:03 +09:00
Michel Dänzer
94fe42f29e Don't enable DRI3 by default with EXA
It doesn't work correctly in all cases, see e.g.
https://bugs.freedesktop.org/show_bug.cgi?id=95475 . I'm not sure this
is fixable, given EXA's architecture.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-07-22 19:10:53 +09:00
Michel Dänzer
6d91fb4fc7 Don't enable micro-tiling for scanout buffers on pre-R600
The display engine didn't support it.

Fixes display corruption with options "TearFree" and "ShadowPrimary"
(and rotation or transforms with current xserver) on pre-R600.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-07-22 19:09:48 +09:00
Michel Dänzer
a37af70176 Add explicit RADEON_DRM_QUEUE_ERROR define
Should make the radeon_drm_queue_alloc error handling clearer, and gets
rid of a compile warning about it returning NULL.

Reviewed-by: Alexandre Demers <alexandre.f.demers@gmail.com>
2016-07-22 19:08:38 +09:00
Keith Packard
024afff27e Adapt to video API 22
Deal with drm fd wakeup

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2016-07-20 10:26:23 +09:00
Adam Jackson
eac4db4f0c Adapt Block/WakeupHandler signature for ABI 23
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-07-19 10:17:40 -04:00
Michel Dänzer
3be841d0ae Only use RandR APIs if RandR is enabled
Fixes crash with Xinerama enabled, which disables RandR.

Fixes: https://bugs.debian.org/827984

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-06-24 11:12:49 +09:00
Michel Dänzer
7835558acd Adapt to XF86_CRTC_VERSION 7
Now the HW cursor can be used with TearFree rotation.

This also allows always using the separate scanout pixmap mechanism for
rotation, so that should be much smoother even without TearFree enabled.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-06-21 10:41:27 +09:00
Tan Hu
0945db4d90 EXA/6xx/7xx: accelerate PictOpOver with component alpha
Subpixel text rendering is typically done with a solid src and
a pixmap mask. Traditionally, this cannot be accelerated in a single
pass and requires two passes [1]. However, we can cheat a little
with a constant blend color.

We can use:
const.A = src.A / src.A
const.R = src.R / src.A
const.G = src.G / src.A
const.B = src.B / src.A

dst.A = const.A * (src.A * mask.A) + (1 - (src.A * mask.A)) * dst.A
dst.R = const.R * (src.A * mask.R) + (1 - (src.A * mask.R)) * dst.R
dst.G = const.G * (src.A * mask.G) + (1 - (src.A * mask.G)) * dst.G
dst.B = const.B * (src.A * mask.B) + (1 - (src.A * mask.B)) * dst.B

This only needs a single source value. src.A is cancelled down in
the right places.

[1] http://anholt.livejournal.com/32058.html

r6xx still be used on some machine,
Ported from commit 4375a6e75e.

Signed-off-by: Tan Hu <tan.hu@zte.com.cn>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
2016-06-01 18:17:16 +09:00
Tan Hu
9b9ad669c7 EXA/6xx/7xx: fast solid pixmap support
Solid pixmaps are currently implemented with scratch pixmaps, which
is slow. This replaces the hack with a proper implementation. The
Composite shader can now either sample a src/mask or use a constant
value.

r6xx still be used on some machine,
Ported from commit 94d0d14914.

Signed-off-by: Tan Hu <tan.hu@zte.com.cn>
Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
2016-06-01 18:17:16 +09:00
Michel Dänzer
aa07b365d7 Add .editorconfig file
Basically a conversion from .dir-locals.el, but also correctly handles
files which predominantly use tabs for indentation.

Also, EditorConfig supports many more editors and IDEs.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2016-06-01 17:23:55 +09:00
Michel Dänzer
040a7b80e1 Explicitly set the fbcon pixmap pitch again
The kernel driver returns 0 as the pitch of the fbcon BO via the
DRM_RADEON_GEM_GET_TILING ioctl, so we ended up using an incorrect
pitch in some cases.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94901

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-12 18:52:50 +09:00
Michel Dänzer
1181b9c582 Enable DRI3 by default when building for Xorg >= 1.18.3
Seems to work well enough in general now.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-05-11 12:25:23 +09:00
Michel Dänzer
c801f9f10a Handle Zaphod mode correctly in radeon_mode_hotplug
We need to scan both screens of the entity for existing connectors, and
enumerate DVI & HDMI connectors consistently regardless of which screen
they're assigned to.

Fixes crash when hot-(un)plugging connectors in Zaphod mode.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93415
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-19 16:35:40 +09:00
Michel Dänzer
1ca6773097 present: Support async flips
The xserver Present code only calls radeon_present_flip with
sync_flip=FALSE if radeon_present_screen_init sets
PresentCapabilityAsync, and the latter only sets it if the kernel driver
advertises support for async flips.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-12 17:46:56 +09:00
Michel Dänzer
90a915c62d Add support for async flips to radeon_do_pageflip
Will be used by the next change. No functional change here.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-12 17:46:12 +09:00
Qiang Yu
ba8b6288c8 Remove RR_Capability_SinkOutput for GPU without CRTC
Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
(Ported from amdgpu commit a0bbb373f902e0ffc14570c85faec7e44134f62e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-11 16:35:37 +09:00
Tom St Denis
bd4c72c862 dri3: Return NULL from radeon_dri3_pixmap_from_fd if calloc fails.
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-04-11 16:13:44 +09:00
Michel Dänzer
3300ea01fb Post 7.7.0 release version bump 2016-04-11 16:11:57 +09:00
Michel Dänzer
df6662864b Bump version for 7.7.0 release xf86-video-ati-7.7.0 2016-04-07 11:44:05 +09:00
Michel Dänzer
c12614cfdc Update manpage entry for Option "TearFree"
It's now effective for rotation as well.

(Ported from amdgpu commit faf9d720b7d650f5f1ea657a874d08eac3972e60)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-04 14:59:41 +09:00
Michel Dänzer
4693b1bd5b Identify DRM event queue entries by sequence number instead of by pointer
If the memory for an entry was allocated at the same address as that for
a previously cancelled entry, the handler could theoretically be called
prematurely, triggered by the DRM event which was submitted for the
cancelled entry.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-04-01 15:23:10 +09:00
Michel Dänzer
83734317e6 Update pixmap pitch in radeon_set_pixmap_bo
Stop second guessing it in drmmode_crtc_scanout_create.

Fixes display corruption in some cases with TearFree enabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94751

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-31 16:24:45 +09:00
Michel Dänzer
0b3aac1de9 DRI3: Refuse to open DRM file descriptor for ssh clients (v2)
Fixes hangs when attempting to use DRI3 on display connections forwarded
via SSH.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93261

v2: Don't do this for Xorg > 1.18.99.1 since the corresponding xserver
    change has landed in Git master.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
2016-03-28 18:43:36 +09:00
Michel Dänzer
8a6cd4bda0 Revert "Use render node for DRI3 if available"
This reverts commit cd94248ffa.

It broke VDPAU<->GL interop with DRI3 enabled, because the Gallium VDPAU
code doesn't support DRI3 yet. We can consider re-enabling this once
there is a Mesa release where the Gallium VDPAU code supports DRI3.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94675

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-25 11:50:15 +09:00
Michel Dänzer
ed31cffba0 Call RADEONBlockHandler_KMS before setting initial modes
Doing it the other way around meant that there was still a possibility
for the front buffer contents to be uninitialized when they start being
scanned out.

(Ported from amdgpu commit 4a60b4b1851a3cbc2d8ad9048d68eeb6947cf132)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 18:08:22 +09:00
Michel Dänzer
e592f32f8b Require xserver 1.9 or newer
1.9.0 was released in August 2010.

We were already unintentionally relying on things not available in 1.8
for at least a year, and nobody has complained.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 18:02:46 +09:00
Michel Dänzer
bde466e5d4 Fix build against older versions of xserver
Also slightly clean up the error handling in radeon_scanout_do_update.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94614

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 18:01:03 +09:00
Michel Dänzer
b2b079be0e Use radeon_alloc_pixmap_bo for allocating scanout BOs
This enables tiling for scanout BOs used for TearFree / ShadowPrimary,
and simplifies the code a little.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 18:00:11 +09:00
Michel Dänzer
d21ac4669a DRI3 only works with acceleration
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94214

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-24 17:59:27 +09:00
Michel Dänzer
eb1a2c57e6 TearFree can only work with acceleration
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 17:23:31 +09:00
Michel Dänzer
d670c5c985 Check for xf86CursorResetCursor
If it's available, Xorg calls it on each mode configuration change. It
does what xf86_reload_cursors does (and more), so we don't need to call
the latter anymore.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 16:54:24 +09:00
Michel Dänzer
7f3d0780ca Don't try DRI2/Present flipping while the HW cursor can't be used
Flipping doesn't interact correctly with SW cursor: A flip makes the SW
cursor disappear. It will only appear again when the cursor is moved,
but it will be surrounded by corruption, because the SW cursor code
will restore stale screen contents at the old cursor location before
drawing the cursor at the new location.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 16:52:59 +09:00
Michel Dänzer
3de480e83c Factor out HW cursor checking code into drmmode_can_use_hw_cursor
And add a check for RandR 1.4 multihead.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 16:51:50 +09:00
Ryan Kennedy
2e0b458e74 Use correct tiling in drmmode_create_bo_pixmap
The callers were using 0 for the tiling flags, causing surfaces to be
incorrectly treated as linear. This issue was causing corruption on Cayman
just after login with GNOME3. The kernel was rejecting the cs in
drmmode_copy_fb due to invalid texture pitch.

Signed-off-by: Ryan Kennedy <Ryan.Kennedy@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-03-23 16:38:50 +09:00
Michel Dänzer
a03271de5e present: Return rotated CRTCs from radeon_present_get_crtc
Sync-to-vblank works fine with rotation. We're still checking for
rotation in radeon_present_check_flip.

Returning NULL from here resulted in the xserver present code falling
back to the fake CRTC running at 1 fps.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-10 18:44:17 +09:00
Michel Dänzer
40191d8237 present: Clear drmmode->fb_id before calling set_mode_major for unflip
Without this, drmmode_set_mode_major may just re-set the FB for the
last flipped BO, in which case the display will probably freeze.

Reproduction recipe: Enable rotation while a fullscreen client is
flipping.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-09 18:29:06 +09:00
Michel Dänzer
798c4fd16d Make Option "TearFree" effective for rotated/reflected outputs as well (v2)
Support varies by xserver version:

< 1.12:    No support for the driver handling rotation/reflection
1.12-1.15: Support for driver handling rotation/reflection, but there's
           a bug preventing the HW cursor from being visible everywhere
           it should be on rotated outputs, so we can only support
           TearFree for reflection.
>= 1.16:   While the bug above is still there (fixes pending review),
           the driver can force SW cursor for rotated outputs, so we
           can support TearFree for rotation as well.

v2: Don't set crtc->driverIsPerformingTransform after xf86CrtcRotate if
    it wasn't set before. Fixes breaking rotation with TearFree disabled.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
2016-03-09 16:11:47 +09:00
Michel Dänzer
eb611a2e4e Consolidate pScreen usage in drmmode_set_mode_major
We were already relying on pScrn->pScreen being non-NULL in some cases,
which is supposedly always true ever since this function is no longer
getting called from ScreenInit.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-09 16:11:22 +09:00
Michel Dänzer
0660217138 Remove check for XF86_CRTC_VERSION 3
We require xserver >= 1.8, which was already at version 3.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-08 17:46:54 +09:00
Michel Dänzer
a88985f5d1 Deal with modesets and page flips crossing on a CRTC
If we set a mode while a flip is pending, the kernel driver may program
the flip to the hardware after the modeset. If that happens, the hardware
will display the BO from the flip, whereas we will assume it displays the
BO from the modeset. In other words, the display will most likely freeze,
at least until another modeset.

Prevent this condition by waiting for a pending flip to finish before
setting a mode.

Fixes display freezing when setting rotation or a transform with
TearFree enabled.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-01 10:26:39 +09:00
Michel Dänzer
f5d968cbba Make DRM event queue xf86CrtcPtr based instead of ScrnInfoPtr based
This allows for a minor simplification of the code.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:16:37 +09:00
Michel Dänzer
e87365117a DRI2: Also clear dri2_flipping when client disconnects before event
Fixes the following problem:

With DRI3 enabled, run glxgears with LIBGL_DRI3_DISABLE=1, make it
fullscreen and press Escape while it's still fullscreen. This could
result in dri2_flipping not getting cleared, spuriously preventing apps
using DRI3 from flipping.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:15:56 +09:00
Michel Dänzer
d5dbb07db2 Remove radeon_scanout_flip_handler
No longer necessary now that radeon_drm_queue_handler can handle
e->handler == NULL.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:15:29 +09:00
Michel Dänzer
3989766edd drm_queue: Don't abort events immediately from radeon_drm_abort_client
Keep them around until the DRM event arrives, but then call the abort
functions instead of the handler functions.

This is a prerequisite for the following fix.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-25 16:43:48 +09:00
jimqu
7bc089ee97 glamor: Return NullPixmap on failure to create shareable pixmap
If we were asked to create a shareable pixmap, it doesn't make sense
to return a pixmap which isn't shareable. Doing so caused trouble down
the line such as a crash with older versions of glamor when trying to
use GLX pixmaps of bpp < 32 via DRI2.

Signed-off-by: JimQu <jim.qu@amd.com>
(ported from amdgpu commit 2fcb7dadd3c71cd405cbbaafc777697538ca9c29)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-17 11:44:19 +09:00
jimqu
4cc3203146 Move radeon_glamor_destroy_pixmap before radeon_glamor_create_pixmap
The next commit will call the former from the latter. No functional
change.

Signed-off-by: JimQu <jim.qu@amd.com>
(ported from amdgpu commit 5269a2228bff6023c1a7f3e8534027e1d7addc25)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-17 11:43:14 +09:00
Michel Dänzer
a9b181083d Remove pci_dev test from radeon_get_scrninfo
The pci_dev parameter can never be NULL since we only support KMS.

Reported-by: Tom St Denis <tom.stdenis@amd.com>
(ported from amdgpu commit 6e42c58375a4c3229da93c27bbd104af145c6163)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-17 11:42:34 +09:00