Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / 16 bit fixed point slower than 32 bit? Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Peter Bone

March 18, 2005, 05:55 AM

I realized that I only need 16 bit integers for my gouraud shader; so I changed it to use 16 bit instead of 32 bit expecting it to speed it up a lot. However, it made it slightly slower! Why is this? Is it because the processor is designed to work in 32 bit so it's having to convert to 32 bit each time?
Sorry, I'm a self taught programmer - never learnt about processors.

Thanks

Peter Bone

 
Victor Widell

March 18, 2005, 06:58 AM

The processor is designed for 32 bits, so it won't be much faster with 16 bits. But If your memmory band width becomes a bottle neck, then the decrease in memmory can speed things up a lot.

 
Chris

March 18, 2005, 09:40 AM

Did you code in assembly yourself ? If not, the compiler might use 16 bit registers for all those unsigned shorts you use. But using 16 bit registers is much slower than using the full 32 bits.

It'll only be a speedup if you can manage to shade two pixels at once by fitting two of them into one register. Or even four using the 64 bit MMX registers. But you've got to code assembly yourself to do it, the compilers are nowhere near doing such things themselves.

 
Peter Bone

March 19, 2005, 01:52 PM

I'm not using assembly. I'm programming in basic Delphi code. I'll just stick with the 32 bit integers then (until I learn asm). It's still pretty fast anyway.
Thanks for your help.

 
Chris

March 19, 2005, 02:11 PM

The Delphi compiler ist incredibly fast, but severly sucks at hard-core optimizing such things. You won't get decent performance with it using 16 bit data types.
It's simply not Delphi's main target, Borland aimed at an entirely different market segment when launching Delphi.

 
fiero

March 19, 2005, 06:26 PM

The conversion of colors RGB for the calculation gouraud is quicker in 32 bits because the colors are separated in bytes. In 16 bits it is necessary to make displacements to calculate the RGB, to calculate the color and then make displacements to convert to 16 bits the result again. More calculations in 16 bits, slower.

un saludo

 
This thread contains 6 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.