Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/libglemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3036,7 +3036,7 @@ var LibraryGLEmulation = {
// upload based on the indices. If they are in a buffer on the GPU, that is very
// inconvenient! So if you do not have an array buffer, you should also not have
// an element array buffer. But best is to use both buffers!
assert(!GLctx.currentElementArrayBufferBinding);
assert(!GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer');
#endif
for (var i = 0; i < numProvidedIndexes; i++) {
var currIndex = {{{ makeGetValue('ptr', 'i*2', 'u16') }}};
Expand Down
4 changes: 4 additions & 0 deletions src/lib/libwebgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
var cb = GL.currentContext.clientBuffers[i];
if (!cb.clientside || !cb.enabled) continue;

#if ASSERTIONS
assert(count || !GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this assert belong here inside this for loop? Could it not go outside the loop?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be !count || !GLctx.currentElementArrayBufferBinding ? (i.e. I'm not sure what the count || part is doing here.

Copy link
Author

Choose a reason for hiding this comment

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

It is written as intended, but there may be an edge case I didn't consider.

preDrawHandleClientVertexAttribBindings is called in two places. It is called by glDrawArrays, where the vertex count is always passed by the user. And in glDrawElements, where the vertex count is computed if it can be, or otherwise passed as 0.

The error case is only for glDrawElements, when the vertex count cannot be computed, so that the count is passed as 0, even though the real count is non-zero.

I added the "count ||" to make sure the assert doesn't fire for glDrawArrays. But it could still fire if glDrawArrays is called with a count of 0.

I'll get a fix for this ready.

#endif

GL.resetBufferBinding = true;

var size = GL.calcBufLength(cb.size, cb.type, cb.stride, count);
Expand Down