After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770585 - glupload: propose dma buffer pool upstream based on ion allocator
glupload: propose dma buffer pool upstream based on ion allocator
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 768794
Blocks:
 
 
Reported: 2016-08-30 08:22 UTC by Haihua Hu
Modified: 2018-11-03 11:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
propose dma buffer pool upstream based on ion allocator (11.12 KB, patch)
2016-08-30 08:25 UTC, Haihua Hu
needs-work Details | Review

Description Haihua Hu 2016-08-30 08:22:48 UTC
1. Propose ion dma-fd buffer pool to upstream
2. If upstream don't choose the proposed buffer pool, then create our own and do buffer copy to avoid memory copy from CPU to GPU side
3. Add buffer alignment
Comment 1 Haihua Hu 2016-08-30 08:25:02 UTC
Created attachment 334412 [details] [review]
propose dma buffer pool upstream based on ion allocator
Comment 2 Haihua Hu 2016-08-30 08:27:48 UTC
ion allocator is in upstream progress in another thread:
https://bugzilla.gnome.org/show_bug.cgi?id=769962
Comment 3 Matthew Waters (ystreet00) 2016-08-30 11:36:32 UTC
Review of attachment 334412 [details] [review]:

Why is all this needed?  What's wrong with upstream setting all this information?  What kind of elements are upstream?

::: gst-libs/gst/gl/gstglupload.c
@@ +849,2 @@
   /* This will eliminate most non-dmabuf out there */
