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

Add support for property functions in line-color #2938

Merged
merged 1 commit into from
Aug 18, 2016

Conversation

lucaswoj
Copy link
Contributor

@lucaswoj lucaswoj commented Aug 3, 2016

... and pave the way for all other line properties

This PR

  • adds support for line-color property functions
  • builds the infrastructure needed for making other line properties support property functions

The naive implementation of line-color property functions was too slow, prompting me to investigate ways to reduce the perf overhead of setting uniforms per tile. We need to set uniforms per tile as if each were a different GL program because different tiles may actually require different GL programs due to a pending asynchronous operation.

My solution was a Painter#setUniforms(uniforms: Object) method, something I've been thinking about writing for a while anyway as part of #145 (needed for #281).

ref #2729

cc @mollymerp @mourner

@@ -347,6 +359,12 @@ LineBucket.prototype.addLine = function(vertices, join, cap, miterLimit, roundLi
startOfLine = false;
}

this.populatePaintArrays(
'line', {zoom: this.zoom},
feature.properties,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only use feature.properties, should we pass featureProperties in the outer function directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored in the next commit.

@mourner
Copy link
Member

mourner commented Aug 5, 2016

This looks great overall. How are the benchmarks looking?

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Aug 5, 2016

The benchmarks are looking pretty good. I was seeing around 5% slowdown in frame-duration, everything else 0%. I think setUniforms is the source of the slowdown and there are opportunities to make it faster, as you pointed out above. #2938 (comment)

@mollymerp
Copy link
Contributor

Daaang awesome job keeping perf 🏃 !

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Aug 8, 2016

Branch Benchmarks

7.2 ms, 0% > 16ms
7.6 ms, 1% > 16ms
7.2 ms, 0% > 16ms

Master Benchmarks

frame-duration:

8.5 ms, 11% > 16ms
6.7 ms, 0% > 16ms
6.6 ms, 0% > 16ms
6.5 ms, 0% > 16ms

EDIT: The previous master benchmark was a bit of an anomaly. Updated data above.

@lucaswoj
Copy link
Contributor Author

I got this running as fast or faster than master but there's a lingering test-suite failure that I can't understand. Any ideas @mourner?

@lucaswoj
Copy link
Contributor Author

I found the problem with line-dasharray long-segment and fixing it regressed all the perf gains. Pperf hasn't improved at all since the initial implementation in cd78412. I recommend we consider merging that as-written.

@mourner
Copy link
Member

mourner commented Aug 18, 2016

fixing it regressed all the perf gains

Interesting, what was the fix about? It's hard to tell because of the rebased commit.

@lucaswoj
Copy link
Contributor Author

Ah! My apologies. I've gotten into the habit of squashing bugfixes. I'll unsquash and push so you can see. In short, there was a mistake leading to early loop termination. The performance gains / losses make a lot of sense.

@lucaswoj
Copy link
Contributor Author

The fix for the test is in 62564e8. It's obvious how this led to artificial performance gains 😢

I am going to remove all ineffective perf optimizations from this branch, leaving only the initial commit.

@mourner
Copy link
Member

mourner commented Aug 18, 2016

Oh wow. It's fascinating that this was caught by just a single obscure test. :) It may be worth adding a "functional" render test that renders a relatively detailed map tile with all stuff at once to catch things like this.

I agree that we can merge this now — the changes look good, and we can follow-up with perf improvements later if they're possible.

@lucaswoj
Copy link
Contributor Author

It may be worth adding a "functional" render test that renders a relatively detailed map tile with all stuff at once to catch things like this.

Yes! mapbox/mapbox-gl-test-suite#26

@sguignot
Copy link

@lucaswoj Thanks for this :)
Is there a way to use directly the color from a 'color' property of the feature?

Note: I made a few tests using categorical stops but it's a bit heavy when rendering railways from OSM since they use hundreds of different colors in some areas.

@lucaswoj
Copy link
Contributor Author

@sguignot the closest thing is a proposal for identity functions mapbox/mapbox-gl-function#20. PRs welcome!

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

Successfully merging this pull request may close these issues.

None yet

4 participants