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

WebGL matrix performance fix #5072

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kubapelc
Copy link
Collaborator

Fixes #5070 by passing float32 matrices to WebGL instead of float64. Note that the performance degradation only seemed to affect Chrome, not Firefox. Updates relevant unit & render tests.

@kubapelc
Copy link
Collaborator Author

kubapelc commented Nov 19, 2024

It would be nice to also have some hard perf numbers for this from a benchmark. I will see if there is a benchmark that can catch this and try to post some numbers tomorrow.

@ibesora
Copy link
Collaborator

ibesora commented Nov 19, 2024

Nice work and quick fix!
Is there anything we should be wary of by going back to 32-bit matrices? What was the rationale on changing those to 64?

@@ -1197,7 +1197,7 @@ export class GlobeTransform implements ITransform {
const fallbackMatrixScaled = createMat4f64();
mat4.scale(fallbackMatrixScaled, projectionData.fallbackMatrix, [EXTENT, EXTENT, 1]);

projectionData.fallbackMatrix = fallbackMatrixScaled;
projectionData.fallbackMatrix = new Float32Array(fallbackMatrixScaled);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to create a 64f matrix and then save it as 32? It's it easier to create a 32 from the start or does it help precision and worth the conversion?

@@ -416,7 +416,7 @@ export class MercatorTransform implements ITransform {
const tileMatrix = calculateTileMatrix(tileID, this.worldSize);
mat4.multiply(tileMatrix, aligned ? this._alignedProjMatrix : this._viewProjMatrix, tileMatrix);

cache[posMatrixKey] = tileMatrix;
cache[posMatrixKey] = new Float32Array(tileMatrix); // Must be 32 bit floats, otherwise WebGL calls in Chrome get very slow.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as above.

@HarelM
Copy link
Collaborator

HarelM commented Nov 19, 2024

Added a small question around object creation...
Looks good otherwise.

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.

Performance degradation in render time in 5.0.0 version
3 participants