cairosink and gpu buffer sharing (gstreamer conference 2013)
TRANSCRIPT
![Page 2: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/2.jpg)
ongoing experiment, I may not have the best answers yet
![Page 3: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/3.jpg)
Work sponsored by Samsung Research Americahttp://www.sisa.samsung.com/
![Page 4: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/4.jpg)
I. Technologies, past and present
![Page 5: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/5.jpg)
Cairo: 2D graphicsCairogles: 2D graphics in OpenGL(ES)
![Page 6: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/6.jpg)
support for EGL/GLX/WGL
![Page 7: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/7.jpg)
Sharing video buffers: before
- Add a specific cap (e.g. video/x-raw-gl) - subclass GstBuffer
![Page 8: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/8.jpg)
Sharing video buffers: nowadays
- GstContext - GstVideoGLTextureUploadMeta - GstAllocator and GstMemory
![Page 9: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/9.jpg)
- GstContext, system to share a GL context and more between elements - GstVideoGLTextureUploadMeta: a way to tell how to upload a buffer to GPU - GstAllocator and GstMemory: cleaner way to handle non-CPU memory
![Page 10: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/10.jpg)
Sharing video buffers: nowadays
"modern" gl(es) sink implementationsknown to the author: - eglglessink (and libgstegl) - glimagesink
![Page 11: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/11.jpg)
II. Integrating cairogles and GStreamer
![Page 12: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/12.jpg)
Many possibilities: - xvimagesink + GstVideoOverlay - eglglessink - glimagesink - make our own sink
![Page 13: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/13.jpg)
xvimagesink with overlay: not so fast, I suspect it triggers a download to CPU to get the image from xvimagesink's Drawable to a cairo-gl surface. eglglessink: promising, but obviously doesn't support openGL or GLX glimagesink started work on proper integration, likely will require addition of a few features there
![Page 14: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/14.jpg)
First attempt:a cairosink that does everything
![Page 15: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/15.jpg)
Cairosink: status
- GstAllocator and GstMemory subclasses - Use either OpenGL or OpenGLES - Possibility to use PixelBuffer Objects (PBOs) (inefficiently)
![Page 16: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/16.jpg)
allocator and memory not that useful as it's the only element using it. Main advantage: _could_ allow to start uploading the frame as soon as possible. PBOs in a nutshell: a way to asynchronously upload a frame to a texture. The upload is then done through the magic of DMA, without the CPU being involved. More on why cairosink is currently inefficient at using it later. FIXME: graph explaining PBO?
![Page 17: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/17.jpg)
Cairosink: simplistic benchmark
![Page 18: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/18.jpg)
![Page 19: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/19.jpg)
Synchronous / PBO / XV XV: limited by refresh rate? Looks like its genuine limit (often below 60) frames 720x400, RGB or YUV
![Page 20: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/20.jpg)
Cairosink: difficulties (or rants)
- cairogles can be compiled with either gl or glesv2 (not both) - driver bugs and regressions - cairo only supports RGB - desktop vs mobile GPUs
![Page 21: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/21.jpg)
driver regression: GL+EGL used to work on my machine...
![Page 22: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/22.jpg)
Desktop vs mobile GPU
- EGLMakeCurrent() is costly on many mobile GPUs/drivers - bandwidth differences
![Page 23: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/23.jpg)
context acquisition (makeCurrent) slowness is likely to counter the effects of asynchronous direct upload
![Page 24: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/24.jpg)
Cairosink: what's to do - more flexibility on code path - compatibility with other elements (not our own memory/allocator)
![Page 25: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/25.jpg)
we want to be able to tailor to various GPUs various "options": is it faster to do a synchronous or asynchronous upload?
![Page 26: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/26.jpg)
Cairosink: other ideas to explore - libgstgl backend (ongoing experiment) - wrapper around glimagesink
![Page 27: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/27.jpg)
libgstgl issues: mechanism to MakeCurrent() or save/restore states share GMainContext? (all in one thread)
![Page 28: Cairosink and GPU Buffer Sharing (GStreamer Conference 2013)](https://reader033.vdocuments.net/reader033/viewer/2022042701/55a28e651a28ab09588b46f8/html5/thumbnails/28.jpg)
Thank youQuestions?