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

Lepton Wu lepton at chromium.org
Sat May 26 04:28:15 UTC 2018


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