From: Rian Quinn Subject: Re: Sharing Framebuffers between Client / Server Date: Mon, 20 Jan 2014 07:21:43 -0800 (PST) Message-ID: References: <52DD2779.4090802@shipmail.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2053495054==" Return-path: Received: from mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DE76FAE99 for ; Mon, 20 Jan 2014 07:21:45 -0800 (PST) Received: by mail-ie0-f172.google.com with SMTP id e14so8440997iej.31 for ; Mon, 20 Jan 2014 07:21:44 -0800 (PST) In-Reply-To: <52DD2779.4090802@shipmail.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org To: Thomas Hellstrom Cc: Thomas Hellstrom , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============2053495054== Content-Type: multipart/alternative; boundary="=_03ED3B49-CFF8-4CE2-B963-B2A8F0F84F4B" --=_03ED3B49-CFF8-4CE2-B963-B2A8F0F84F4B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Yeah we looked into GDM. We already link into Mesa, but I was also concerne= d about having to use GL to render into the buffers, as the format of the b= uffer is (correct me if I am wrong) specific to the graphics card (i.e. it'= s not a simple ARGB format which I need).=C2=A0 Could you point me to some docs, or headers for DRM prime. I think that usi= ng simple =E2=80=9Cdumb=E2=80=9D KMS buffers should work fine.=C2=A0 In my use case, I actually have to have a memcpy because there will only be= one scanout buffer managed by the server. Each client needs to directly re= nder (ARGB) to a framebuffer, and then the server will memcpy the contents = it wants, to the scanout buffer. In that past, we used a CPU memcpy, but we= would like to use a DMA transfer going forward. Our plan was to use Mesa/G= L to do a BLT_SRC_COPY. Will the =E2=80=9Cdumb=E2=80=9D buffer support this= ?=C2=A0 I guess this brings up a performance question too. Is it better to render i= nto system memory, and then DMA from that to video memory, or is it better = to render into video memory, and DMA between video memory?=C2=A0 - Rian Sent with Unibox > On Jan 20, 2014, at 8:41 AM, Thomas Hellstrom wrote: >=20 >=20 > On 01/20/2014 02:10 PM, Rob Clark wrote: >=20 >=20 >> On Fri, Jan 17, 2014 at 6:43 AM, Rian Quinn wrote: >>=20 >>=20 >>> I am working on a client/server program, where the server creates (and = has >>> access to a framebuffer), and then needs to share this framebuffer with= a >>> client program so that this client program can draw into the framebuffer >>> directly (i.e. no memcpy). >>>=20 >>>=20 >>> I am trying to figureout what the =E2=80=9Ccleanest=E2=80=9D way to do = this is, such that I >>> can support Intel=E2=80=99s proprietary driver, the open source AMD and= NVidia >>> drivers, and the VMWare driver (I have no need for the proprietary >>> ADM/NVidia drivers right now). From what I can tell, GEM is one way to = do >>> this. The problem is VMWare doesn=E2=80=99t support GEM. >>>=20 >>>=20 >>> I tried (knowing it would not work), using KMS to create the framebuffe= r, >>> and then sending the information needed to mmap to the client. This of >>> course failed because the framebuffer is marked non-sharable in the ker= nel. >>>=20 >>>=20 >>> Dmabuf (or just plain old egl/glx which uses dri2 under the hood) >> would probably be what I suggest *except* you mention mmap. If you >> are doing software rendering, I guess you probably just want to suck >> it up and do XShmPutImage. >>=20 >>=20 >>> From what I understand, any sort of mmap access to vmwgfx buffers is >>>=20 >>>=20 >>> tricky, because they end up being backed by normal GL textures on the >> host OS side (IIUC). So the single copy upload path in XShmPutImage >> might be close to the ideal path for sw rendered content. >>=20 >>=20 >>> To be clear, I am fine having to manually write ioctls for each driver,= if >>> thats what it takes. But at this point, I am at a loss on the best meth= od to >>> share scannot buffers (or at least in a way that doesn=E2=80=99t make s= omeone cringe >>> when they see my code). >>>=20 >>>=20 >>> Some sort of prepare/finish access ioctls for dmabuf to bracket mmap >> access are, I think, what vmwgfx is missing in order to implement >> dmabuf mmap. But no one so far has needed them badly enough to come >> up with something and send patches. >>=20 >>=20 >> IIUC, for vmwgfx there would still be a copy back to original texture >> on the host on finish-access, so it might not amount to anything much >> different from XShmPutImage. Probably better to ask some vmwgfx folks >> to clarify, since the virtual driver has some unique constraints which >> I may not be adequately representing. >>=20 >>=20 >> BR, >> -R >>=20 >>=20 >>=20 >=20 > Rian, for sharing accelerated buffers, They'd best be created with > Mesa's GBM, and shared using DRM prime. Those interfaces are generic and > AFAICT, Ubuntu's Mir works exactly this way. The problem is that the > client would need to link to mesa, and could use GL / GLES to transfer > software contents to the buffer. >=20 >=20 > For pure software contents, the server would share a generic shared > memory buffer, together with a damage protocol, and composite / copy > onto the framebuffer in the server. >=20 >=20 > In principle, as Rob says, the dma-buf shared using DRM prime has an > mmap() method, but none of the "big" drivers Intel, Nouveau and Radeon > implements it, and for vmwgfx an implementation would be extremely > inefficient. Also other drivers may have issues with write-combining and > tiling of the mmap'ed framebuffer. >=20 >=20 > If both the server and client would be 100% software one could create > and share "dumb" kms buffers using DRM prime. If there's something in > the vmwgfx driver that blocks sharing in this way, we could ease that > restriction. But these buffers could not be rendered into. >=20 >=20 > GEM is, BTW, purely driver-private. >=20 >=20 > As you might see, the big restriction here is that there is no simple > generic way to mmap() accelerated shared buffers from a lean client. > This is intentional. For vmwgfx it's because of coherency issues that > would make such an implementation inefficient. For other drivers I can > imagine there are tiling- and caching issues. >=20 >=20 > /Thomas >=20 >=20 >>=20 >>=20 >>> Thanks, >>> - Rian >>>=20 >>>=20 >>> _______________________________________________ >>> dri-devel mailing list >>> dri-devel@lists.freedesktop.org >>> http://lists.freedesktop.org/mailman/listinfo/dri-devel >>>=20 >>>=20 >>> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/dri-devel >>=20 >>=20 >>=20 >=20 >=20 >=20 >=20 --=_03ED3B49-CFF8-4CE2-B963-B2A8F0F84F4B Content-Type: multipart/related; boundary="=_F0A7F091-D08C-46D4-A151-30A19174B40E" --=_F0A7F091-D08C-46D4-A151-30A19174B40E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Yeah we looked into GDM. We already link into Mesa, but I was also= concerned about having to use GL to render into the buffers, as the format= of the buffer is (correct me if I am wrong) specific to the graphics card = (i.e. it's not a simple ARGB format which I need).=C2=A0