+  if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer, 0))) {

What's the difference between this failure case and the raw data uploader?

@@ +980,3 @@
+#endif
+  if (!allocator) {
+    GST_WARNING ("New ion allocator failed.");

This warning will occur on all non-ion platforms.

@@ +990,3 @@
+    goto setup_failed;
+
+  gst_query_set_nth_allocation_pool (query, 0, pool, info.size, 1, 30);

Why were these numbers (1, 30) chosen?
Comment 4 Haihua Hu 2016-08-30 12:17:33 UTC
(In reply to Matthew Waters (ystreet00) from comment #3)
> Review of attachment 334412 [details] [review] [review]:
> 
> Why is all this needed?  What's wrong with upstream setting all this
> information?  What kind of elements are upstream?

Hi Matthew, I'am so sorry that I have paste the wrong link to ion allocator thread which is should be:
https://bugzilla.gnome.org/show_bug.cgi?id=768794

> 
> ::: gst-libs/gst/gl/gstglupload.c
> @@ +849,2 @@
>    /* This will eliminate most non-dmabuf out there */
> +  if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer, 0))) {
> 
> What's the difference between this failure case and the raw data uploader?

In the failure case, glupload will create a local dmabuf pool and copy data to dmabuf so that eglimage can import this dmabuf. While raw data will copy date to PBO and use PBO upload texture. This two case is the same in most cases but except some embedded system. For these platforms, PBO has some hardware limitation such as only specical format(RGBA) can use DMA transform texture from PBO to GPU and other format will fallback to CPU copy. This will impact performance.

> 
> @@ +980,3 @@
> +#endif
> +  if (!allocator) {
> +    GST_WARNING ("New ion allocator failed.");
> 
> This warning will occur on all non-ion platforms.

Will change to use DEBUG

> 
> @@ +990,3 @@
> +    goto setup_failed;
> +
> +  gst_query_set_nth_allocation_pool (query, 0, pool, info.size, 1, 30);
> 
> Why were these numbers (1, 30) chosen?

We have a use case in which playbin will load libav decoder for video decoder. libav decoder will not respect the downstream video alignment and use his own. This will cause eglCreateImage fail because hardware memory alignment limitation. But libav decoder will reject this buffer pool when max buffer nums less than 32, so we set it to 30 and let libav decoder reject our buffer pool and we do buffer copy in glupload.
Comment 5 Matthew Waters (ystreet00) 2016-08-30 14:25:20 UTC
(In reply to Haihua Hu from comment #4)
> (In reply to Matthew Waters (ystreet00) from comment #3)
> > Review of attachment 334412 [details] [review] [review] [review]:
> > 
> > Why is all this needed?  What's wrong with upstream setting all this
> > information?  What kind of elements are upstream?
> 
> Hi Matthew, I'am so sorry that I have paste the wrong link to ion allocator
> thread which is should be:
> https://bugzilla.gnome.org/show_bug.cgi?id=768794

That does not answer the questions.

> > 
> > ::: gst-libs/gst/gl/gstglupload.c
> > @@ +849,2 @@
> >    /* This will eliminate most non-dmabuf out there */
> > +  if (!gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer, 0))) {
> > 
> > What's the difference between this failure case and the raw data uploader?
> 
> In the failure case, glupload will create a local dmabuf pool and copy data
> to dmabuf so that eglimage can import this dmabuf. While raw data will copy
> date to PBO and use PBO upload texture. This two case is the same in most
> cases but except some embedded system. For these platforms, PBO has some
> hardware limitation such as only specical format(RGBA) can use DMA transform
> texture from PBO to GPU and other format will fallback to CPU copy. This
> will impact performance.

dmabuf doesn't create the memory though, ion does.  While they are somewhat similar in purpose, they do slightly different things.

> > 
> > @@ +990,3 @@
> > +    goto setup_failed;
> > +
> > +  gst_query_set_nth_allocation_pool (query, 0, pool, info.size, 1, 30);
> > 
> > Why were these numbers (1, 30) chosen?
> 
> We have a use case in which playbin will load libav decoder for video
> decoder. libav decoder will not respect the downstream video alignment and
> use his own. This will cause eglCreateImage fail because hardware memory
> alignment limitation. But libav decoder will reject this buffer pool when
> max buffer nums less than 32, so we set it to 30 and let libav decoder
> reject our buffer pool and we do buffer copy in glupload.

Erm, that's not going to fly.  What should happen is that the bufferpool should fail setting the config with the unaligned size of which the easiest thing is to propose a separate pool with the ion allocator.  At which point it makes more sense to write a new upload method for ion than shoehorn this into the dmabuf allocator.

Another question, what hardware/software are you testing on?  Will this work on any hardware that supports ion?
Comment 6 Haihua Hu 2016-09-05 06:54:09 UTC
(In reply to Matthew Waters (ystreet00) from comment #5)
> 
> Erm, that's not going to fly.  What should happen is that the bufferpool
> should fail setting the config with the unaligned size of which the easiest
> thing is to propose a separate pool with the ion allocator.  At which point
> it makes more sense to write a new upload method for ion than shoehorn this
> into the dmabuf allocator.
> 
> Another question, what hardware/software are you testing on?  Will this work
> on any hardware that supports ion?

You mean we need to implement a new buffer pool which is specific for ion buffer and override _set_config() vmethod to make it fail to set the unaligned size? As a result, we need to write a new uploader for ion dma-buf.

We are testing this plugin on imx soc for linux, this patch will be useful on the platform which has ion support.
Comment 7 Matthew Waters (ystreet00) 2016-09-05 12:22:49 UTC
(In reply to Haihua Hu from comment #6)
> (In reply to Matthew Waters (ystreet00) from comment #5)
> > 
> > Erm, that's not going to fly.  What should happen is that the bufferpool
> > should fail setting the config with the unaligned size of which the easiest
> > thing is to propose a separate pool with the ion allocator.  At which point
> > it makes more sense to write a new upload method for ion than shoehorn this
> > into the dmabuf allocator.
> 
> You mean we need to implement a new buffer pool which is specific for ion
> buffer and override _set_config() vmethod to make it fail to set the
> unaligned size? As a result, we need to write a new uploader for ion dma-buf.

Yes to all that.

> > Another question, what hardware/software are you testing on?  Will this work
> > on any hardware that supports ion?
>
> We are testing this plugin on imx soc for linux, this patch will be useful
> on the platform which has ion support.

Ok.
Comment 8 Matthew Waters (ystreet00) 2018-05-05 21:11:02 UTC
Is this still being worked on?
Comment 9 GStreamer system administrator 2018-11-03 11:49:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/287.