Re: problem with first use of a copied pipeline layer texture not freeing, subsequent textures do free



Hi Lionel,
I understand your point, but I'm seeing the video memory (using TechPowerUp GPU-Z to monitor it) go up when I display a full screen texture, not go down when I delete it, then display a small postage stamp sized texture and memory does not go down.  Video memory does not go down after that strangely until I display several other big textures, then delete them all.   To keep memory down due to what looks like a bug to me I display a dummy 1x1 texture at the start of the program and delete it, then start the test.  Also on destruction of my actors, I set the pipeline  layer 0 texture to NULL before unreffing the pipeline.  As you can see below the memory usage is more level, even if a little higher at some points.  I'm not sure why memory stays so flat with my hack but it seems there is still some ref holding going on but not on that first allocated texture.  It still seems that something is not quite right or at the very least it is quite confusing.

Here's a running case:
From a baseline memory of "start"
display full HD screen texture:     mem: start + 8Mb
delete the texture:                 mem: start + 8Mb
display same full screen texture:   mem: start + 16Mb
delete the texture:                 mem: start + 16Mb
display a small texture:            mem: start + 6Mb
delete the small texture            mem: start + 6Mb
display same full screen texture:   mem: start + 6Mb
delete full screen texture:         mem: start + 6Mb
display 3 1kx1k new textures:       mem: start + 18Mb
delete 3 textures:                  mem: start + 10Mb
display a small texture             mem: start + 2Mb
delete the small texture:           mem: start + 2Mb

With my hacks:

display full HD screen texture:     mem: start + 8Mb
delete the texture:                 mem: start + 8Mb 
display same full screen texture:   mem: start + 8Mb
delete the texture:                 mem: start + 8Mb
display a small texture:            mem: start + 8Mb
delete the small texture            mem: start + 8Mb
display same full screen texture:   mem: start + 8Mb
delete full screen texture:         mem: start + 8Mb
display 3 1kx1k new textures:       mem: start + 20Mb
delete 3 textures:                  mem: start + 2Mb
display a small texture             mem: start + 2Mb
delete the small texture            mem: start + 2Mb

Reza


On Wed, Apr 20, 2016 at 3:08 PM, Lionel Landwerlin <llandwerlin gmail com> wrote:
Hi Reza,

It seems that the backend will keep a reference to the last pipeline
used :

https://git.gnome.org/browse/cogl/tree/cogl/driver/gl/cogl-pipeline-ope
ngl.c#n1390


My understanding is that this is done to limit the amount of state that
needs to be flushed onto the driver for every pipeline you draw with.

I suppose if you draw one more time with a different pipeline, it would
get rid of that reference and dispose the texture attached to it.

As far as I know, pipelines are not immutable. Although you might want
to pretend they are for example if you are deriving for a complex
pipeline with many copies on which you just change one property. 

Cheers,

-
Lionel

On Mon, 2016-04-18 at 16:22 -0700, Reza Ghassemi wrote:
> Hi,
> I'm cc'ing this question to the clutter  mailing list because the
> cogl mailing list has very little traffic
> ----
>
> I am either using pipelines incorrectly or found a problem in cogl
> pipeline
> layer code.  Are they really supposed to be treated as immutable
> after
> you've rendered with them?  I just read that in check-in comments and
> that
> is not how I programmed my code.  In this problem case I'm not making
> a
> change after rendering so the immutability is moot.  But changing
> them like
> adding/removing a layer does seem to work with the same pipeline.
>
> The following occurs ONLY on the first Actor I create with a new or
> copied
> pipeline.  All additional actors with a new or copied pipeline do not
> cause
> a leak.
>
> First case: I'm creating a pipeline, setting a texture on layer 0,
> drawing
> with it, then later unreffing the pipeline.  It seems that the
> pipeline
> would be freed but the texture did not because a pipeline layer held
> a
> reference to it.  I inserted a
> cogl_pipeline_set_layer_texture(pipeline, 0,
> NULL) in my code just before unreffing the pipeline and voila the
> texture
> was freed.
>
> In another version of the code I copy a pipeline, setting a texture
> on
> layer 0, drawing with it, then later unreffing the pipeline. It 
> seems
> again that the pipeline would be freed but the texture did not
> because a
> pipeline layer held a reference to it.  I inserted a
> cogl_pipeline_set_layer_texture(pipeline, 0, NULL) in my code just
> before
> unreffing the pipeline, but in this case the texture is not unreffed
> and
> freed.  In the routine _cogl_pipeline_set_layer_texture_data() for
> some
> reason for just the first actor and pipeline copy it takes the (new
> !=
> layer) condition and doesn't unref the texture which is done in the
> else
> clause (/* If the original layer we found is currently the authority
> on
> ...) for all subsequent actors / pipeline copies.
>
> Unfortunately if you have for the first actor and pipeline a
> 1024x1024
> texture and activate the atlas then you get a 2048x2048 atlas (16Mb
> of GPU
> RAM) that doesn't free up when the actor and pipeline copy is
> destroyed.
>
> Could anyone help me out here?
>
> Thanks,
>
> Reza
> _______________________________________________
> clutter-list mailing list
> clutter-list gnome org
> https://mail.gnome.org/mailman/listinfo/clutter-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]