Discussion:
modesetting TearFree / VSYNC aware rotation pageflipping
Carsten Behling
2018-09-28 12:52:36 UTC
Permalink
Hi all,

I noticed ugly tearing when rotating the screen with modesetting.

I already noticed this thread

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

that suggests to implement the TearFree option into modesetting.

So I took a look on the amd and ati implementations

https://cgit.freedesktop.org/xorg/driver/xf86-video-amdgpu/commit/?id=c57da33308a81fa575179238a0415abcb8b34908

https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=43159ef400c3b18b9f4d3e6fa1c4aef2d60d38fe

and compared it to modesetting and I found that pageflipping is already
implemented since this patch:

https://lists.x.org/archives/xorg-devel/2015-May/046271.html

But:

1. The above stated Freedesktop bug is older and the modesetting
pageflipping implementation is not mentioned there in the TearFree context.
But e.g. AMD GPU is doing a very similar thing for TearFree.
2. Modesettings pageflipping is disabled on rotation and I found just that
Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
So here are my questions:

1. What is the difference between flipping the scanout buffers in
amdgpu/ati and the front buffer and back buffer flipping in modesetting?

2. I suppose in both cases that are real video buffers instead of shadow
buffers for rotation. Right?

3. I did not found any background info about the limitation for
pageflipping caught by Jason. Can anyone give me some more info? Since
amdgpu does the nearly the same with its two scanout buffers it shouldn't
be a big problem.

So if TearFree support or something else that makes more sense is still an
issue I can add that feature. I just need a little help.

Best regards
-Carsten
Michel Dänzer
2018-10-01 15:57:20 UTC
Permalink
Post by Carsten Behling
Hi all,
I noticed ugly tearing when rotating the screen with modesetting.
I already noticed this thread
https://bugs.freedesktop.org/show_bug.cgi?id=98876
that suggests to implement the TearFree option into modesetting.
So I took a look on the amd and ati implementations
https://cgit.freedesktop.org/xorg/driver/xf86-video-amdgpu/commit/?id=c57da33308a81fa575179238a0415abcb8b34908
https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=43159ef400c3b18b9f4d3e6fa1c4aef2d60d38fe
and compared it to modesetting and I found that pageflipping is already
https://lists.x.org/archives/xorg-devel/2015-May/046271.html
1. The above stated Freedesktop bug is older and the modesetting
pageflipping implementation is not mentioned there in the TearFree context.
But e.g. AMD GPU is doing a very similar thing for TearFree.
2. Modesettings pageflipping is disabled on rotation and I found just that
Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
1. What is the difference between flipping the scanout buffers in
amdgpu/ati and the front buffer and back buffer flipping in modesetting?
2. I suppose in both cases that are real video buffers instead of shadow
buffers for rotation. Right?
3. I did not found any background info about the limitation for
pageflipping caught by Jason. Can anyone give me some more info? Since
amdgpu does the nearly the same with its two scanout buffers it shouldn't
be a big problem.
So if TearFree support or something else that makes more sense is still an
issue I can add that feature. I just need a little help.
Basically you're comparing apples (TearFree, the amdgpu/radeon driver
changes above) and oranges (DRI page flipping, the modesetting change
above).

DRI page flipping is an old mechanism (supported by the amdgpu/radeon
drivers as well, "forever", since long before TearFree) for direct
scanout from buffers whose contents were produced with direct rendering
by the client. Because it scans out directly, output transformations
such as rotation are traditionally not supported with DRI page flipping.

TearFree uses separate dedicated scanout buffers, to which the "main"
buffer contents are copied on demand.

Originally, these three things (DRI page flipping, rotation and
TearFree) were separate and mutually exclusive. However, the
amdgpu/radeon drivers support all of them the same time these days; this
still requires an extra copy in some cases, but that could be eliminated
at least in the non-rotated DRI page flipping case.

