dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Karol Herbst <kherbst@redhat.com>,
	James Jones <jajones@nvidia.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Thierry Reding <treding@nvidia.com>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Subject: Re: [git pull] drm for 5.8-rc1
Date: Tue, 18 Aug 2020 16:37:51 +0200	[thread overview]
Message-ID: <20200818143751.GB814860@ulmo> (raw)
In-Reply-To: <CAKMK7uFsTP-tN49SKJhm9w49EF3Ars0c1bF4=iUrEtKHCLzCTg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 5702 bytes --]

On Fri, Aug 14, 2020 at 07:25:17PM +0200, Daniel Vetter wrote:
> On Fri, Aug 14, 2020 at 7:17 PM Daniel Stone <daniel@fooishbar.org> wrote:
> >
> > Hi,
> >
> > On Fri, 14 Aug 2020 at 17:22, Thierry Reding <thierry.reding@gmail.com> wrote:
> > > I suspect that the reason why this works in X but not in Wayland is
> > > because X passes the right usage flags, whereas Weston may not. But I'll
> > > have to investigate more in order to be sure.
> >
> > Weston allocates its own buffers for displaying the result of
> > composition through GBM with USE_SCANOUT, which is definitely correct.
> >
> > Wayland clients (common to all compositors, in Mesa's
> > src/egl/drivers/dri2/platform_wayland.c) allocate with USE_SHARED but
> > _not_ USE_SCANOUT, which is correct in that they are guaranteed to be
> > shared, but not guaranteed to be scanned out. The expectation is that
> > non-scanout-compatible buffers would be rejected by gbm_bo_import if
> > not drmModeAddFB2.
> >
> > One difference between Weston and all other compositors (GNOME Shell,
> > KWin, Sway, etc) is that Weston uses KMS planes for composition when
> > it can (i.e. when gbm_bo_import from dmabuf + drmModeAddFB2 from
> > gbm_bo handle + atomic check succeed), but the other compositors only
> > use the GPU. So if you have different assumptions about the layout of
> > imported buffers between the GPU and KMS, that would explain a fair
> > bit.
> 
> Yeah non-modifiered multi-gpu (of any kind) is pretty much hopeless I
> think. I guess the only option is if the tegra mesa driver forces
> linear and an extra copy on everything that's USE_SHARED or
> USE_SCANOUT.

I ended up trying this, but this fails for the X case, unfortunately,
because there doesn't seem to be a good synchronization point at which
the de-tiling blit could be done. Weston and kmscube end up calling a
gallium driver's ->flush_resource() implementation, but that never
happens for X and glamor.

But after looking into this some more, I don't think that's even the
problem that we're facing here. The root of the problem that causes the
glxgears crash that Karol was originally reporting is because we end up
allocating the glxgears pixmaps using the dri3 loader from Mesa. But the
dri3 loader will unconditionally pass both __DRI_IMAGE_USE_SHARE and
__DRI_IMAGE_USE_SCANOUT, irrespective of whether the buffer will end up
being scanned out directly or whether it will be composited onto the
root window.

What exactly happens depends on whether I run glxgears in fullscreen
mode or windowed mode. In windowed mode, the glxgears buffers will be
composited onto the root window, so there's no need for the buffers to
be scanout-capable. If I modify the dri3 loader to not pass those flags
I can make this work just fine.

When I run glxgears in fullscreen mode, the modesetting driver ends up
wanting to display the glxgears buffer directly on screen, without
compositing it onto the root window. This ends up working if I leave out
the _USE_SHARE and _USE_SCANOUT flags, but I notice that the kernel then
complains about being unable to create a framebuffer, which in turn is
caused by the fact that those buffers are not exported (the Tegra Mesa
driver only exports/imports buffers that are meant for scanout, under
the assumption that those are the only ones that will ever need to be
used by KMS) and therefore Tegra DRM doesn't have a valid handle for
them.

So I think an ideal solution would probably be for glxgears to somehow
pass better usage information when allocating buffers, but I suspect
that that's just not possible, or would be way too much work and require
additional protocol at the DRI level, so it's not really a good option
when all we want to fix is backwards-compatibility with pre-modifiers
userspace.

Given that glamor also doesn't have any synchronization points, I don't
see how I can implement the de-tiling blit reliably. I was wondering if
it shouldn't be possible to flush the framebuffer resource (and perform
the blit) at presentation time, but I couldn't find a good entry point
to do this.

One other solution that occurred to me was to reintroduce an old IOCTL
that we used to have in the Tegra DRM driver. That IOCTL was meant to
attach tiling meta data to an imported buffer and was basically a
simplified, driver-specific way of doing framebuffer modifiers. That's
a very ugly solution, but it would allow us to be backwards-compatible
with pre-modifiers userspace and even use an optimal path for rendering
and scanning out. The only prerequisite would be that the driver IOCTL
was implemented and that a recent enough Mesa was used to make use of
it. I don't like this very much because framebuffer modifiers are a much
more generic solution, but all of the other options above are pretty
much just as ugly.

