Closed cxong closed 8 years ago
I have not looked at the source code since the SDL2 port yet, but just a random thought: Is VSYNC enabled? It may be either in C-Dogs or SDL2 itself. This can cause a major slowdown.
vsync shouldn't be set; I'm using SDL_CreateWindowAndRenderer
which does not accept vsync flag.
Some fixes for next release:
According to xcode time profiler, 75% of time was spent in draw functions. Of these:
ColorToPixel()
DoBuffer()
)The ColorToPixel()
call comes from a for loop to clear the screen, so this is a very obvious optimisation. Looks like a memset 0 will suffice.
The next most expensive thing is BlitMasked()
, due to the pixel conversions. Pixel conversions should be avoided wherever possible; it appears a lot of them come from the line-of-sight shadow renders. A cheap and old-school way to speed this up would be to render a shadow made of alternating black and fully-transparent pixels. Another method would be to pre-generate shadow versions of tiles and render them.
It seems fps is still about 30, despite the recent optimisations. It can be raise to 40 if blood is turned off. It might be harder to optimise from this point on; the next candidate would be things like #440 and removing all the per-pixel draw calls. Some game code could be optimised too; 4 player deathmatch only runs at 5 fps.
Performance should have been greatly improved after the SDL2 port, at least for high screen resolutions. However, the game still runs at 30fps, including some choppiness, on GCW-Zero.
C-Dogs is still fundamentally a simple game, so it's likely that the game is simply doing some inefficient things, and may be able to run the full 70fps. Do some profiling using 320x240 resolution, and see what the bottlenecks are.