From: Rian Quinn Subject: Re: Sharing Framebuffers between Client / Server Date: Mon, 20 Jan 2014 05:22:13 -0800 (PST) Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0274243425==" Return-path: Received: from mail-ie0-f173.google.com (mail-ie0-f173.google.com [209.85.223.173]) by gabe.freedesktop.org (Postfix) with ESMTP id B0F06FABA2 for ; Mon, 20 Jan 2014 05:22:14 -0800 (PST) Received: by mail-ie0-f173.google.com with SMTP id e14so8182818iej.4 for ; Mon, 20 Jan 2014 05:22:14 -0800 (PST) In-Reply-To: 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: Rob Clark Cc: Thomas Hellstrom , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============0274243425== Content-Type: multipart/alternative; boundary="=_CC6E90CD-6CA9-43D7-A15C-A3C8F4D0275B" --=_CC6E90CD-6CA9-43D7-A15C-A3C8F4D0275B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks for reply.=C2=A0 Actually in my case, when I say client/server, I mean replacement for X, so= XShmPutImage won=E2=80=99t work. What we are trying to do is actually simi= lar to Wayland, and need to provide each client with a scannot buffer for d= irect rendering, while at the same time, providing a means for the server t= o read/write to all of the scannot buffers.=C2=A0 We have looked into EGL (EGL_DRM_BUFFER_USE_SCANOUT_MESA), but I have yet t= o code this up (will likely work on that this week), to see if it will work= for us. We started with an example that we found, that was coded wrong in many ways= . The biggest issue though, was that the buffer allocated using libkms coul= d not be shared. We also looked into drmAddBuf / drmMapBuf, from what I cou= ld tell, nobody was using them. GEM seems to be the option of choice but vm= wgfx doesn=E2=80=99t support that yet. Thanks, - Rian Sent with Unibox > On Jan 20, 2014, at 8:10 AM, 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 h= as >> 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 t= his 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 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 kern= el. >>=20 >>=20 >>=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 > 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 metho= d to >> share scannot buffers (or at least in a way that doesn=E2=80=99t make so= meone cringe >> when they see my code). >>=20 >>=20 >>=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 >> Thanks, >> - Rian >>=20 >>=20 >> _______________________________________________ >> dri-devel mailing list >> dri-devel@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/dri-devel >>=20 >>=20 >>=20 --=_CC6E90CD-6CA9-43D7-A15C-A3C8F4D0275B Content-Type: multipart/related; boundary="=_02159DC1-7AD1-4F5F-A15C-13D926AE26E6" --=_02159DC1-7AD1-4F5F-A15C-13D926AE26E6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Thanks for reply.=C2=A0

Actually in my case, when I say client/server, I = mean replacement for X, so XShmPutImage won=E2=80=99t work. What we are try= ing to do is actually similar to Wayland, and need to provide each client w= ith a scannot buffer for direct rendering, while at the same time, providin= g a means for the server to read/write to all of the scannot buffers.=C2=A0

We have looked into EGL (EGL_DRM_BUFFER_USE_SCANOUT_MESA), but I= have yet to code this up (will likely work on that this week), to see if i= t will work for us.

=
We started with an example that we found, that was coded wrong in many w= ays. The biggest issue though, was that the buffer allocated using libkms c= ould not be shared. We also looked into drmAddBuf / drmMapBuf, from what I = could tell, nobody was using them. GEM seems to be the option of choice but= vmwgfx doesn=E2=80=99t support that yet.

Thanks,
- Rian<= /div>


Sent wit= h Unibox

On Jan 20, 2014, at 8:10 AM, Rob Clark <robdclark@gmail.com> wrote:

On Fri, Jan 17, 2014 at 6:43 AM, Rian Quinn <r= ianquinn@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 which uses dri2 under the hood)
would probably be what I su= ggest *except* you mention mmap. If you
are doing software rendering, I = guess you probably just want to suck
it up and do XShmPutImage.

From what I understand, any sort of mmap access t= o vmwgfx buffers is
tricky, because they end up being backed by normal G= L 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.

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 ioctls for dmabuf to bracket mmap
access are, I think, wha= t 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.

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

Thanks,
- Rian

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

--=_02159DC1-7AD1-4F5F-A15C-13D926AE26E6-- --=_CC6E90CD-6CA9-43D7-A15C-A3C8F4D0275B-- --===============0274243425== 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 --===============0274243425==--