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

Rewrite 2D drawing APIs #36

Open
trigger-segfault opened this issue Feb 19, 2022 · 1 comment
Open

Rewrite 2D drawing APIs #36

trigger-segfault opened this issue Feb 19, 2022 · 1 comment
Labels
graphics Relates to how graphics are rendered and displayed on screen. partially solved The issue is solved, but not in its entirety. performance Issue/PR aims to improve performance of the game. refactor A task that will improve code readability, without changing outcome.

Comments

@trigger-segfault
Copy link
Owner

Describe the issue

Both the Draw and Fonts modules are very poorly optimized, and can cause a massive hit in performance when overused.

Examples

  • When the Radar Map View is open.
  • When a ToolTip is showing.
  • When ObjInfo above units are showing.

Draw module

  • Consider reorganizing the use of Draw functions, so that all drawing happens in a single buffer lock/unlock. Maybe a spritebatch like with what's used in XNA (this would need to be implemented for all drawing-based modules).
  • None Effect: Fill rect and line functions should be replaced with BitBliting a 1x1 white pixel with scaling, colorization, and rotation to match the desired output.
  • HalfTrans Effect: Can probably be replaced with an added alpha value (around 0.5?) to get a close approximation to the actual pixel operation.
  • XOR Effect: Might be natively supported by BitBlit, but it has to be checked.

Font module

  • Optimizations for sprite fonts may be a lot trickier, since drawing is already done with BitBliting images from a sheet.
  • More research is needed to see where the bottlenecks are, and how they can be resolved.
@trigger-segfault trigger-segfault added graphics Relates to how graphics are rendered and displayed on screen. performance Issue/PR aims to improve performance of the game. labels Feb 19, 2022
@trigger-segfault trigger-segfault added the refactor A task that will improve code readability, without changing outcome. label Sep 2, 2022
@trigger-segfault
Copy link
Owner Author

With 9f9b9f6, there's now a significant performance improvement in rendering the radar map and Object UIs. All large groups of Draw calls have been combined into 4 different sessions for locking the drawing surface.

There's still a noticeable hit in the framerate when disabling the Draw module, but this is still a huge improvement. You can now play at above 60FPS with 9 units, the radar map open, and all Object UIs visible.

@trigger-segfault trigger-segfault added the partially solved The issue is solved, but not in its entirety. label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graphics Relates to how graphics are rendered and displayed on screen. partially solved The issue is solved, but not in its entirety. performance Issue/PR aims to improve performance of the game. refactor A task that will improve code readability, without changing outcome.
Projects
None yet
Development

No branches or pull requests

1 participant