diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-22 11:37:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-22 11:37:46 -0800 |
commit | 02ec49d58bbc468cac367b86d6ba1ceae6649b99 (patch) | |
tree | 745d65d9eb2421589a6c5d44ef50880d93c3c00f /src | |
parent | de644016429e268179962730dbb9172823985993 (diff) |
GL_UNSAFE_OPTS option
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 20 | ||||
-rw-r--r-- | src/settings.js | 1 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index f0b5b9ca..c0393a67 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1898,27 +1898,35 @@ var LibraryGL = { } // If the array buffer is unchanged and the renderer as well, then we can avoid all the work here - // XXX We use some heuristics here, and this may not work in all cases. Try disabling this if you - // have odd glitches (by setting canSkip always to 0, or even cleaning up the renderer right - // after rendering) + // XXX We use some heuristics here, and this may not work in all cases. Try disabling GL_UNSAFE_OPTS if you + // have odd glitches +#if GL_UNSAFE_OPTS var lastRenderer = GL.immediate.lastRenderer; var canSkip = this == lastRenderer && arrayBuffer == GL.immediate.lastArrayBuffer && (GL.currProgram || this.program) == GL.immediate.lastProgram && !GL.immediate.matricesModified; if (!canSkip && lastRenderer) lastRenderer.cleanup(); +#endif if (!GL.currArrayBuffer) { // Bind the array buffer and upload data after cleaning up the previous renderer +#if GL_UNSAFE_OPTS + // Potentially unsafe, since lastArrayBuffer might not reflect the true array buffer in code that mixes immediate/non-immediate if (arrayBuffer != GL.immediate.lastArrayBuffer) { +#endif Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, arrayBuffer); +#if GL_UNSAFE_OPTS } +#endif Module.ctx.bufferSubData(Module.ctx.ARRAY_BUFFER, start, GL.immediate.vertexData.subarray(start >> 2, end >> 2)); } +#if GL_UNSAFE_OPTS if (canSkip) return; GL.immediate.lastRenderer = this; GL.immediate.lastArrayBuffer = arrayBuffer; GL.immediate.lastProgram = GL.currProgram || this.program; GL.immediate.matricesModified = false; +#endif if (!GL.currProgram) { Module.ctx.useProgram(this.program); @@ -1994,9 +2002,11 @@ var LibraryGL = { Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null); } +#if GL_UNSAFE_OPTS GL.immediate.lastRenderer = null; GL.immediate.lastArrayBuffer = null; GL.immediate.lastProgram = null; +#endif GL.immediate.matricesModified = true; } }; @@ -2241,6 +2251,10 @@ var LibraryGL = { if (emulatedElementArrayBuffer) { Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, GL.buffers[GL.currElementArrayBuffer] || null); } + +#if GL_UNSAFE_OPTS == 0 + renderer.cleanUp(); +#endif } }, diff --git a/src/settings.js b/src/settings.js index 9023f7d8..f4e23c5b 100644 --- a/src/settings.js +++ b/src/settings.js @@ -163,6 +163,7 @@ var SOCKET_DEBUG = 0; // Log out socket/network data transfer. var GL_DEBUG = 0; // Print out all calls into WebGL. As with LIBRARY_DEBUG, you can set a runtime // option, in this case GL.debug. var GL_MAX_TEMP_BUFFER_SIZE = 2097152; // How large GL emulation temp buffers are +var GL_UNSAFE_OPTS = 1; // Enables some potentially-unsafe optimizations in GL emulation code var DISABLE_EXCEPTION_CATCHING = 0; // Disables generating code to actually catch exceptions. If the code you // are compiling does not actually rely on catching exceptions (but the |