Could you point me to some docs, or headers for D= RM prime. I think that using simple =E2=80=9Cdumb=E2=80=9D KMS buffers shou= ld work fine.=C2=A0

In my use case, I actually have to have a memcpy = because there will only be one scanout buffer managed by the server. Each c= lient needs to directly render (ARGB) to a framebuffer, and then the server= will memcpy the contents it wants, to the scanout buffer. In that past, we= used a CPU memcpy, but we would like to use a DMA transfer going forward. = Our plan was to use Mesa/GL to do a BLT_SRC_COPY. Will the =E2=80=9Cdumb= =E2=80=9D buffer support this?=C2=A0

I guess this brings up a performance question too= . Is it better to render into system memory, and then DMA from that to vide= o memory, or is it better to render into video memory, and DMA between vide= o memory?=C2=A0

- Rian


Sent wi= th Unibox

On Jan 20, 2014, at 8:41 AM, Thomas Hellstrom <thomas@shipmail.org> = wrote:

On 01/20/2014 02:10 PM, Rob Clark wrote:

On Fri, Jan 17, 2014 at 6:43 AM, Rian= Quinn <rianquinn@gmail.com> wrote:

I am working on a client/server progr= am, where the server creates (and has
access to a framebuffer), and then= needs to share this framebuffer with a
client program so that this clie= nt program can draw into the framebuffer
directly (i.e. no memcpy).

