Commit Graph

622 Commits

Author SHA1 Message Date
faiface 4137f87f22 clarify Rect.Intersect doc 2017-07-05 19:58:09 +02:00
faiface bee65f5833 add Rect.Intersect 2017-07-05 19:54:30 +02:00
faiface 46e79f21b9 add Rect.Area 2017-07-05 19:54:18 +02:00
faiface 99573a5f1e optimize ToRGBA (weird one) 2017-07-03 00:23:07 +02:00
faiface c23446fb49 improve sprite.Draw(batch) benchmark 2017-07-03 00:22:45 +02:00
faiface 578ae8fa53 fix bug in text benchmark 2017-07-02 23:26:26 +02:00
faiface 6af6195bd0 optimize Drawer (reduce map access) 2017-07-02 23:23:27 +02:00
faiface 0c28c0785e add text benchmarks 2017-07-02 19:35:56 +02:00
faiface 17f735c2d0 remove unnecessary reassign in color benchmarks 2017-07-02 19:26:43 +02:00
faiface 7629b6ef5e add imdraw benchmarks 2017-07-02 19:22:40 +02:00
faiface ae0526fda0 add ToRGBA, sprite.Draw(batch) and Matrix benchmarks 2017-07-02 19:04:20 +02:00
Michal Štrba 80cfdfcb6a Merge pull request #40 from aerth/master
Use travis-ci
2017-06-16 01:14:23 +02:00
aerth b01300dab9
move button 2017-06-15 23:05:00 +00:00
aerth c078a58652
Link to travis build 2017-06-15 22:52:47 +00:00
aerth b58d6bf5ec
add travis config 2017-06-15 22:40:37 +00:00
faiface 75ab96923c another minor code style change 2017-06-11 14:14:02 +02:00
faiface 2a9b7e5210 minor code style change 2017-06-11 14:06:45 +02:00
faiface 79c5d20194 Merge branch 'dev' 2017-06-11 01:19:57 +02:00
faiface e6484064aa one more tiny doc change 2017-06-11 01:18:23 +02:00
faiface 3fcad7503f minor doc changes 2017-06-11 01:17:37 +02:00
Michal Štrba 1545bd7af5 Merge pull request #38 from seebs/master
more performance tweaks
2017-06-11 01:12:03 +02:00
Seebs 0dc27e409b Push: Don't convert pixel.RGBA to pixel.RGBA
Because that's expensive, even in the case where the conversion
is trivial. Use type assertion first. Reduces runtime cost of
imdraw.Push from ~15.3% to 8.4%, so not-quite-50% of runtime
cost of pushing points.

If you were setting imd.Color to Color objects that aren't RGBA
every single point, not much help. But if you set it and then
draw a bunch of points, this will be a big win.
2017-06-10 17:56:15 -05:00
Seebs f2ef87f198 Improve normal calculations
Soooo. It turns out that the bunch of smallish (~4-5% of runtime)
loads associated with Len(), Unit(), Rotated(), and so on... Were
actually more like 15% or more of computational effort. I first
figured this out by creating:

	func (u Vec) Normal(v Vec) Vec

which gives you a vector normal to u->v. That consumed a lot
of CPU time, and was followed by .Unit().Scaled(imd.thickness / 2),
which consumed a bit more CPU time.

After some poking, and in the interests of avoiding UI cruft,
the final selection is
	func (u Vec) Normal() Vec

This returns the vector rotated 90 degrees, which turns out to
be the most common problem.
2017-06-10 17:55:16 -05:00
Seebs ef6a44fef8 Slightly clean up normal calculations
We never actually need the "normal" value; it's an extra calculation
we didn't need, because ijNormal is the same value early on. It's
totally possible that we could further simplify this; there's a lot
of time going into the normal computations.
2017-06-10 10:47:22 -05:00
Seebs 9a6e6066bd don't call Len() when it can't change
updateData()'s loops checking gt.Len() turns out to have been costing
significant computation, not least because each call then in turn
called gt.vs.Stride().
2017-06-10 10:47:18 -05:00
faiface 7ebbf7e9b5 switch back to OpenGL 3.3 (OS X issues) 2017-06-10 15:11:45 +02:00
faiface 31fc049ab7 optimize GLTriangles SetLen and Update 2017-06-10 01:10:59 +02:00
faiface c331fe2583 Merge branch 'master' into gl2.1 2017-06-09 19:26:14 +02:00
faiface 6b9ea45e96 minor, mostly stylistic, changes 2017-06-09 18:13:05 +02:00
Michal Štrba 2e4c6018c9 Merge pull request #36 from seebs/master
revised performance tuning pull request
2017-06-09 18:04:25 +02:00
Seebs 7215265523 Don't duplicate computations in gltriangles.go
The computation including a call to Stride() can't be optimized away
safely because the compiler can't tell that Stride() is effectively
constant, but we know it won't change so we can make a slice pointing
at that part of the array.

