GL rendering is hideously inefficient compared to kmssink.
The Pi has very efficient composition hardware (the Hardware Video Scalar) for taking any number of YUV and RGB formats and resizing/composing them into an output frame. This what kmssink is linking to.
For GL composition you are converting the YUV image into an RGB texture in order to be passed through to 3D hardware which is then told to render it onto a flat surface. When you think that every YUV frame at 1080P is ~3MB, and an RGBA frame is ~8MB, at 30fps (60fps for rendering) this becomes a large hit on SDRAM bandwidth.
The support for YUV within Mesa and GL is a relatively recent addition - if you're using standard Raspbian Stretch libraries then it's probably horribly out of date.
You can get a gain by reducing the overhead of the texture conversion. GStreamer's v4l2videoconvert component can use the ISP hardware to do the YUV to RGB conversion, and downscale the image. Unfortunately it can't write out to the tile format that the 3D hardware wants, so there is still a significant overhead there. If you haven't got the absolute latest GStreamer with https://github.com/GStreamer/gst-plugin ... 4c7b3d7994
then you'll need to set the "disable_bayer=1" kernel module parameter on bcm2835-codec to get GStreamer to acknowledge that the driver does match v4l2videoconvert.
Code: Select all
gst-launch-1.0 -vv -e filesrc location=foo.mkv ! matroskademux ! h264parse ! v4l2h264dec capture-io-mode=4 ! v4l2videoconvert output-io-mode=5 capture-io-mode=4 ! video/x-raw,format=BGRA,width=640,height=360 ! glimagesink
Reducing to 640x360 gives barely usable playback. 1080P renders a few frames.
The majority of effort in getting VLC and Chromium to play reasonably has been down to minimising the amount of work that X11 has to do. A custom pipeline is created within the app to resize to exactly the right size for the window, and the right colour format, and then X only has to do a blit into the frame buffer. Even this starts straining some parts of the system.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.