https://gitlab.freedesktop.org/xorg/xserver/merge_requests/24 has the
start of TearFree support for the modesetting driver, but it's still
mutually exclusive with rotation (DRI3 page flipping should work with
TearFree, but may still exhibit tearing if the client/user disables
sync-to-vblank).


Hope this helps,
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer


_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription a
Carsten Behling
2018-10-03 14:22:16 UTC
Permalink
Hi Michel,

thanks for responding.
Post by Michel Dänzer
Basically you're comparing apples (TearFree, the amdgpu/radeon driver
changes above) and oranges (DRI page flipping, the modesetting change
above).
DRI page flipping is an old mechanism (supported by the amdgpu/radeon
drivers as well, "forever", since long before TearFree) for direct
scanout from buffers whose contents were produced with direct rendering
by the client. Because it scans out directly, output transformations
such as rotation are traditionally not supported with DRI page flipping.
I see. So I have to double buffer the rotated buffer and flip it on vsync.

According to this discussion

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

it should be able to double-buffer the rotated frontbuffer and let a
'damage'
trigger rendering to the offscreen buffer and wait for vsync to flip. Right?
Post by Michel Dänzer
TearFree uses separate dedicated scanout buffers, to which the "main"
buffer contents are copied on demand.
Originally, these three things (DRI page flipping, rotation and
TearFree) were separate and mutually exclusive. However, the
amdgpu/radeon drivers support all of them the same time these days; this
still requires an extra copy in some cases, but that could be eliminated
at least in the non-rotated DRI page flipping case.
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/24 has the
start of TearFree support for the modesetting driver, but it's still
mutually exclusive with rotation (DRI3 page flipping should work with
TearFree, but may still exhibit tearing if the client/user disables
sync-to-vblank).
Couldn't we extend modesetting in addition to Martin's TearFree patch the
same way you did here for Radeon?:

https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=798c4fd16d339b1ad5fd729cc884be084c60e38b

Best regards
-Carsten
Michel Dänzer
2018-10-03 14:36:07 UTC
Permalink
Post by Carsten Behling
Post by Michel Dänzer
TearFree uses separate dedicated scanout buffers, to which the "main"
buffer contents are copied on demand.
Originally, these three things (DRI page flipping, rotation and
TearFree) were separate and mutually exclusive. However, the
amdgpu/radeon drivers support all of them the same time these days; this
still requires an extra copy in some cases, but that could be eliminated
at least in the non-rotated DRI page flipping case.
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/24 has the
start of TearFree support for the modesetting driver, but it's still
mutually exclusive with rotation (DRI3 page flipping should work with
TearFree, but may still exhibit tearing if the client/user disables
sync-to-vblank).
Couldn't we extend modesetting in addition to Martin's TearFree patch the
https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=798c4fd16d339b1ad5fd729cc884be084c60e38b
Yeah, something like that would be needed.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Martin Peres
2018-10-04 07:42:38 UTC
Permalink
Post by Michel Dänzer
Post by Carsten Behling
Post by Michel Dänzer
TearFree uses separate dedicated scanout buffers, to which the "main"
buffer contents are copied on demand.
Originally, these three things (DRI page flipping, rotation and
TearFree) were separate and mutually exclusive. However, the
amdgpu/radeon drivers support all of them the same time these days; this
still requires an extra copy in some cases, but that could be eliminated
at least in the non-rotated DRI page flipping case.
https://gitlab.freedesktop.org/xorg/xserver/merge_requests/24 has the
start of TearFree support for the modesetting driver, but it's still
mutually exclusive with rotation (DRI3 page flipping should work with
TearFree, but may still exhibit tearing if the client/user disables
sync-to-vblank).
Couldn't we extend modesetting in addition to Martin's TearFree patch the
https://cgit.freedesktop.org/xorg/driver/xf86-video-ati/commit/?id=798c4fd16d339b1ad5fd729cc884be084c60e38b
Yeah, something like that would be needed.
Carsten,

Would you like to add support for it on top of my branch? I am a bit
swamped but I could be convinced to help you on this if needed :)

Martin
_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/l

Loading...