Click here to Skip to main content
16,016,537 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionHow is BitBlt implemented [modified] Pin
Force Code15-Nov-07 8:15
Force Code15-Nov-07 8:15 
AnswerRe: How is BitBlt implemented Pin
Luc Pattyn15-Nov-07 8:27
sitebuilderLuc Pattyn15-Nov-07 8:27 
GeneralRe: How is BitBlt implemented Pin
Force Code15-Nov-07 8:43
Force Code15-Nov-07 8:43 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn15-Nov-07 9:22
sitebuilderLuc Pattyn15-Nov-07 9:22 
GeneralRe: How is BitBlt implemented Pin
Force Code15-Nov-07 9:54
Force Code15-Nov-07 9:54 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn15-Nov-07 10:16
sitebuilderLuc Pattyn15-Nov-07 10:16 
GeneralRe: How is BitBlt implemented [modified] Pin
Force Code15-Nov-07 11:12
Force Code15-Nov-07 11:12 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn15-Nov-07 12:03
sitebuilderLuc Pattyn15-Nov-07 12:03 
Hi,

The optimization of image processing code is handled at the cycle level, that is why
C/assembly/MMX/SSE are required here. If you want to explain an approach in a higher level,
that is fine to express the concept, but for performance you must visualize the basic CPU
operations that will correspond.

if BYTE ROP[x][y][z] contains a random value, of course you need a table look-up.
At best, these are the basic operations that would occur (assume x,y,z in CPU registers):
copy x, shift it by 8 positions, add y to it, shift it by 8 positions, add z to it,
add the address of ROP[0][0][0] to it, do an indirect load; so that amounts to 6 simple
arithmetic operations and a load.

as long as the value of BYTE ROP[x][y][z] can be expressed as a function of x,y,z containing
less than say 6 logical operators the direct code would be faster, since it does not need
the load at all.

So what I am saying is this: on modern CPUs (Pentium class, RISC, and many others)
u= x&y | x^z | !y&z would be faster than u=ROP[x][y][z]
without any doubt, (say by a factor of 1.33 to 2)

From what you have shown so far, I can only conclude that you are a novice in
optimization stuff.
If you want to continue in this field, I recommend you study some code outside
the .NET Framework, and look at assemly code generated (a) by compilers, (b) by
manual optimization (e.g. look at the disassembled code of the strlen function, you
will find over 100 lines for something that most people would do, somewhat slower,
in less than 10 lines! The difference is not much, but that's mainly because strlen
is hard to parallellize, although there are MMX versions of it too).

Smile | :)



Luc Pattyn [Forum Guidelines] [My Articles]


this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google


GeneralRe: How is BitBlt implemented [modified] Pin
Force Code15-Nov-07 13:19
Force Code15-Nov-07 13:19 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn15-Nov-07 14:01
sitebuilderLuc Pattyn15-Nov-07 14:01 
GeneralI Completely agree with DQNOK Pin
CPallini16-Nov-07 4:25
mveCPallini16-Nov-07 4:25 
GeneralRe: I Completely agree with DQNOK Pin
Luc Pattyn16-Nov-07 6:08
sitebuilderLuc Pattyn16-Nov-07 6:08 
GeneralRe: How is BitBlt implemented Pin
Dan Neely15-Nov-07 10:48
Dan Neely15-Nov-07 10:48 
GeneralRe: How is BitBlt implemented Pin
DQNOK16-Nov-07 3:46
professionalDQNOK16-Nov-07 3:46 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn16-Nov-07 3:55
sitebuilderLuc Pattyn16-Nov-07 3:55 
GeneralRe: How is BitBlt implemented Pin
Force Code16-Nov-07 7:49
Force Code16-Nov-07 7:49 
GeneralRe: How is BitBlt implemented Pin
Luc Pattyn16-Nov-07 8:27
sitebuilderLuc Pattyn16-Nov-07 8:27 
GeneralRe: How is BitBlt implemented Pin
Skippums16-Nov-07 9:02
Skippums16-Nov-07 9:02 
GeneralRe: How is BitBlt implemented Pin
Force Code16-Nov-07 9:59
Force Code16-Nov-07 9:59 
GeneralRe: How is BitBlt implemented Pin
Jheriko++17-Nov-07 17:18
Jheriko++17-Nov-07 17:18 
GeneralRe: How is BitBlt implemented Pin
Alan Balkany29-Nov-07 4:46
Alan Balkany29-Nov-07 4:46 
GeneralRe: How is BitBlt implemented Pin
Mark Churchill19-Nov-07 14:58
Mark Churchill19-Nov-07 14:58 
GeneralRe: How is BitBlt implemented Pin
Force Code19-Nov-07 20:24
Force Code19-Nov-07 20:24 
AnswerRe: How is BitBlt implemented Pin
Chris Losinger19-Nov-07 4:36
professionalChris Losinger19-Nov-07 4:36 
AnswerRe: How is BitBlt implemented Pin
El Corazon20-Nov-07 5:04
El Corazon20-Nov-07 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.