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 10 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?

@HarelM
Copy link
Collaborator

HarelM commented Nov 19, 2024

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

@kubapelc
Copy link
Collaborator Author

Firefox benchmark:

Firefox

Chrome:

Chrome

It seems that the float32 fix works, but there is still a performance regression somewhere.

private _posMatrixCache: {[_: string]: mat4};
private _fogMatrixCache: {[_: string]: mat4};
private _alignedPosMatrixCache: {[_: string]: mat4};
private _posMatrixCacheF32: Map<string, mat4> = new Map();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would advise to create an object/type that has both 32 and 64 matrices to avoid cache misalignment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what you mean exactly. As in not allowing the maps to have different sets of key-value pairs by accident?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of two maps holding the same keys, have one map holding an object with two fields.

@HarelM
Copy link
Collaborator

HarelM commented Nov 20, 2024

Codecov is not running on PRs lately for somereason, I'll see if I can make it work again.
Otherwise I left a few minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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