Welcome! Log In Create A New Profile

Advanced

When is it safe to delete a texture buffer?

Posted by ArminTamzarian 
When is it safe to delete a texture buffer?
February 12, 2009 08:48PM
Okay, so I'm running into an issue with the development of one of my libraries and figured I may as wella sk ehre in case anyone else has the same question.

So I have a memalign'ed buffer with pretty little RGBA8 format (or other) texture data. I create a GXTexObj and load the texture data into it with GX_InitTexObj. Next I load the texture object with GX_LoadTexObj and draw the texture to a quad with the GX_Begin/GX_End functions.

Now, all is well and good but as what point can I safely free the originally memalign'ed buffer and not cause a rendering error somewhere in the display pipeline? The main thing I'm trying to avoid is for the rendering engine to not try to display a texture buffer which has been freed somewhere prior.

So, any thoughts?
Re: When is it safe to delete a texture buffer?
February 12, 2009 09:00PM
Someone else would know better, but I think these three functions would help:

GX_Flush(); GX_DrawDone(); GX_WaitDrawDone();

I think calling these after GX_End() is sufficient?
Re: When is it safe to delete a texture buffer?
February 14, 2009 02:35PM
Hi Armin,

DevKitPro have a CVS repository over at SourceForge.net with the GX source. Unfortunately, it's a bit of a mess to wade through. I think the way that the texture rendering works is that it's all pointers until GX_DrawDone(), and even then I'm not sure that the textures are safe to change, since the pointers are added to a hardware FIFO queue handled by the GPU rather than the main PPC processor, and after each GX_Flush() the whole thing has to get redrawn anyway.

To be on the safe side, I would leave the texture in memory until your last relevant call to GX_Flush(). I know it might be a bit of a waste of space-time to leave it there, but I think that's just the price you pay for complicated texture rendering.



Edited 1 time(s). Last edit at 02/14/2009 02:37PM by Myu0.
Re: When is it safe to delete a texture buffer?
February 15, 2009 06:51PM
DevkitPro CVS is no longer updated. DevkitPro SVN is now used.
Sorry, only registered users may post in this forum.

Click here to login