[virglrenderer-devel] Need advices for adding yv12 image support to virgl

Lepton Wu lepton at chromium.org
Sat May 26 04:43:18 UTC 2018


Some other ideas which could be for discussion:

Adding some new ioctl which could be used to create multi plane buffers.
 From user space, it's a big buffer. But inside kernel, it's backed by
several virgl object. And
mmap will "concatenate" buffers of these virgl objects. We also need some
new ioctl which could be used to get "sub" texture from this big "yv12"
object to make mesa
happy. Is this the right way to go?

On Fri, May 25, 2018 at 9:28 PM Lepton Wu <lepton at chromium.org> wrote:

> Hi,

> I'de like to use virgl for android inside emulator. The main issue I am
> hitting now is "yv12" format support for apps like youtube.  Now I have
> some hack to make it working, the basic idea is like this:

> Android is use gralloc (actually compiled from code of minigbm) to get
yb12
> format  "bo".  So actually there is only one gl texture behind that bo.
And
> eglCreateImageKHR will import this YUV buffer and setup
>     a sampler that does the conversion to RGBA.  But since there is only
one
> gl texture behind that "bo", so actually the sampler are using same one GL
> texture to do convert.  So we need multiple different host gl texture
> from same one guest buffer. Now my hack is:

> gbm_bo_create  will create  3 virgl resources when it's yv12 format. And
> more, it will get the global name of the resource for u and v plane and
> write them at end of  memory for plane y.
> gbm_bo_map will map y plane first, and get global name for u plane and y
> plane and also map them.
> gbm_bo_flush will copy data from  y buffer( apps will write u and y data
to
> y buffer since they are treating it as yuv buffer) to u buffer and v
buffer
> which was setup in bo_map.

> Also add a hack at virgl_drm_winsys_resource_create_handle, if the offset
> is not zero, get global bo name of u and v planes from y buffer and then
> get the actual res_handle for u,v texture.  With this hack, finally I can
> get
> youtube app show "right" color sometimes.

> But over all, this sounds like a hack. I guess it won't be accepted
> upstream. Do you have any suggestion/advice for adding yv12 (or more
> generally, multi plane image format) to virgl?

> Thanks!


More information about the virglrenderer-devel mailing list