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 720336 - plugins: implement GLTextureUploadMeta user data copy
plugins: implement GLTextureUploadMeta user data copy
Status: RESOLVED FIXED
Product: gstreamer-vaapi
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
Depends on:
Blocks: 719412 720727 720728
 
 
Reported: 2013-12-12 17:11 UTC by Matthieu Bouron
Modified: 2013-12-19 16:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
plugins: implement GLTextureUploadMeta user data copy (1.48 KB, patch)
2013-12-12 17:12 UTC, Matthieu Bouron
none Details | Review
plugins: implement GLTextureUploadMeta user data copy (1.81 KB, patch)
2013-12-18 17:36 UTC, Gwenole Beauchesne
none Details | Review

Description Matthieu Bouron 2013-12-12 17:11:31 UTC
This patch makes the copies of a buffer reference their own GLTextureUploadMeta user data and prevent the original buffer accessing already freed memory if its copies has been released and freed.
Comment 1 Matthieu Bouron 2013-12-12 17:12:44 UTC
Created attachment 264091 [details] [review]
plugins: implement GLTextureUploadMeta user data copy
Comment 2 Gwenole Beauchesne 2013-12-18 17:32:47 UTC
Why not make it a real copy, i.e. also referencing the newly created texture, instead of creating yet another?
Comment 3 Gwenole Beauchesne 2013-12-18 17:36:41 UTC
Created attachment 264493 [details] [review]
plugins: implement GLTextureUploadMeta user data copy

Does this patch work for you?
Comment 4 Matthieu Bouron 2013-12-18 18:05:56 UTC
(In reply to comment #2)
> Why not make it a real copy, i.e. also referencing the newly created texture,
> instead of creating yet another?

There is no guarantee that the texture handle you will provide to the upload function will be the same, this is why I didn't try to copy the existing texture.
Comment 5 Gwenole Beauchesne 2013-12-18 18:43:12 UTC
Do you mean there are cases when we would just recycle the texture id with other characteristics e.g. dimensions?

BTW, that hurts performance. We'd need a way to notify the consumer of the upload() function to prefer a strategy where he would try to re-use the texture.
Comment 6 Matthieu Bouron 2013-12-18 19:08:58 UTC
(In reply to comment #5)
> Do you mean there are cases when we would just recycle the texture id with
> other characteristics e.g. dimensions?
> 
> BTW, that hurts performance. We'd need a way to notify the consumer of the
> upload() function to prefer a strategy where he would try to re-use the
> texture.

Indeed.

(In reply to comment #3)
> Created an attachment (id=264493) [details] [review]
> plugins: implement GLTextureUploadMeta user data copy
> 
> Does this patch work for you?

It works thanks :)
Comment 7 Gwenole Beauchesne 2013-12-19 05:36:19 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Do you mean there are cases when we would just recycle the texture id with
> > other characteristics e.g. dimensions?
> > 
> > BTW, that hurts performance. We'd need a way to notify the consumer of the
> > upload() function to prefer a strategy where he would try to re-use the
> > texture.
> 
> Indeed.

So, the only case where it could fail is if the texture id is recycled, i.e. glDeleteTexture() + glGenTExtures() to get the same id again, and if the associated size is changed.

We could additionally check for dimensions changes in _upload() and not just texture id. However, this causes the GL pipeline to block (glGet*). Therefore, an efficient way to solve that could be to let the caller notify upload, through extra arguments, of the relevant dimensions. This causes API/ABI changes.

We could also mandate, i.e. define and document, that once we established the texture info, it should not change through subsequent upload() calls.

> (In reply to comment #3)
> > Created an attachment (id=264493) [details] [review] [details] [review]
> > plugins: implement GLTextureUploadMeta user data copy
> > 
> > Does this patch work for you?
> 
> It works thanks :)

At least, it works the same as before. :)
Comment 8 Gwenole Beauchesne 2013-12-19 10:02:56 UTC
(In reply to comment #6)
> > Created an attachment (id=264493) [details] [review] [details] [review]
> > plugins: implement GLTextureUploadMeta user data copy
> > 
> > Does this patch work for you?
> 
> It works thanks :)

Pushed it to git master branch. Thanks.
Comment 9 Gwenole Beauchesne 2013-12-19 10:23:15 UTC
(In reply to comment #7)
> So, the only case where it could fail is if the texture id is recycled, i.e.
> glDeleteTexture() + glGenTExtures() to get the same id again, and if the
> associated size is changed.
> 
> We could additionally check for dimensions changes in _upload() and not just
> texture id. However, this causes the GL pipeline to block (glGet*). Therefore,
> an efficient way to solve that could be to let the caller notify upload,
> through extra arguments, of the relevant dimensions. This causes API/ABI
> changes.
> 
> We could also mandate, i.e. define and document, that once we established the
> texture info, it should not change through subsequent upload() calls.

I opened bug #720728 to track the status of this case since I am going to close this present bug.
Comment 10 Gwenole Beauchesne 2013-12-19 10:23:54 UTC
While we are at it, another optimization is also possible and tracked in bug #720727
Comment 11 Gwenole Beauchesne 2013-12-19 16:31:43 UTC
commit bf8f244de3262c782f425252afe919dbad0f554b
Author: Matthieu Bouron <matthieu.bouron@collabora.com>
Date:   Thu Dec 12 17:01:29 2013 +0000

    plugins: implement GLTextureUploadMeta user data copy.
    
    Makes the copies of a buffer reference their own GLTextureUploadMeta
    user data and prevent the original buffer accessing already freed
    memory if its copies has been released and freed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720336
    
    [Propagate the original meta texture to the copy too]
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>