-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix for zero count in glUniform family of functions #21573
Conversation
The code size code here is either 2 bytes or 4 bytes of total compressed size. However, the alternative would be add an additional |
0935560
to
386965b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but can we add a test for this?
Can I use the same excuse that was used last time not to? #16837 (comment) :) |
I'll meet you halfway: how about a test for one of them? 😄 that would at least test the recurring pattern, and have a good chance of catching regressions assuming we regress them all at once. |
Test added! Confirmed that it fails without this change. |
OK to land now? |
I see that in for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
miniTempWebGLFloatBuffers[i] = miniTempWebGLFloatBuffersStorage.subarray(0, i+1);
}
for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; ++i) {
miniTempWebGLIntBuffers[i] = miniTempWebGLIntBuffersStorage.subarray(0, i+1);
} and then at site of use there is that if (count <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}) {
// avoid allocation when uploading few enough uniforms
var view = miniTempWebGLIntBuffers[count-1];
for (var i = 0; i < count; ++i) {
view[i] = {{{ makeGetValue('value', '4*i', 'i32') }}};
}
} else Maybe we can fix this by changing That should result in a zero-sized arraybuffer being passed to the function calls naturally? Not sure why that original |
Thats works great! |
The previous fix for this was in emscripten-core#16837, but I looks like that only covered the new "garbage-free" webgl2 path. When old webgl1 path was still using the zero count value. As part of this change I resurrected `test_webgl_draw_triangle_with_uniform_color.c` which has not actually be used since emscripten-core#20925. Fixes: emscripten-core#21567
Ping... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
library_webgl.js attempts to use a pool of temp float or int buffers for uniform uploads up to 288 elements, however it would only allocate 288 temp buffers, so 0 through 287 would be fine but 288 would crash (miniTempWebGLFloatBuffers[288] would be undefined). Fix for emscripten-core#21573
library_webgl.js attempts to use a pool of temp float or int buffers for uniform uploads up to 288 elements, however it would only allocate 288 temp buffers, so 0 through 287 would be fine but 288 would crash (miniTempWebGLFloatBuffers[288] would be undefined). Confirmed manually that any one of the six "Just at the optimization limit" calls would crash before, and with the fix does not. Fix for the change in PR #21573
The previous fix for this was in #16837, but I looks like that only covered the new "garbage-free" webgl2 path. When old webgl1 path was still using the zero count value.
As part of this change I resurrected
test_webgl_draw_triangle_with_uniform_color.c
which has not actuallybe used since #20925.
Fixes: #21567