Skip to content

Commit 0dc08a3

Browse files
authored
Assert when glDrawElements cannot draw anything because of missing vertex bounds (#26525)
Even with FULL_ES2, glDrawElements cannot handle the case where the indices are in a buffer but the vertices are client-side. Nothing will be drawn in this case. Add an assertion to make this situation visible when debugging. Fixes #26460
1 parent 0a74f32 commit 0dc08a3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/lib/libglemu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3036,7 +3036,7 @@ var LibraryGLEmulation = {
30363036
// upload based on the indices. If they are in a buffer on the GPU, that is very
30373037
// inconvenient! So if you do not have an array buffer, you should also not have
30383038
// an element array buffer. But best is to use both buffers!
3039-
assert(!GLctx.currentElementArrayBufferBinding);
3039+
assert(!GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer');
30403040
#endif
30413041
for (var i = 0; i < numProvidedIndexes; i++) {
30423042
var currIndex = {{{ makeGetValue('ptr', 'i*2', 'u16') }}};

src/lib/libwebgl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
575575
var cb = GL.currentContext.clientBuffers[i];
576576
if (!cb.clientside || !cb.enabled) continue;
577577

578+
#if ASSERTIONS
579+
assert(count || !GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer');
580+
#endif
581+
578582
GL.resetBufferBinding = true;
579583

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

0 commit comments

Comments
 (0)