# OSX: Much faster MakeTexture / DrawTexture available for testing...

**URL:** <https://psychtoolbox.discourse.group/t/osx-much-faster-maketexture-drawtexture-available-for-testing/948>\
**Category:** Uncategorized\
**Created:** [January 5, 2005, 7:13am UTC](https://psychtoolbox.discourse.group/t/osx-much-faster-maketexture-drawtexture-available-for-testing/948 "2005-01-05T07:13:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [January 5, 2005, 7:13am UTC](https://psychtoolbox.discourse.group/t/osx-much-faster-maketexture-drawtexture-available-for-testing/948/1 "2005-01-05T07:13:23Z")

</div>

Hello everybody, Allen, Jan and Lisa,  
  
if you are not happy with the current speed of Screen('MakeTexture') and   
Screen('DrawTexture') in PTB OS-X 1.0.40, please read on. In all other   
cases: Sorry for spamming ;)  
  
At a boring sunday afternoon i had a look at the Sourcecode of OS-X   
Psychtoolbox Release 1.0.40. I had some ideas on how to improve the   
speed of the Screen('MakeTexture') and Screen('DrawTexture') commands,   
implemented and tested it and first results look good to me:  
  
Depending on the size and format of the image matrix (Double matrix or   
uint8 matrix, Luminance image, Luminance+Alpha image, RGB image or   
RGB+Alpha image) the new MakeTexture - implementation is between 3 and   
10 times faster than the one currently contained in PTB 1.0.40.  
  
e.g., a 800 x 800 pixels uint 8 grayscale image takes 3 Milliseconds to   
process compared to 36 ms in the standard implementation, a 800 x 800   
pixels double RGB+Transparency image takes 78 ms compared to 207 ms in   
the standard implementation...  
  
The speed of DrawTexture is also more consistent: For images whose width   
is divisable by 8, my implementation is about 10-20% slower, but for all   
other image sizes its between 2 and 3 times faster.  
  
A few small bugs have also been fixed...  
  
This code has been extensively tested and benchmarked with a wide   
variety of texture formats, but only on a single machine, a Single   
processor PowerMac G5 1.6 Ghz, 256 MB RAM, NVidia GeForce graphics card   
with 64MB VRAM on MacOS-X 10.3.7.  
  
Now, i need some volunteers for testing the code on other machines,   
especially ones with more RAM memory, ATI-Radeon graphics cards and G4   
processors to see if it is consistently faster and bug-free(TM), or if   
it needs more work. My goal/hope is obviously that Allen Ingling   
integrates the new implementation in one of the next Psychtoolbox releases.  
  
Please find a Zip file with all the necessary files (A Readme file, the   
new Screen.mexmac file, the Source code of the modified routines and   
some Benchmarkscripts and Demos) on our FTP-Server under:  
  
ftp://ftp.tuebingen.mpg.de/kyb/kleinerm/FastPTBScreen.zip  
  
You need to replace the Screen.mexmac file in your PTB Folder with the   
file in the ZIP file to test. Please also test it with your experiment   
code for some real-world testing additionaly to the benchmark script.  
  
Please report success/failure either to the Psychtoolbox-Forum and/or to   
me ( mario.kleiner at tuebingen.mpg.de )  
  
An explanation of what has been changed in the code can be found in the   
.c source files in code comments that are prefixed with "MK:", but   
basically it boils down to some texture rotation trick and optimizations   
of the C code of MakeTexture...  
  
I've also got a few more ideas for further improvements of the   
performance of DrawTexture / MakeTexture, but first this code needs to   
be successfully tested / integrated.  
  
If you've got questions regarding this thingy, feel free to e-mail me.  
  
Happy new year & happy testing :-)  
-mario  
  
  
--   
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Mario Kleiner  
Max Planck Institute for Biological Cybernetics  
Spemannstr. 38  
72076 Tuebingen  
Germany  
  
e-mail: [mario.kleiner@...](mailto:mario.kleiner@...)  
office: +49 (0)7071/601-742  
fax: +49 (0)7071/601-616  
www: [http://www.kyb.tuebingen.mpg.de/~kleinerm](http://www.kyb.tuebingen.mpg.de/~kleinerm)  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
"Debugging is twice as hard as writing the code in the first place.  
Therefore, if you write the code as cleverly as possible, you are,  
by definition, not smart enough to debug it." - Brian W. Kernighan