I am trying to figureout what the =E2=80=9Ccleane= st=E2=80=9D way to do this is, such that I
can support Intel=E2=80=99s p= roprietary driver, the open source AMD and NVidia
drivers, and the VMWar= e driver (I have no need for the proprietary
ADM/NVidia drivers right no= w). From what I can tell, GEM is one way to do
this. The problem is VMWa= re doesn=E2=80=99t support GEM.

I tried (knowing it would not work), using KMS to= create the framebuffer,
and then sending the information needed to mmap= to the client. This of
course failed because the framebuffer is marked = non-sharable in the kernel.

Dmabuf (or just plain old egl/glx wh= ich uses dri2 under the hood)
would probably be what I suggest *except* = you mention mmap. If you
are doing software rendering, I guess you proba= bly just want to suck
it up and do XShmPutImage.

From what I understand, any sort of m= map access to vmwgfx buffers is

tricky, because they end up being ba= cked by normal GL textures on the
host OS side (IIUC). So the single cop= y upload path in XShmPutImage
might be close to the ideal path for sw re= ndered content.

To be clear, I am fine having to manu= ally write ioctls for each driver, if
thats what it takes. But at this p= oint, I am at a loss on the best method to
share scannot buffers (or at = least in a way that doesn=E2=80=99t make someone cringe
when they see my= code).

Some sort of prepare/finish access i= octls for dmabuf to bracket mmap
access are, I think, what vmwgfx is mis= sing in order to implement
dmabuf mmap. But no one so far has needed the= m badly enough to come
up with something and send patches.

IIUC, for vmwgfx there would still be a copy back= to original texture
on the host on finish-access, so it might not amoun= t to anything much
different from XShmPutImage. Probably better to ask s= ome vmwgfx folks
to clarify, since the virtual driver has some unique co= nstraints which
I may not be adequately representing.

BR,
-R


Rian, for sharing acc= elerated buffers, They'd best be created with
Mesa's GBM, and shared usi= ng DRM prime. Those interfaces are generic and
AFAICT, Ubuntu's Mir work= s exactly this way. The problem is that the
client would need to link to= mesa, and could use GL / GLES to transfer
software contents to the buff= er.

For pure software contents, the server would shar= e a generic shared
memory buffer, together with a damage protocol, and c= omposite / copy
onto the framebuffer in the server.

In principle, as Rob says, the dma-buf shared usi= ng DRM prime has an
mmap() method, but none of the "big" drivers Intel, = Nouveau and Radeon
implements it, and for vmwgfx an implementation would= be extremely
inefficient. Also other drivers may have issues with write= -combining and
tiling of the mmap'ed framebuffer.

If both the server and client would be 100% softw= are one could create
and share "dumb" kms buffers using DRM prime. If th= ere's something in
the vmwgfx driver that blocks sharing in this way, we= could ease that
restriction. But these buffers could not be rendered in= to.

GEM is, BTW, purely driver-private.

As you might see, the big restriction here is tha= t there is no simple
generic way to mmap() accelerated shared buffers fr= om a lean client.
This is intentional. For vmwgfx it's because of cohere= ncy issues that
would make such an implementation inefficient. For other= drivers I can
imagine there are tiling- and caching issues.

/Thomas


Thanks,- Rian

_______________________________________________dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists= .freedesktop.org/mailman/listinfo/dri-devel

____________________________________= ___________
dri-devel mailing list
dri-devel@lists.freedesktop.orghttp://lists.freedesktop.org/mailman/listinfo/dri-devel



--=_F0A7F091-D08C-46D4-A151-30A19174B40E-- --=_03ED3B49-CFF8-4CE2-B963-B2A8F0F84F4B-- --===============2053495054== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============2053495054==--