One other idea that I haven't explored yet is to be a little more clever
about the export/import dance that we do for buffers. Currently we
export/import at allocation time, and that seems to cause a bit of a
problem, like the lack of valid GEM handles for some buffers (such as in
the glxgears fullscreen use-case discussed above). I wonder if perhaps
deferring the export/import dance until the handles are actually
required may be a better way to do this. With such a solution, even if a
buffer is allocated for scanout, it won't actually be imported/exported
if the client ends up being composited onto the root window. Import and
export would be limited to buffers that truly are going to be used for
drmModeAddFB2(). I'll give that a shot and see if that gets me closer to
my goal.

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-08-18 14:37 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  6:06 [git pull] drm for 5.8-rc1 Dave Airlie
2020-06-02 21:21 ` Linus Torvalds
2020-06-02 21:22   ` Linus Torvalds
2020-06-02 21:56   ` Linus Torvalds
2020-06-03  7:18     ` Thomas Zimmermann
2020-06-03  7:43       ` Daniel Vetter
2020-06-02 22:14 ` Linus Torvalds
2020-06-02 23:03   ` Dave Airlie
2020-06-02 22:20 ` pr-tracker-bot
2020-06-03 20:13 ` Jason Gunthorpe
2020-06-04  8:10   ` Christian König
2020-06-30 23:08 ` Kirill A. Shutemov
2020-07-01  4:40   ` James Jones
2020-07-01  7:57     ` Kirill A. Shutemov
2020-07-01  7:59       ` Kirill A. Shutemov
2020-07-01 19:45         ` James Jones
2020-07-02  7:36           ` Daniel Vetter
2020-07-02  7:59           ` Pekka Paalanen
2020-07-02  8:22           ` Daniel Stone
2020-07-02 21:14             ` James Jones
2020-07-03  6:01               ` James Jones
2020-07-03  7:16                 ` Daniel Vetter
2020-07-13  1:37                   ` Dave Airlie
2020-07-14 14:31                     ` James Jones
2020-08-04  8:58                       ` Karol Herbst
2020-08-12  0:19                         ` James Jones
2020-08-12 10:27                           ` Karol Herbst
2020-08-12 10:43                             ` Karol Herbst
2020-08-12 12:24                               ` Karol Herbst
2020-08-12 12:37                                 ` Ilia Mirkin
2020-08-12 17:03                                   ` James Jones
2020-08-12 17:10                                     ` Karol Herbst
2020-08-12 17:19                                       ` James Jones
2020-08-12 17:40                                         ` Alyssa Rosenzweig
2020-08-12 18:24                                           ` James Jones
2020-08-12 18:51                                             ` Karol Herbst
2020-08-13 13:00                                               ` Karol Herbst
2020-08-13 15:39                                                 ` Karol Herbst
2020-08-13 17:19                                                   ` Karol Herbst
2020-08-13 17:45                                                     ` James Jones
2020-08-13 17:48                                                       ` Karol Herbst
2020-08-14 13:57                                                         ` Thierry Reding
2020-08-14 13:59                                                           ` Karol Herbst
2020-08-14 14:10                                                             ` Thierry Reding
2020-08-14 14:05                                                       ` Thierry Reding
2020-08-14 14:44                                                         ` Karol Herbst
2020-08-14 15:34                                                           ` Thierry Reding
2020-08-14 15:40                                                             ` Karol Herbst
2020-08-14 16:06                                                               ` Thierry Reding
2020-08-14 16:12                                                                 ` Karol Herbst
2020-08-14 16:22                                                                   ` Thierry Reding
2020-08-14 17:17                                                                     ` Daniel Stone
2020-08-14 17:25                                                                       ` Daniel Vetter
2020-08-18 14:37                                                                         ` Thierry Reding [this message]
2020-09-01  7:13                                                                           ` Daniel Vetter
2020-09-01 10:42                                                                             ` Daniel Stone
2020-09-01 10:59                                                                             ` Karol Herbst
2020-09-01 14:42                                                                               ` James Jones
2020-08-14 14:08                                                   ` Thierry Reding
2020-08-14 14:45                                                     ` Karol Herbst
2020-08-14 15:24                                                       ` Thierry Reding
2020-08-14 15:43                                                         ` Karol Herbst
2020-08-14 13:54                                                 ` Thierry Reding
2020-08-14 13:40                                     ` Thierry Reding
2020-08-14 13:56                                       ` Karol Herbst
2020-08-12 15:05                               ` Thierry Reding
2020-08-12 15:20                                 ` Karol Herbst
2020-08-12 15:49                                   ` Karol Herbst
2020-07-01 11:24     ` Karol Herbst
2020-07-01 15:51       ` James Jones
2020-07-01 16:01         ` Daniel Vetter
2020-07-01 17:04           ` Karol Herbst
2020-07-01 17:37             ` James Jones
2020-07-01 18:08               ` Karol Herbst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818143751.GB814860@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jajones@nvidia.com \
    --cc=kherbst@redhat.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).