CPU time for updateData goes from 26.35% to 18.65% in my test case.
2017-06-09 10:37:47 -05:00
Seebs fc858bff4d Reduce copying in fillPolygon
A slice of points means copying every point into the slice, then
copying every point's data from the slice to TrianglesData. An
array of indicies lets the compiler make better choices.
2017-06-09 10:37:47 -05:00
Seebs 918031892a smaller imdraw optimizations
For polyline, don't compute each normal twice; when we're going through a line,
the "next" normal for segment N is always the "previous" normal for segment
N+1, and we can compute fewer of them.
2017-06-09 10:37:47 -05:00
Seebs 9a7ab1c6b0 use point pool
For internal operations (anything using getAndClearPoints), there's a
pretty good chance that the operation will repeatedly invoke something
like fillPolygon(), meaning that it needs to push "a few" points
and then invoke something that uses those points.

So, we add a slice for containing spare slices of points, and on the
way out of each such function, shove the current imd.points (as used
inside that function) onto a stack, and set imd.points to [0:0] of
the thing it was called with.

Performance goes from 11-13fps to 17-18fps on my test case.
2017-06-09 10:37:47 -05:00
Seebs 34cdd8729b Simplify Matrix math, use 6-value affine matrixes.
It turns out that affine matrices are much simpler than the 3x3 matrices
they imply, and we can use this to dramatically streamline some code.
For a test program, this was about a 50% gain in frame rate just from
the cost of the applyMatrixAndMask calls in imdraw, which were calling
matrix.Project() many times. Simplifying matrix.Project, alone, got a
nearly 50% frame rate boost!

Also modify pixelgl's SetMatrix to copy the six values of a 3x2
Affine into the corresponding locations of a 3x3 matrix.
2017-06-09 10:37:43 -05:00
Seebs 0358330d3b The initializer is surprisingly expensive.
Removing the call to Alpha(1) and replacing it with an inline definition
produces measurable improvements. Replacing each instance of ZV with
Vec{} further improves things. We keep an inline RGBA because there
are circumstances (mostly when using pictures) where we don't want to
have to set colors to get default behavior.

For a fairly triangle-heavy thing, this reduces time spent in SetLen
from something over 10% of execution time to around 2.5% of execution
time.
2017-06-07 21:25:54 -05:00
faiface 4b7553cd73 add maze generator community example 2017-05-30 13:30:09 +02:00
faiface 781c44f119 add text tutorial link to README 2017-05-30 02:53:24 +02:00
faiface c385b247b3 add 07 guide code 2017-05-30 02:52:33 +02:00
faiface 3706d040ce fix typo in doc 2017-05-28 18:50:56 +02:00
faiface 4749e3ee7e add Canvas.Frame method 2017-05-28 18:44:30 +02:00
faiface e06acda99b minorly simplify typewriter example 2017-05-28 00:06:29 +02:00
faiface 9e0c65d8dd remove profiling from typewriter example 2017-05-27 19:19:31 +02:00
faiface f80edafc7b remove profiling from typewriter example 2017-05-27 19:14:25 +02:00
faiface 67a69d96d6 switch to OpenGL 2.1 2017-05-27 13:14:13 +02:00
faiface bbeab0aebf update 06 guide code 2017-05-26 21:26:06 +02:00
faiface d5f7088b7d update 05 guide code 2017-05-26 14:04:44 +02:00
faiface 9a401948ae remove accidentaly set theme 2017-05-25 22:51:17 +02:00
Michal Štrba abc99bdef8 Set theme jekyll-theme-time-machine 2017-05-25 20:03:02 +02:00
faiface debdbea894 limit ttf face glyphcacheentries size in typewriter example 2017-05-25 15:21:28 +02:00