Tidying-up resources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Tidying-up resources

hendikon
What's the preferred way to clean-up resources ?

I have an island which has an object which does some GPU computations with a FBO, which I would like to handle to cleanup of when the island shuts-down, or when my CroquetParticipant is closed.
Reply | Threaded
Open this post in threaded view
|

Re: Tidying-up resources

Joshua Gargus-2
When the CroquetParticipant is closed, the OpenGL context is destroyed, so any FBO associated with that context will also be destroyed.  I don't believe that Cobalt has the capability to unload islands that have been loaded (I may be mistaken on this point).  So, given Cobalt's current capabilities, you should already be covered.

If you're concerned about the "right way" to do this sort of thing as Cobalt develops, there is some code that points the way...

OGLTextureManager has some commented-out code in #cleanup (which is sent every frame)... the intent is that when the texture corresponding to the low-level OpenGL handle has been garbage collected, the low-level handle should also be destroyed.  This is accomplished by using a "weak reference": a reference that is treated differently by Squeak's garbage collector.  A weak reference does not prevent an object from being garbage-collected; when garbage collection occurs, all weak references now point to nil instead of the reclaimed object.  I don't recall why that code is commented out.

Another bit of code to look at is KTransientHandleManager.  This isn't hooked up in the default Cobalt browser, but works fine in the KAT demo.

I won't go into detail on this point (since it has been addressed very well on this list in the past), but be aware that things like GPU computations should be done "off-island", otherwise you will break the invariant that makes Croquet work: that each replica of an island evolves identically over time.  

I'm curious, what are you doing with FBOs?

Josh




On Apr 14, 2008, at 3:10 AM, matthew chadwick wrote:
What's the preferred way to clean-up resources ?

I have an island which has an object which does some GPU computations with a FBO, which I would like to handle to cleanup of when the island shuts-down, or when my CroquetParticipant is closed.

Reply | Threaded
Open this post in threaded view
|

Re: Tidying-up resources

hendikon
Thankyou for the answer.

>
> I'm curious, what are you doing with FBOs?


Computing the evolution of a dynamical system. The aim is to use the CPU
by default, but use the GPU if available for a higher-resolution view of
the system.
Reply | Threaded
Open this post in threaded view
|

Re: Tidying-up resources - GPUs

hendikon

>
>
> The aim is to use the CPU by default, but use the GPU if available for
> a higher-resolution view of the system.
>

correcting myself, I meant to say: "use the GPU's FBO & GLSL
capabilities if present".


I've adapted some of David Faught's procedural texturing code to do
pingpong work.