DrawBitmap causes unusable frame rate

So I am only on episode 50 - way way before Casey addresses optimisation.

However since Casey added the background bitmap, each frame ramps up to 130+ ms a frame making the game unusable. I've been getting around this by simply removing the background and the hero draw only hits the ms a small amount so I have left that in.

Specifically its the bitwise operators when performing the linear blend that is causing the speed issues.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
float sr = (float)((*source >> 16) & 0xFF);
float sg = (float)((*source >> 8) & 0xFF);
float sb = (float)((*source >> 0) & 0xFF);

float dr = (float)((*dest >> 16) & 0xFF);
float dg = (float)((*dest >> 8) & 0xFF);
float db = (float)((*dest >> 0) & 0xFF);

float r = (1.0f - a) * dr + a * sr;
float g = (1.0f - a) * dg + a * sg;
float b = (1.0f - a) * db + a * sb
;

I only have a laptop i7 running @ 1.90Ghz but surely it can handle something this simple? Interestingly it seems to only cause a big problem when built with Visual Studio. If I build using Casey's bat file, the slow down isn't as bad.

I am not too sure why this would be? I can't identify what flag Casey has set that I haven't set in Visual Studio that would cause this? Since he has Od set which disables any optimisations!?

Any one had this issue or have any ideas how I can make this more usable without turning on optimisations?

Edited by Jay on
Try /Oi (Optimization -> Enable Intrinsic Functions) and /fp:fast (Code Generation -> Floating Point Model = Fast) options.

Anyways - it is not about handling something simple. The question is how many such simple things CPU needs to handle. If you are drawing millions of pixels, then even the simplest thing for each pixel can add up to significant time.
That did help thanks. But still only running at 50ms a frame when built with VS compared to building with Casey's build script but I'll have to keep investigating.
Maybe that's because your laptop is only dual-core? Casey has 8 cores from which HH uses 6. So you are seeing 6/2 = 3x larger frame time.
mmozeiko
Maybe that's because your laptop is only dual-core? Casey has 8 cores from which HH uses 6. So you are seeing 6/2 = 3x larger frame time.

Unlikely. At that point in HH, the renderer is not multithreaded. The only difference extra cores would have is slightly less contention between processes.

That said, even the individual cores on Casey's machine are pretty beefy, so that's probably part of the issue. You might just need to reduce the resolution you render at, Jay, until you're using the optimized renderer.