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
Blitter line drawing improvements #7082
Blitter line drawing improvements #7082
Conversation
1b13a66
to
cc9af4d
Compare
src/blitter/common.hpp
Outdated
@@ -7,15 +7,18 @@ | |||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
/** @file base.cpp Implementation of the base for all blitters. */ | |||
/** @file base.hpp Common functionality for all blitter implemenytations. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base.hpp -> common.hpp
I found it difficult to measure the performance benefit of this. Using a busy savegame, the average ms per tick in the graphics rendering is pretty much the same (well within noise tolerance) between this PR and master. However over a 4 month period (showing the exact same view), master was 2 game days behind this PR. |
This is remove per-pixel overheads due to use of the SetPixel virtual method. These overheads included: * expensive virtual method call which prevents inlining * palette lookup for every pixel * branch on whether palette animation is enabled on every pixel Regenerate project files.
…off-screen work This clips the line segment to be within the screen area prior to pixel iteration.
I used this OpenTTDCoop savegame to test this: https://wiki.openttdcoop.org/ProZone:Archive_-_Games_11_-_20#gameid_13 |
cc9af4d
to
5deee94
Compare
I see this makes a huge difference when using 32bpp-anim! |
This removes per-pixel overheads due to use of the SetPixel virtual method.
These overheads included:
Avoid signed overflow when drawing long lines
Adjust line-drawing algorithm to reduce wasted off-screen work
This clips the line segment to be within the screen area prior to pixel iteration.
The performance improvement of these changes is quite noticeable when many link graph overlay lines are being rendered.