Subject: I need some help to fully understand the buffers design

From: Eleni Maria Stea <[email-masked]>
Date: Thu, 04 Apr 2013 11:06:58 +0300

Hello everyone :)

I am trying to create an SDL backend for mir so that mir can run inside
X using SDL functions for the display/input handling. For the buffer
exchange part, I tried to use the existing GBM at first, as some people
suggested, but after some tests I did outside mir, it seems that you
can't have the GBM/DRM working under X (you cannot create the gbm device).

Since, in the current implementation the client and the server can only
exchange drm or android buffers, I have to create a 3rd type of buffers
that can use the same IPC mechanism with the gbm/android ones. I would
really really appreciate if you could give me a high level overview of
the buffers design to save me some time!

Thanks a lot!!
Eleni

---

From: Daniel van Vugt <[email-masked]>
Date: Thu, 04 Apr 2013 16:11:00 +0800

If we can't find a way to work it into the existing GBM implementation 
then we might need to resolve this first:
   https://bugs.launchpad.net/mir/+bug/1118909

---

From: Kevin DuBois <[email-masked]>
Date: Thu, 04 Apr 2013 08:22:50 -0700

We will need an implementation of mg::Display that sits on top of the 
SDL/X api. This is how mir's final composition would posted to the screen.

As for the "3rd type" of buffers, the buffers in gbm/android are color 
buffers backed by memory we got from the driver platforms that have 
certain capabilities. (The buffers must be usable as EGLImages, 
transmittable over ipc, mappable for usage in the driver as a GL target) 
I'm unaware of anything in SDL that has this capability, as SDL is (as 
my understanding goes) more of a cross-platform toolkit.

I haven't dived as deep into the problem as you, but I still think that 
the crux of the problem is to create the display type, and then figure 
out the permissions on the GBM buffers so that X and Mir can both 
operate under the same roof

Cheers,
Kevin

---

From: Eleni Maria Stea <[email-masked]>
Date: Fri, 05 Apr 2013 01:49:33 +0300

On 04/04/2013 06:22 PM, Kevin DuBois wrote:
> transmittable over ipc, mappable for usage in the driver as a GL
> target) I'm unaware of anything in SDL that has this capability, as
> SDL is (as my understanding goes) more of a cross-platform toolkit.
I think that the SDL capabilities are not an issue since I probably can
create the EGL images from GLES2 textures

>
> I haven't dived as deep into the problem as you, but I still think
> that the crux of the problem is to create the display type, and then
> figure out the permissions on the GBM buffers so that X and Mir can
> both operate under the same roof

Ok! I will check it again and see if I can find a way to make this work! :-)

Thank you,
Eleni

---

From: Christopher James Halse Rogers <[email-masked]>
Date: Fri, 05 Apr 2013 08:46:23 +0011

Hey Eleni!

> can't have the GBM/DRM working under X (you cannot create the gbm 

I can't off the top of my head think of a reason why gbm wouldn't work 
under X. You *would* need to manually authenticate your drm fd with 
DRI2Authenticate, because nothing is going to do it for you. That's 
probably why you were finding that you couldn't create the gbm device.

> the buffers design to save me some time!

As I mentioned on IRC, I think this is the perfect time to divorce 
buffer allocation and display, as they're really separate concerns. 
We'll want to do this anyway to support Mir-on-Mir without having to do 
Android-Mir-on-Android-Mir and GBM-Mir-on-GBM-Mir. Then you wouldn't 
have to handle the buffer allocation/passing stuff, just the display.

---

From: Eleni Maria Stea <[email-masked]>
Date: Sat, 06 Apr 2013 02:41:40 +0300

Hello!

> probably why you were finding that you couldn't create the gbm device.

I experimented a bit more with the gbm under X11 issue, today and it
turns out that it might be possible after all to use gbm buffers under
X11 given sufficient user privileges... I want to determine which exact
privileges are required (hopefully only device file permissions!:p) and
try again! I will also use the DRI2Authenticate. when I come back (i am
on holidays now). It seems that Kevin's right :)

> We'll want to do this anyway to support Mir-on-Mir without having to
> do Android-Mir-on-Android-Mir and GBM-Mir-on-GBM-Mir. Then you
> wouldn't have to handle the buffer allocation/passing stuff, just the
> display.
>
I totally agree with this!

Thank's a lot and have a nice weekend!
Eleni