Closing Textures OSX

Hello,

Is there a way to quickly close all open textures without closing the screen?
I noticed that there is not a CloseAllTextures screen command.

I am trying to present multiple unique animations in a row and am quickly building up
thousands of textures (and exceeding the current limit). I'd like to clear the previous
textures before starting each new animation without closing the screen. Looping through
so many individual 'Close' commands is very slow.

Thanks a lot,
Melissa Saenz
Caltech
Dear Mario,

Thanks a lot for investigating this issue with textures. I will try out your new code, but as
you suggested, I found a way around drawing so many textures using the new "DrawDots"
Screen command.

Thanks Again!
Melissa Saenz


--- In psychtoolbox@yahoogroups.com, "Mario Kleiner" <mario.kleiner@t...> wrote:
>
> Hello Melissa,
>
> i have added kind of a "CloseAllTextures" command to Screen:
>
> If you have a texture tex and want to close it, issue a
> Screen('Close', tex) command as you probably did in the past.
>
> If you want to close *all* open textures, but without closing the
> onscreen-window, issue a
> Screen('Close') command without parameters.
>
> For now, you can download the new Screen.mexmac - file, together with
> a small demo-
> script CloseTextureDemoOSX.m, from my FTP directory under:
>
> ftp://ftp.tuebingen.mpg.de/kyb/kleinerm/
>
> The new code has been pushed to Allen Ingling for inclusion into
> future official PTB
> releases.
>
> Unfortunately there isn't much speed gain in using the new command.
> As my tests ona
> PowerMac G5 1.6 Ghz show, when deleting 4000 128x128 pixel textures,
> you only save
> about 0.1 seconds compared to a for-loop in Matlab. This is because
> the time consuming
> part in releasing a texture is the deallocation of texture memory,
> not the call-overhead
> from Matlab. The speed of releasing textures therefore depends mostly
> on the size of the
> textures. Try the provided script for doing the measurements for
> yourself...
>
> In the future one might add a new command to Screen that allows the
> recycling of existing
> textures for multiple different movies, instead of freeing and
> recreating them. That might
> be faster...
>
> Could you explain what kind of stimuli you want to present for your
> experiments? For
> some types of stimuli/experiments, the new PTB allows for much better
> ways of doing it
> than the old way of pre-creating thousands of images as movie clips.
> Maybe there is a
> more elegant/faster solution for your experiment.
>
> ciao,
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "saenz_melissa"
> <saenz_melissa@h...> wrote:
> >
> >
> > Hello,
> >
> > Is there a way to quickly close all open textures without closing
> the screen?
> > I noticed that there is not a CloseAllTextures screen command.
> >
> > I am trying to present multiple unique animations in a row and am
> quickly building up
> > thousands of textures (and exceeding the current limit). I'd like
> to clear the previous
> > textures before starting each new animation without closing the
> screen. Looping
> through
> > so many individual 'Close' commands is very slow.
> >
> > Thanks a lot,
> > Melissa Saenz
> > Caltech

Hi All,

Does closing texture increase the efficiency of the code?

I have 20 images. I load them, make the corresponding textures, and draw these textures at various points in my study. I do not close a texture after Screen(‘Flip’), because I will present the same texture later on in the study. Does this slow down my script?

I checked the values returned by Screen(‘Flip’), e.g. VBLTimestamp, FlipTimestamp, Missed, etc. All looks fine, except for the random missed flips (if any). However, I may be missing something when it comes to closing textures, and I wanted to get your views on it.

Thanks a lot,
Natasa

In your case, no. 20 textures don’t use much memory, doing what you do is most efficient.

If you had many textures that you don’t reuse across trials, or similar, that could become a problem. Essentially when you have so many textures that the machine runs out of graphics memory and then slows down or malfunctions due to out of memory / low memory conditions.

E.g., creating 10 new textures every trial and not closing them at the end of a trial could cause a slow down as the experiment progresses into hundreds of trials. Or movie playback at 30 fps == 30 new textures every second of playback if you don’t close each movie texture after drawing it - that can suck up Gigabytes of RAM and spell trouble quickly.

-mario

1 Like