-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Emscripten WebGL inefficiency with glEnable/DisableVertexAttribArray #1960
Comments
Cool. Send PR. |
A quick test with removing the redundant calls to ( |
You still have to call |
Actually, why? A honest question, I was thinking the same, but cannot find a reason in the GL spec to see why any attrib arrays need to be disabled. The GL spec does not seem to give a reason, technical or behavioral, that I could find. Disabling an attrib array means "I want to use a constant vector value for this attribute instead of sourcing the attribute from a VBO" (i.e. source that attribute via
I did not actually modify the engine code, but just the build output of a page from Emscripten that I was given to consult. I don't have the source project to test other platforms. |
See: #1515 |
Thanks, very interesting. In such case, using the bitfield approach to keep the enabled set of attribute array indices to a minimum can be used. In the profile numbers above where I removed the |
…VertexAttribArray(). bkaradzic#1960
* master: Move GL_CHECK to GL callsites. make sure depth textures are resolved as well when blitting frameBuffer Cleanup. Adjust integer texture format enums for desktop OpenGL < 4.0 Revert back to using GL_HALF_FLOAT (that is GL_HALF_FLOAT_OES) Fix OpenGL ES texture formats and remove runtime texture probing on WebGL. Cleanup. Create WebGL 2 context if available. Work around Chrome performance bug https://bugs.chromium.org/p/chromium/issues/detail?id=1045643 Optimize glUniform1iv and glUniform4fv to use faster glUniform1i and glUniform4f on WebGL. Avoid redundant GL calls to glEnableVertexAttribArray() and glDisableVertexAttribArray(). bkaradzic#1960
…VertexAttribArray(). bkaradzic#1960
Looking at a bgfx demo in Spector.js shows the two following profiles:
The renderer first disables all attrib arrays, and then re-enables them. These API calls are quite inefficient in web browsers. It would be better to use a bitfield to track which are currently set, and which want to be set, and only do the minimal delta of enable/disable calls to switch from old state to new state. This can improve CPU performance on the order of +5%.
The text was updated successfully, but these errors were encountered: