Skip to content

perf(native): faster color blending#870

Open
AnatoleLucet wants to merge 1 commit intoanomalyco:mainfrom
AnatoleLucet:perf/cell-blending
Open

perf(native): faster color blending#870
AnatoleLucet wants to merge 1 commit intoanomalyco:mainfrom
AnatoleLucet:perf/cell-blending

Conversation

@AnatoleLucet
Copy link
Copy Markdown

@AnatoleLucet AnatoleLucet commented Mar 24, 2026

follow up to #865 (only the last commit is relevant)

this pr makes a small change to the color blending function (roughly 4x faster now) which improves prefs for draw calls with translucent colors and for postprocessing draws (drawSuperSampleBuffer, drawGrayscaleBuffer, etc).

i replaced the use of std.math.pow with a faster approximate pow.
the approximate pow is a not 100% accurate so the result does not fully match std.math.pow but for color blending the change is (very) hardly noticeable.

benchmark (left with std.math.pow, right with approximate pow) image (running on my laptop so take it with a grain of salt)
color comparison (left with std.math.pow, right with approximate pow)
screenrecording-2026-03-24_15-46-04.mp4

@simonklee
Copy link
Copy Markdown
Member

This would replace #498, since you make the same change. in general i would try to limit this to one-idea per pr. You both add a bunch of early outs + replace the pow in this one.

@simonklee
Copy link
Copy Markdown
Member

I've triggered a run for your branch at https://opentui-bench.fly.dev/ ~30 min and it should show up there.

@AnatoleLucet
Copy link
Copy Markdown
Author

This would replace #498, since you make the same change. in general i would try to limit this to one-idea per pr. You both add a bunch of early outs + replace the pow in this one.

yeah sorry i hope the fact it's a follow up of #865 doesn't make it harder to review. i just preferred to open a separate pr since color blending felt unrelated. i'll add the opacity benchmark in #865 instead so both pr can be merged separately. but we won't have the benchmarks on this branch.

i'll remove the condition that's already covered by #498 :) did you stumble on anything that stopped you from merging that pr, or was it just forgotten?

@AnatoleLucet
Copy link
Copy Markdown
Author

i added a separate benchmark here for color blending / translucency, and moved the box opacity benchmark to #865. hope it's clearer now, sorry about that

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.

2 participants