Skip to content

Commit 544bcaf

Browse files
authored
GL_ASSERTIONS: check for MAX_TEMP_BUFFER_SIZE (emscripten-core#26098)
This always happens to me, if you specify not enough MAX_TEMP_BUFFER_SIZE, then you will have non clear error in runtime. With this PR in GL_ASSERTIONS mode, you will have a clean message and information about really needed size of buffer.
1 parent 5dafa6b commit 544bcaf

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/lib/libwebgl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
461461
getTempVertexBuffer: (sizeBytes) => {
462462
var idx = GL.log2ceilLookup(sizeBytes);
463463
var ringbuffer = GL.currentContext.tempVertexBuffers1[idx];
464+
#if GL_ASSERTIONS
465+
assert(ringbuffer, `MAX_TEMP_BUFFER_SIZE is not large enough to store a buffer of size ${sizeBytes}`);
466+
#endif
464467
var nextFreeBufferIndex = GL.currentContext.tempVertexBufferCounters1[idx];
465468
GL.currentContext.tempVertexBufferCounters1[idx] = (GL.currentContext.tempVertexBufferCounters1[idx]+1) & (GL.numTempVertexBuffersPerSize-1);
466469
var vbo = ringbuffer[nextFreeBufferIndex];

0 commit comments

Comments
 (0)