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

Optimisations for GCW-Zero, Pandora #500

Closed
cxong opened this issue Apr 23, 2017 · 10 comments
Closed

Optimisations for GCW-Zero, Pandora #500

cxong opened this issue Apr 23, 2017 · 10 comments
Labels

Comments

@cxong
Copy link
Owner

cxong commented Apr 23, 2017

No description provided.

@cxong cxong added the engine label Apr 23, 2017
@cxong cxong added this to the 0.6.6 milestone Apr 23, 2017
@cxong
Copy link
Owner Author

cxong commented May 21, 2017

capture
capture1
capture2
capture3
capture4
capture5
capture6

Profiling from visual studio on doom mission 3 shows update and draw both taking about 40% CPU. Expensive operations include:

  • DrawPlayerAreas (19.63%)
  • CameraDraw (17.58%)
  • DrawRadar (12.69%)
  • OverlapGetFirstItem (10.06%)
  • CommandBadGuys (9.75%)

Two obvious optimisations: HUD is unexpectedly expensive, even more expensive than drawing the game, and also the map has lots of actors so lots of the update expense is on basic updating and collision detection.

@cxong
Copy link
Owner Author

cxong commented May 22, 2017

FPS on GCW-Zero is about 8

cxong added a commit that referenced this issue May 23, 2017
@cxong
Copy link
Owner Author

cxong commented May 23, 2017

Update AI every 4 frames; this reduced the cost of UpdateAllActors, so approximately 3% speedup.
image
More can be done; on this mission there are about 114 enemies. Updating a fixed number of AIs per frame (say 10) should make the AI a fixed cost. This can be improved so that enemies closer to the players are prioritised.

Next most expensive function:

  • LOSCalcFrom (8.34%)

@cxong
Copy link
Owner Author

cxong commented Dec 27, 2017

New profiling:

image

Areas to improve:

  • 13.62% DrawPlayerAreas etc. - pre-draw map, use events like explore to update dynamically
  • 11.61% DrawFloor - can pre-draw floor as one texture and drawing separately
  • 8.95% OverlapGetFirstItem - consider not updating everything 70 times per second and using interpolation
  • 7.51% DrawWallsAndThings - need more investigation; possibly mark particles as "dead" and permanently bake them into the floor?

cxong added a commit that referenced this issue Feb 2, 2018
@cxong
Copy link
Owner Author

cxong commented Feb 6, 2018

Optimised DrawFloor by drawing as textures - percent of time dropped to 1.22%. Strangely now the whole game takes 75% CPU instead of 99% before.

image

One side effect is that the blob shadows need to be redone otherwise they don't show up properly over the floor.

  • Fix blob shadows

cxong added a commit that referenced this issue Feb 6, 2018
cxong added a commit that referenced this issue Feb 6, 2018
@cxong
Copy link
Owner Author

cxong commented Feb 7, 2018

Some of the optimisations have to do with rendering textures instead of to a pixel array. However we still need to render to a single "surface", for the game background and for the editor. But in this case, we should be using SDL_SetRenderTarget, so that the drawing code doesn't change. Replace the renderToTex parameters added recently.

cxong added a commit that referenced this issue Feb 7, 2018
cxong added a commit that referenced this issue Feb 7, 2018
Don't move window when resizing
Fix background texture rendering
Note: editor redraw still broken
cxong added a commit that referenced this issue Feb 8, 2018
@cxong
Copy link
Owner Author

cxong commented Feb 11, 2018

image

Converted more blitting functions to use texture rendering. This has dropped DrawWallsAndThings from 8% down to 4%, although strangely total CPU has dropped to 50% and DrawDebris has gone up from 2% to 4%. Maybe there's some extra graphics latency here?

This has also introduced some graphics glitches. Map objects like barrels appear behind walls - perhaps walls are still being blitted. "Background" tinted objects like gas clouds no longer look right, will need to redo them.

cxong added a commit that referenced this issue Feb 11, 2018
cxong added a commit that referenced this issue Feb 11, 2018
cxong added a commit that referenced this issue Feb 11, 2018
cxong added a commit that referenced this issue Feb 18, 2018
@cxong
Copy link
Owner Author

cxong commented Feb 22, 2018

image
Profiling results after character blitting converted to texture renders. Curiously the overall draw time hasn't reduced by much, although DrawFloor has shot up.

Need to benchmark under GCW-Zero; perhaps there is too much slowdown caused by rendering many small textures. Switching to texture atlases may be necessary.

cxong added a commit that referenced this issue Feb 22, 2018
@cxong
Copy link
Owner Author

cxong commented May 5, 2018

Unfortunately performance on GCW-Zero has become worse, at about 6fps.

@cxong cxong modified the milestones: Grenade Button (and optimisations?), 0.6.8 May 5, 2018
@cxong cxong modified the milestones: 0.6.9, 0.6.10 Oct 30, 2018
@cxong cxong modified the milestones: 0.7, 0.7.1 Dec 5, 2018
@cxong cxong modified the milestones: 0.8, Backlog Jan 22, 2019
@cxong cxong removed this from the Backlog milestone Aug 7, 2019
@cxong
Copy link
Owner Author

cxong commented Sep 15, 2019

Abandoning this for now; will possibly revisit once we look into a handheld platform again

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

No branches or pull requests

1 participant