Switch from `Float32` to `Uint16` for encoding colors in buffers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Currently we use a pair of `Float32` values to represent a color value in WebGL buffers:
https://github.com/mapbox/mapbox-gl-js/blob/4eeefaee04b92ebfb18f5b9bc1626264b4f03779/src/data/program_configuration.js#L169-L170
Using a pair of `Uint16` instead should be enough precision while cutting the amount of data necessary to represent data-driven color properties in half, which might be a nice low hanging fruit to optimize performance in styles that extensively use data-driven colors (such as Mapbox core styles).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/data/program_configuration.js at the referenced lines and trace how data-driven color values are encoded into WebGL buffers. Confirm that Uint16 provides sufficient precision, update the relevant encoding path, and verify that color rendering remains correct while buffer storage is reduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100