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
[Impeller] simplify text shaders by moving UV computation to contents #39989
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
.aaaa * | ||
frag_info.text_color; | ||
vec4 value = texture(glyph_atlas_sampler, v_uv); | ||
if (v_has_color != 1.0) { |
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.
need to get rid of this too
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.
Perhaps this wouldn't be an issue if we just had separate atlases. Leaving for another day.
This shader is also almost what I need for flutter/flutter#121650 |
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.
LGTM! Super minor comments.
auto position = PositionForGlyphPosition( | ||
translation, point, glyph_position.glyph.bounds.size); | ||
vtx.uv = point * uv_scaler_a + uv_scaler_b; | ||
vtx.position = position; |
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.
I like that we're not passing as much needlessly interpolated data to the fragment shader anymore (🤢), but I wonder if the 16 byte savings per vertex is worth the extra per character CPU work. My guess is that it's worth it.
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.
you also have to pay the CPU cost of copying that extra data too. Its probably slightly more expensive on the raster side of things but hard to tell exactly.
Matrix(1, 0, 0, 0, // | ||
0, 1, 0, 0, // | ||
0, 0, 1, 0, // | ||
offset_glyph_position.x, offset_glyph_position.y, 0, 1); |
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.
Matrix::MakeTranslation
?
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.
Done
Size destination_size) { | ||
return translation * Vector4(unit_position.x * destination_size.width, | ||
unit_position.y * destination_size.height, 0.0, | ||
1.0); |
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.
Doesn't translation * (unit_position * destination_size)
work fine for this, or are we missing an overload somewhere? Size should get coerced to Point
.
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.
Done
This should improve performance without dramatically changing the raster thread cost - additionally allows us to upload less data.
Part of flutter/flutter#121732