Skip to content

glamor: xv: UYVY and RGB24 support

Andrey Zhadchenko requested to merge azhadchenko/xserver:glamor_xv into master

These changes are focused on glamor_xv major improvements.

First of all, Xv currently calls glamor_xv_free_port_data at the end of every putimage. This leads to shader recompilation for every frame, which is a huge performance loss. With this patch, glamor_xv_free_port_data is called only if width, height or format is changed for xv port. Also, the shader is moved to port instead of being global to xv.

Added UYVY format. Y U and V planes are constructed during put image and drawn the same way as yv12. I tried several UYVY -> RGB shaders to escape plane copying, but all of them showed a quality loss.

Added RGB24 format. However, glamor uses GL_BGRA (or GL_RGBA or whatever) for 24 depth formats in glamor_create_fbo and glamor_upload_boxes. To draw rgb24 we need to pass GL_RGB format to gl. I added glamor_create_pixmap_fmt function to create pixmap with the desired format (instead of the format being guessed depending on depth) and updated glamor_create_fbo and glamor_upload_boxes to use pixmap->fmt to use format type based on pixmap format instead of depth. A bit reworked glamor format handling so it is possible to have multiple formats for the same depth now.

Also, some aligns in glamor_xv are very strict. For example, valid YUV video may be 246x180 pixels, but it won't pass ALIGN(*w >> 1, 4) and will be torn (although many video players, such as MPlayer, internally expanding video to 256x180 before uploading). Moreover, 246x180 video U and V planes will have 123x90 R8 pixmaps and won't fit in GL_UNPACK_ALIGN==4 so I set it to GL_UNPACK_ALIGN==1. This also affects RGB videos, since they may not be aligned to 4 due to 3 bytes per pixel.

Merge request reports