Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise for GCW-Zero #422

Closed
cxong opened this issue May 25, 2016 · 5 comments
Closed

Optimise for GCW-Zero #422

cxong opened this issue May 25, 2016 · 5 comments
Milestone

Comments

@cxong
Copy link
Owner

cxong commented May 25, 2016

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.

@cxong cxong modified the milestones: Polishing, 0.6.2 May 25, 2016
@carstene1ns
Copy link
Contributor

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.

@cxong
Copy link
Owner Author

cxong commented May 28, 2016

vsync shouldn't be set; I'm using SDL_CreateWindowAndRenderer which does not accept vsync flag.

@cxong
Copy link
Owner Author

cxong commented Jul 7, 2016

Some fixes for next release:

  • crash in dogfight/doom, dogfight/map01, deathmatch/doom, dogfight/map01
  • include copyright status of all campaigns

@cxong
Copy link
Owner Author

cxong commented Jul 10, 2016

According to xcode time profiler, 75% of time was spent in draw functions. Of these:

  • 35% in ColorToPixel()
  • 20% in main draw function (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.

cxong added a commit that referenced this issue Jul 12, 2016
cxong added a commit that referenced this issue Jul 14, 2016
cxong added a commit that referenced this issue Jul 19, 2016
Remove 3rd party dogfight maps
@cxong
Copy link
Owner Author

cxong commented Jul 20, 2016

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.

@cxong cxong closed this as completed Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants