diff options
-rw-r--r-- | src/library.js | 5 | ||||
-rw-r--r-- | src/library_gl.js | 43 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 7 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 10 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
5 files changed, 58 insertions, 11 deletions
diff --git a/src/library.js b/src/library.js index 501f766c..e244491b 100644 --- a/src/library.js +++ b/src/library.js @@ -4164,6 +4164,11 @@ LibraryManager.library = { }, // ========================================================================== + // GCC/LLVM specifics + // ========================================================================== + __builtin_prefetch: function(){}, + + // ========================================================================== // LLVM specifics // ========================================================================== diff --git a/src/library_gl.js b/src/library_gl.js index 14e70868..ecb72f0f 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -11,6 +11,7 @@ var LibraryGL = { #endif counter: 1, // 0 is reserved as 'null' in gl + lastError: 0, buffers: [], programs: [], framebuffers: [], @@ -51,6 +52,13 @@ var LibraryGL = { Browser.moduleContextCreatedCallbacks.push(GL.initExtensions); }, + // Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error + // is remembered, and subsequent errors are discarded until the user has cleared the stored error by a call to glGetError(). + recordError: function recordError(errorCode) { + if (!GL.lastError) { + GL.lastError = errorCode; + } + }, // Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later. getNewId: function(table) { var ret = GL.counter++; @@ -2123,9 +2131,6 @@ var LibraryGL = { glGetShaderPrecisionFormat__sig: 'v', glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' }, - glShaderBinary__sig: 'v', - glShaderBinary: function() { throw 'glShaderBinary: TODO' }, - glDeleteObject__sig: 'vi', glDeleteObject: function(id) { if (GL.programs[id]) { @@ -2137,11 +2142,6 @@ var LibraryGL = { } }, - glReleaseShaderCompiler__sig: 'v', - glReleaseShaderCompiler: function() { - // NOP (as allowed by GLES 2.0 spec) - }, - glGetObjectParameteriv__sig: 'viii', glGetObjectParameteriv: function(id, type, result) { if (GL.programs[id]) { @@ -4618,6 +4618,30 @@ var LibraryGL = { #endif }, + glShaderBinary__sig: 'v', + glShaderBinary: function() { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail."); +#endif + }, + + glReleaseShaderCompiler__sig: 'v', + glReleaseShaderCompiler: function() { + // NOP (as allowed by GLES 2.0 spec) + }, + + glGetError__sig: 'i', + glGetError: function() { + // First return any GL error generated by the emscripten library_gl.js interop layer. + if (GL.lastError) { + var error = GL.lastError; + GL.lastError = 0/*GL_NO_ERROR*/; + return error; + } else { // If there were none, return the GL error from the browser GL context. + return Module.ctx.getError(); + } + }, // signatures of simple pass-through functions, see later glActiveTexture__sig: 'vi', @@ -4651,14 +4675,13 @@ var LibraryGL = { glFlush__sig: 'v', glClearColor__sig: 'viiii', glIsEnabled__sig: 'ii', - glGetError__sig: 'i', glFrontFace__sig: 'vi', glSampleCoverage__sig: 'vi', }; // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name -[[0, 'getError* finish flush'], +[[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'], [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index dda82047..434fbaf9 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -291,4 +291,11 @@ function watIf() { if ($cmp38) {} else {} } } +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0; + $call24 = MUST_RUN() | 0; + STACKTOP = sp; + return ($foundBase_0_off0 ? 0 : $call24) | 0; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 6f426150..7ec277d5 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -362,5 +362,13 @@ function watIf() { } } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf"] +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0, $retval_0 = 0; + $call24 = MUST_RUN() | 0; + $retval_0 = $foundBase_0_off0 ? 0 : $call24; + STACKTOP = sp; + return $retval_0 | 0; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 022bdf47..36244298 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2485,6 +2485,10 @@ function eliminate(ast, memSafe) { } else if (type === 'return') { if (node[1]) traverseInOrder(node[1]); } else if (type === 'conditional') { + if (!callsInvalidated) { // invalidate calls, since we cannot eliminate them into a branch of an LLVM select/JS conditional that does not execute + invalidateCalls(); + callsInvalidated = true; + } traverseInOrder(node[1]); traverseInOrder(node[2]); traverseInOrder(node[3]); |