[go: nahoru, domu]

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

Optimize glMapBufferRange() to not generate temporary JS garbage #19592

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

juj
Copy link
Collaborator
@juj juj commented Jun 12, 2023

This was the largest remaining source of per-frame JS garbage in Unity's WebGL 2 backend.

@juj juj force-pushed the avoid_glmapbufferrange_js_garbage branch from 6bb9d7d to 718f81e Compare June 12, 2023 20:29
access: access,
};
if (!GL.mappedBuffers[binding]) GL.mappedBuffers[binding] = {};
binding = GL.mappedBuffers[binding];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be shorter to write Object.assign(GL.mappedBuffers[binding], {offset, length, mem, access})?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It would be shorter, but I think that would generate garbage (since that would assign over the previous {} part). Closure can minify the key names here though.

There are two reasons why I am not considering this code location for strict tight code size savings:

  1. This is in an emulation path. Users who utilize strict web code size are likely to also utilize (only) native web features, so this type of OpenGL ES 3 emulation (the FULL_ES3 feature) would not be in that carefully crafted path, and
  2. To optimize these emulation functions for code size, we would want to give them the GL_TRACK_ERRORS disabled treatment, as well as optimize other code locations around this for size as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yeah, I forget that creates now garbage too.. doh!

@juj juj merged commit 13f632c into emscripten-core:main Jun 13, 2023
2 checks passed
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.

None yet

2 participants