diff --git a/jsb/builtin/glOptMode.js b/jsb/builtin/glOptMode.js index 84589070d2..f1378035cd 100644 --- a/jsb/builtin/glOptMode.js +++ b/jsb/builtin/glOptMode.js @@ -108,6 +108,7 @@ for (var k in gl) { var total_size = 100000; var next_index = 0; var buffer_data; +var commandCount = 0; // Batch GL commands is enabled by default. function batchGLCommandsToNative() { @@ -138,21 +139,25 @@ function disableBatchGLCommandsToNative() { function flushCommands() { if (next_index > 0) { - gl._flushCommands(next_index, buffer_data); + gl._flushCommands(next_index, buffer_data, commandCount); next_index = 0; + commandCount = 0; } } function activeTextureOpt(texture) { + // console.log('GLOpt: activeTexture'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_ACTIVE_TEXTURE; buffer_data[next_index + 1] = texture; next_index += 2; + ++commandCount; } function attachShaderOpt(program, shader) { + // console.log('GLOpt: attachShader'); if (next_index + 3 > total_size) { flushCommands(); } @@ -160,14 +165,17 @@ function attachShaderOpt(program, shader) { buffer_data[next_index + 1] = program ? program._id : 0; buffer_data[next_index + 2] = shader ? shader._id : 0; next_index += 3; + ++commandCount; } function bindAttribLocationOpt(program, index, name) { + // console.log('GLOpt: bindAttribLocation'); flushCommands(); _gl.bindAttribLocation(program, index, name); } function bindBufferOpt(target, buffer) { + // console.log('GLOpt: bindBuffer: ' + (buffer? buffer._id : null)); if (next_index + 3 > total_size) { flushCommands(); } @@ -175,9 +183,11 @@ function bindBufferOpt(target, buffer) { buffer_data[next_index + 1] = target; buffer_data[next_index + 2] = buffer ? buffer._id : 0; next_index += 3; + ++commandCount; } function bindFramebufferOpt(target, framebuffer) { + // console.log('GLOpt: bindFramebuffer'); if (next_index + 3 > total_size) { flushCommands(); } @@ -185,9 +195,11 @@ function bindFramebufferOpt(target, framebuffer) { buffer_data[next_index + 1] = target; buffer_data[next_index + 2] = framebuffer ? framebuffer._id : 0; next_index += 3; + ++commandCount; } function bindRenderbufferOpt(target, renderbuffer) { + // console.log('GLOpt: bindRenderbuffer'); if (next_index + 3 > total_size) { flushCommands(); } @@ -195,9 +207,11 @@ function bindRenderbufferOpt(target, renderbuffer) { buffer_data[next_index + 1] = target; buffer_data[next_index + 2] = renderbuffer ? renderbuffer._id : 0; next_index += 3; + ++commandCount; } function bindTextureOpt(target, texture) { + // console.log('GLOpt: bindTexture'); if (next_index + 3 > total_size) { flushCommands(); } @@ -205,9 +219,11 @@ function bindTextureOpt(target, texture) { buffer_data[next_index + 1] = target; buffer_data[next_index + 2] = texture ? texture._id : 0; next_index += 3; + ++commandCount; } function blendColorOpt(red, green, blue, alpha) { + // console.log('GLOpt: blendColor'); if (next_index + 5 > total_size) { flushCommands(); } @@ -217,18 +233,22 @@ function blendColorOpt(red, green, blue, alpha) { buffer_data[next_index + 3] = blue; buffer_data[next_index + 4] = alpha; next_index += 5; + ++commandCount; } function blendEquationOpt(mode) { + // console.log('GLOpt: blendEquation'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_BLEND_EQUATION; buffer_data[next_index + 1] = mode; next_index += 2; + ++commandCount; } function blendEquationSeparateOpt(modeRGB, modeAlpha) { + // console.log('GLOpt: blendEquationSeparate'); if (next_index + 3 > total_size) { flushCommands(); } @@ -236,9 +256,11 @@ function blendEquationSeparateOpt(modeRGB, modeAlpha) { buffer_data[next_index + 1] = modeRGB; buffer_data[next_index + 2] = modeAlpha; next_index += 3; + ++commandCount; } function blendFuncOpt(sfactor, dfactor) { + // console.log('GLOpt: blendFunc'); if (next_index + 3 > total_size) { flushCommands(); } @@ -246,9 +268,11 @@ function blendFuncOpt(sfactor, dfactor) { buffer_data[next_index + 1] = sfactor; buffer_data[next_index + 2] = dfactor; next_index += 3; + ++commandCount; } function blendFuncSeparateOpt(srcRGB, dstRGB, srcAlpha, dstAlpha) { + // console.log('GLOpt: blendFuncSeparate'); if (next_index + 5 > total_size) { flushCommands(); } @@ -258,33 +282,40 @@ function blendFuncSeparateOpt(srcRGB, dstRGB, srcAlpha, dstAlpha) { buffer_data[next_index + 3] = srcAlpha; buffer_data[next_index + 4] = dstAlpha; next_index += 5; + ++commandCount; } function bufferDataOpt(target, data, usage) { flushCommands(); + // console.log('GLOpt: bufferData'); _gl.bufferData(target, data, usage); } function bufferSubDataOpt(target, offset, data) { flushCommands(); + // console.log('GLOpt: bufferSubData'); _gl.bufferSubData(target, offset, data); } function checkFramebufferStatusOpt(target) { flushCommands(); + // console.log('GLOpt: checkFramebufferStatus'); return _gl.checkFramebufferStatus(target); } function clearOpt(mask) { + // console.log('GLOpt: clear'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_CLEAR; buffer_data[next_index + 1] = mask; next_index += 2; + ++commandCount; } function clearColorOpt(red, green, blue, alpha) { + // console.log('GLOpt: clearColor'); if (next_index + 5 > total_size) { flushCommands(); } @@ -294,27 +325,33 @@ function clearColorOpt(red, green, blue, alpha) { buffer_data[next_index + 3] = blue; buffer_data[next_index + 4] = alpha; next_index += 5; + ++commandCount; } function clearDepthOpt(depth) { + // console.log('GLOpt: clearDepth'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_CLEAR_DEPTH; buffer_data[next_index + 1] = depth; next_index += 2; + ++commandCount; } function clearStencilOpt(s) { + // console.log('GLOpt: clearStencil'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_CLEAR_STENCIL; buffer_data[next_index + 1] = s; next_index += 2; + ++commandCount; } function colorMaskOpt(red, green, blue, alpha) { + // console.log('GLOpt: colorMask'); if (next_index + 5 > total_size) { flushCommands(); } @@ -324,28 +361,34 @@ function colorMaskOpt(red, green, blue, alpha) { buffer_data[next_index + 3] = blue ? 1 : 0; buffer_data[next_index + 4] = alpha ? 1 : 0; next_index += 5; + ++commandCount; } function compileShaderOpt(shader) { + // console.log('GLOpt: compileShader'); if (next_index + 2 > total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_COMPILE_SHADER; buffer_data[next_index + 1] = shader ? shader._id : 0; next_index += 2; + ++commandCount; } function compressedTexImage2DOpt(target, level, internalformat, width, height, border, data) { + // console.log('GLOpt: compressedTexImage2D'); flushCommands(); _gl.compressedTexImage2D(target, level, internalformat, width, height, border, data); } function compressedTexSubImage2DOpt(target, level, xoffset, yoffset, width, height, format, data) { + // console.log('GLOpt: compressedTexSubImage2D'); flushCommands(); _gl.compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, data); } function copyTexImage2DOpt(target, level, internalformat, x, y, width, height, border) { + // console.log('GLOpt: copyTexImage2D'); if (next_index + 9 > total_size) { flushCommands(); } @@ -359,9 +402,11 @@ function copyTexImage2DOpt(target, level, internalformat, x, y, width, height, b buffer_data[next_index + 7] = height; buffer_data[next_index + 8] = border; next_index += 9; + ++commandCount; } function copyTexSubImage2DOpt(target, level, xoffset, yoffset, x, y, width, height) { + // console.log('GLOpt: copyTexSubImage2D'); if (next_index + 9 > total_size) { flushCommands(); } @@ -375,120 +420,148 @@ function copyTexSubImage2DOpt(target, level, xoffset, yoffset, x, y, width, heig buffer_data[next_index + 7] = width; buffer_data[next_index + 8] = height; next_index += 9; + ++commandCount; } function createBufferOpt() { flushCommands(); - return _gl.createBuffer(); + + var ret = _gl.createBuffer(); + // console.log('GLOpt: createBuffer: ' + ret._id); + return ret; } function createFramebufferOpt() { flushCommands(); + // console.log('GLOpt: createFramebuffer'); return _gl.createFramebuffer(); } function createProgramOpt() { flushCommands(); + // console.log('GLOpt: createProgram'); return _gl.createProgram(); } function createRenderbufferOpt() { flushCommands(); + // console.log('GLOpt: createRenderbuffer'); return _gl.createRenderbuffer(); } function createShaderOpt(type) { + // console.log('GLOpt: createShader'); flushCommands(); return _gl.createShader(type); } function createTextureOpt() { flushCommands(); + // console.log('GLOpt: createTexture'); return _gl.createTexture(); } function cullFaceOpt(mode) { + // console.log('GLOpt: cullFace'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_CULL_FACE; buffer_data[next_index + 1] = mode; next_index += 2; + ++commandCount; } function deleteBufferOpt(buffer) { + // console.log('GLOpt: deleteBuffer'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_BUFFER; buffer_data[next_index + 1] = buffer ? buffer._id : 0; next_index += 2; + ++commandCount; } function deleteFramebufferOpt(framebuffer) { + // console.log('GLOpt: deleteFramebuffer'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_FRAME_BUFFER; buffer_data[next_index + 1] = framebuffer ? framebuffer._id : 0; next_index += 2; + ++commandCount; } function deleteProgramOpt(program) { + // console.log('GLOpt: deleteProgram'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_PROGRAM; buffer_data[next_index + 1] = program ? program._id : 0; next_index += 2; + ++commandCount; } function deleteRenderbufferOpt(renderbuffer) { + // console.log('GLOpt: deleteRenderbuffer'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_RENDER_BUFFER; buffer_data[next_index + 1] = renderbuffer ? renderbuffer._id : 0; next_index += 2; + ++commandCount; } function deleteShaderOpt(shader) { + // console.log('GLOpt: deleteShader'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_SHADER; buffer_data[next_index + 1] = shader ? shader._id : 0; next_index += 2; + ++commandCount; } function deleteTextureOpt(texture) { + // console.log('GLOpt: deleteTexture'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DELETE_TEXTURE; buffer_data[next_index + 1] = texture ? texture._id : 0; next_index += 2; + ++commandCount; } function depthFuncOpt(func) { + // console.log('GLOpt: depthFunc'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DEPTH_FUNC; buffer_data[next_index + 1] = func; next_index += 2; + ++commandCount; } function depthMaskOpt(flag) { + // console.log('GLOpt: depthMask'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DEPTH_MASK; buffer_data[next_index + 1] = flag ? 1 : 0; next_index += 2; + ++commandCount; } function depthRangeOpt(zNear, zFar) { + // console.log('GLOpt: depthRange'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -496,9 +569,11 @@ function depthRangeOpt(zNear, zFar) { buffer_data[next_index + 1] = zNear; buffer_data[next_index + 1] = zFar; next_index += 3; + ++commandCount; } function detachShaderOpt(program, shader) { + // console.log('GLOpt: detachShader'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -506,27 +581,33 @@ function detachShaderOpt(program, shader) { buffer_data[next_index + 1] = program ? program._id : 0; buffer_data[next_index + 1] = shader ? shader._id : 0; next_index += 3; + ++commandCount; } function disableOpt(cap) { + // console.log('GLOpt: disable'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DISABLE; buffer_data[next_index + 1] = cap; next_index += 2; + ++commandCount; } function disableVertexAttribArrayOpt(index) { + // console.log('GLOpt: disableVertexAttribArray'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_DISABLE_VERTEX_ATTRIB_ARRAY; buffer_data[next_index + 1] = index; next_index += 2; + ++commandCount; } function drawArraysOpt(mode, first, count) { + // console.log('GLOpt: drawArrays'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -535,9 +616,11 @@ function drawArraysOpt(mode, first, count) { buffer_data[next_index + 2] = first; buffer_data[next_index + 3] = count; next_index += 4; + ++commandCount; } function drawElementsOpt(mode, count, type, offset) { + // console.log('GLOpt: drawElements'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -547,43 +630,53 @@ function drawElementsOpt(mode, count, type, offset) { buffer_data[next_index + 3] = type; buffer_data[next_index + 4] = offset ? offset : 0; next_index += 5; + ++commandCount; } function enableOpt(cap) { + // console.log('GLOpt: enable'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_ENABLE; buffer_data[next_index + 1] = cap; next_index += 2; + ++commandCount; } function enableVertexAttribArrayOpt(index) { + // console.log('GLOpt: enableVertexAttribArray'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_ENABLE_VERTEX_ATTRIB_ARRAY; buffer_data[next_index + 1] = index; next_index += 2; + ++commandCount; } function finishOpt() { + // console.log('GLOpt: finish'); if (next_index + 1 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_FINISH; next_index += 1; + ++commandCount; } function flushOpt() { + // console.log('GLOpt: flush'); if (next_index + 1 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_FLUSH; next_index += 1; + ++commandCount; } function framebufferRenderbufferOpt(target, attachment, renderbuffertarget, renderbuffer) { + // console.log('GLOpt: framebufferRenderbuffer'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -593,9 +686,11 @@ function framebufferRenderbufferOpt(target, attachment, renderbuffertarget, rend buffer_data[next_index + 3] = renderbuffertarget; buffer_data[next_index + 4] = renderbuffer ? renderbuffer._id : 0; next_index += 5; + ++commandCount; } function framebufferTexture2DOpt(target, attachment, textarget, texture, level) { + // console.log('GLOpt: framebufferTexture2D'); if (next_index + 6 >= total_size) { flushCommands(); } @@ -606,127 +701,153 @@ function framebufferTexture2DOpt(target, attachment, textarget, texture, level) buffer_data[next_index + 4] = texture ? texture._id : 0; buffer_data[next_index + 5] = level; next_index += 6; + ++commandCount; } function frontFaceOpt(mode) { + // console.log('GLOpt: frontFace'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_FRONT_FACE; buffer_data[next_index + 1] = mode; next_index += 2; + ++commandCount; } function generateMipmapOpt(target) { + // console.log('GLOpt: generateMipmap'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_GENERATE_MIPMAP; buffer_data[next_index + 1] = target; next_index += 2; + ++commandCount; } function getActiveAttribOpt(program, index) { + // console.log('GLOpt: getActiveAttrib'); flushCommands(); return _gl.getActiveAttrib(program, index); } function getActiveUniformOpt(program, index) { + // console.log('GLOpt: getActiveUniform'); flushCommands(); return _gl.getActiveUniform(program, index); } function getAttachedShadersOpt(program) { + // console.log('GLOpt: getAttachedShaders'); flushCommands(); return _gl.getAttachedShaders(program); } function getAttribLocationOpt(program, name) { + // console.log('GLOpt: getAttribLocation'); flushCommands(); return _gl.getAttribLocation(program, name); } function getBufferParameterOpt(target, pname) { + // console.log('GLOpt: getBufferParameter'); flushCommands(); return _gl.getBufferParameter(target, pname); } function getParameterOpt(pname) { + // console.log('GLOpt: getParameter'); flushCommands(); return _gl.getParameter(pname); } function getErrorOpt() { + // console.log('GLOpt: getError'); flushCommands(); return _gl.getError(); } function getFramebufferAttachmentParameterOpt(target, attachment, pname) { + // console.log('GLOpt: getFramebufferAttachmentParameter'); flushCommands(); return _gl.getFramebufferAttachmentParameter(target, attachment, pname); } function getProgramParameterOpt(program, pname) { + // console.log('GLOpt: getProgramParameter'); flushCommands(); return _gl.getProgramParameter(program, pname); } function getProgramInfoLogOpt(program) { + // console.log('GLOpt: getProgramInfoLog'); flushCommands(); return _gl.getProgramInfoLog(program); } function getRenderbufferParameterOpt(target, pname) { + // console.log('GLOpt: getRenderbufferParameter'); flushCommands(); return _gl.getRenderbufferParameter(target, pname); } function getShaderParameterOpt(shader, pname) { + // console.log('GLOpt: getShaderParameter'); flushCommands(); return _gl.getShaderParameter(shader, pname); } function getShaderPrecisionFormatOpt(shadertype, precisiontype) { + // console.log('GLOpt: getShaderPrecisionFormat'); flushCommands(); return _gl.getShaderPrecisionFormat(shadertype, precisiontype); } function getShaderInfoLogOpt(shader) { + // console.log('GLOpt: getShaderInfoLog'); flushCommands(); return _gl.getShaderInfoLog(shader); } function getShaderSourceOpt(shader) { + // console.log('GLOpt: getShaderSource'); flushCommands(); return _gl.getShaderSource(shader); } function getTexParameterOpt(target, pname) { + // console.log('GLOpt: getTexParameter'); flushCommands(); return _gl.getTexParameter(target, pname); } function getUniformOpt(program, location) { + // console.log('GLOpt: getUniform'); flushCommands(); return _gl.getUniform(program, location); } function getUniformLocationOpt(program, name) { + // console.log('GLOpt: getUniformLocation'); flushCommands(); return _gl.getUniformLocation(program, name); } function getVertexAttribOpt(index, pname) { + // console.log('GLOpt: getVertexAttrib'); flushCommands(); return _gl.getVertexAttrib(index, pname); } function getVertexAttribOffsetOpt(index, pname) { + // console.log('GLOpt: getVertexAttribOffset'); flushCommands(); return _gl.getVertexAttribOffset(index, pname); } function hintOpt(target, mode) { + // console.log('GLOpt: hint'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -734,62 +855,75 @@ function hintOpt(target, mode) { buffer_data[next_index + 1] = target; buffer_data[next_index + 2] = mode; next_index += 3; + ++commandCount; } function isBufferOpt(buffer) { + // console.log('GLOpt: isBuffer'); flushCommands(); return _gl.isBuffer(buffer); } function isEnabledOpt(cap) { + // console.log('GLOpt: isEnabled'); flushCommands(); return _gl.isEnabled(cap); } function isFramebufferOpt(framebuffer) { + // console.log('GLOpt: isFramebuffer'); flushCommands(); return _gl.isFramebuffer(framebuffer); } function isProgramOpt(program) { + // console.log('GLOpt: isProgram'); flushCommands(); return _gl.isProgram(program); } function isRenderbufferOpt(renderbuffer) { + // console.log('GLOpt: isRenderbuffer'); flushCommands(); return _gl.isRenderbuffer(renderbuffer); } function isShaderOpt(shader) { + // console.log('GLOpt: isShader'); flushCommands(); return _gl.isShader(shader); } function isTextureOpt(texture) { + // console.log('GLOpt: isTexture'); flushCommands(); return _gl.isTexture(texture); } function lineWidthOpt(width) { + // console.log('GLOpt: lineWidth'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_LINE_WIDTH; buffer_data[next_index + 1] = width; next_index += 2; + ++commandCount; } function linkProgramOpt(program) { + // console.log('GLOpt: linkProgram'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_LINK_PROGRAM; buffer_data[next_index + 1] = program ? program._id : 0; next_index += 2; + ++commandCount; } function pixelStoreiOpt(pname, param) { + // console.log('GLOpt: pixelStorei'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -797,9 +931,11 @@ function pixelStoreiOpt(pname, param) { buffer_data[next_index + 1] = pname; buffer_data[next_index + 2] = param; next_index += 3; + ++commandCount; } function polygonOffsetOpt(factor, units) { + // console.log('GLOpt: polygonOffset'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -807,14 +943,17 @@ function polygonOffsetOpt(factor, units) { buffer_data[next_index + 1] = factor; buffer_data[next_index + 2] = units; next_index += 3; + ++commandCount; } function readPixelsOpt(x, y, width, height, format, type, pixels) { + // console.log('GLOpt: readPixels'); flushCommands(); _gl.readPixels(x, y, width, height, format, type, pixels); } function renderbufferStorageOpt(target, internalFormat, width, height) { + // console.log('GLOpt: renderbufferStorage'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -824,9 +963,11 @@ function renderbufferStorageOpt(target, internalFormat, width, height) { buffer_data[next_index + 3] = width; buffer_data[next_index + 4] = height; next_index += 5; + ++commandCount; } function sampleCoverageOpt(value, invert) { + // console.log('GLOpt: sampleCoverage'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -834,9 +975,11 @@ function sampleCoverageOpt(value, invert) { buffer_data[next_index + 1] = value; buffer_data[next_index + 2] = invert ? 1 : 0; next_index += 3; + ++commandCount; } function scissorOpt(x, y, width, height) { + // console.log('GLOpt: scissor'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -846,14 +989,17 @@ function scissorOpt(x, y, width, height) { buffer_data[next_index + 3] = width; buffer_data[next_index + 4] = height; next_index += 5; + ++commandCount; } function shaderSourceOpt(shader, source) { + // console.log('GLOpt: shaderSource'); flushCommands(); _gl.shaderSource(shader, source); } function stencilFuncOpt(func, ref, mask) { + // console.log('GLOpt: stencilFunc'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -862,9 +1008,11 @@ function stencilFuncOpt(func, ref, mask) { buffer_data[next_index + 2] = ref; buffer_data[next_index + 3] = mask; next_index += 4; + ++commandCount; } function stencilFuncSeparateOpt(face, func, ref, mask) { + // console.log('GLOpt: stencilFuncSeparate'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -874,18 +1022,22 @@ function stencilFuncSeparateOpt(face, func, ref, mask) { buffer_data[next_index + 3] = ref; buffer_data[next_index + 4] = mask; next_index += 5; + ++commandCount; } function stencilMaskOpt(mask) { + // console.log('GLOpt: stencilMask'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_STENCIL_MASK; buffer_data[next_index + 1] = mask; next_index += 2; + ++commandCount; } function stencilMaskSeparateOpt(face, mask) { + // console.log('GLOpt: stencilMaskSeparate'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -893,9 +1045,11 @@ function stencilMaskSeparateOpt(face, mask) { buffer_data[next_index + 1] = face; buffer_data[next_index + 2] = mask; next_index += 3; + ++commandCount; } function stencilOpOpt(fail, zfail, zpass) { + // console.log('GLOpt: stencilOp'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -904,9 +1058,11 @@ function stencilOpOpt(fail, zfail, zpass) { buffer_data[next_index + 2] = zfail; buffer_data[next_index + 3] = zpass; next_index += 4; + ++commandCount; } function stencilOpSeparateOpt(face, fail, zfail, zpass) { + // console.log('GLOpt: stencilOpSeparate'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -916,10 +1072,12 @@ function stencilOpSeparateOpt(face, fail, zfail, zpass) { buffer_data[next_index + 3] = zfail; buffer_data[next_index + 4] = zpass; next_index += 5; + ++commandCount; } function texImage2DOpt() { flushCommands(); + // console.log('GLOpt: texImage2D'); var argCount = arguments.length; if (argCount === 6) { _gl.texImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); @@ -933,6 +1091,7 @@ function texImage2DOpt() { } function texParameterfOpt(target, pname, param) { + // console.log('GLOpt: texParameterf'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -941,9 +1100,11 @@ function texParameterfOpt(target, pname, param) { buffer_data[next_index + 2] = pname; buffer_data[next_index + 3] = param; next_index += 4; + ++commandCount; } function texParameteriOpt(target, pname, param) { + // console.log('GLOpt: texParameteri'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -952,10 +1113,12 @@ function texParameteriOpt(target, pname, param) { buffer_data[next_index + 2] = pname; buffer_data[next_index + 3] = param; next_index += 4; + ++commandCount; } function texSubImage2DOpt(target, level, xoffset, yoffset, width, height, format, type, pixels) { flushCommands(); + // console.log('GLOpt: texSubImage2D'); var argCount = arguments.length; if (argCount === 7) { _gl.texSubImage2D(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); @@ -969,6 +1132,7 @@ function texSubImage2DOpt(target, level, xoffset, yoffset, width, height, format } function uniform1fOpt(location, x) { + // console.log('GLOpt: uniform1f'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -976,9 +1140,11 @@ function uniform1fOpt(location, x) { buffer_data[next_index + 1] = location; buffer_data[next_index + 2] = x; next_index += 3; + ++commandCount; } function uniform2fOpt(location, x, y) { + // console.log('GLOpt: uniform2f'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -987,9 +1153,11 @@ function uniform2fOpt(location, x, y) { buffer_data[next_index + 2] = x; buffer_data[next_index + 3] = y; next_index += 4; + ++commandCount; } function uniform3fOpt(location, x, y, z) { + // console.log('GLOpt: uniform3f'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -999,9 +1167,11 @@ function uniform3fOpt(location, x, y, z) { buffer_data[next_index + 3] = y; buffer_data[next_index + 4] = z; next_index += 5; + ++commandCount; } function uniform4fOpt(location, x, y, z, w) { + // console.log('GLOpt: uniform4f'); if (next_index + 6 >= total_size) { flushCommands(); } @@ -1012,9 +1182,11 @@ function uniform4fOpt(location, x, y, z, w) { buffer_data[next_index + 4] = z; buffer_data[next_index + 5] = w; next_index += 6; + ++commandCount; } function uniform1iOpt(location, x) { + // console.log('GLOpt: uniform1i'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -1022,9 +1194,11 @@ function uniform1iOpt(location, x) { buffer_data[next_index + 1] = location; buffer_data[next_index + 2] = x; next_index += 3; + ++commandCount; } function uniform2iOpt(location, x, y) { + // console.log('GLOpt: uniform2i'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -1033,9 +1207,11 @@ function uniform2iOpt(location, x, y) { buffer_data[next_index + 2] = x; buffer_data[next_index + 3] = y; next_index += 4; + ++commandCount; } function uniform3iOpt(location, x, y, z) { + // console.log('GLOpt: uniform3i'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -1045,9 +1221,11 @@ function uniform3iOpt(location, x, y, z) { buffer_data[next_index + 3] = y; buffer_data[next_index + 4] = z; next_index += 5; + ++commandCount; } function uniform4iOpt(location, x, y, z, w) { + // console.log('GLOpt: uniform4i'); if (next_index + 6 >= total_size) { flushCommands(); } @@ -1058,9 +1236,11 @@ function uniform4iOpt(location, x, y, z, w) { buffer_data[next_index + 4] = z; buffer_data[next_index + 5] = w; next_index += 6; + ++commandCount; } function uniform1fvOpt(location, value) { + // console.log('GLOpt: uniform1fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1069,9 +1249,11 @@ function uniform1fvOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform2fvOpt(location, value) { + // console.log('GLOpt: uniform2fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1080,9 +1262,11 @@ function uniform2fvOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform3fvOpt(location, value) { + // console.log('GLOpt: uniform3fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1091,9 +1275,11 @@ function uniform3fvOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform4fvOpt(location, value) { + // console.log('GLOpt: uniform4fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1102,9 +1288,11 @@ function uniform4fvOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform1ivOpt(location, value) { + // console.log('GLOpt: uniform1iv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1113,9 +1301,11 @@ function uniform1ivOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform2ivOpt(location, value) { + // console.log('GLOpt: uniform2iv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1124,9 +1314,11 @@ function uniform2ivOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform3ivOpt(location, value) { + // console.log('GLOpt: uniform3iv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1135,9 +1327,11 @@ function uniform3ivOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniform4ivOpt(location, value) { + // console.log('GLOpt: uniform4iv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1146,9 +1340,11 @@ function uniform4ivOpt(location, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function uniformMatrix2fvOpt(location, transpose, value) { + // console.log('GLOpt: uniformMatrix2fv'); if (next_index + 4 + value.length >= total_size) { flushCommands(); } @@ -1158,9 +1354,11 @@ function uniformMatrix2fvOpt(location, transpose, value) { buffer_data[next_index + 3] = value.length; buffer_data.set(value, next_index + 4); next_index += 4 + value.length; + ++commandCount; } function uniformMatrix3fvOpt(location, transpose, value) { + // console.log('GLOpt: uniformMatrix3fv'); if (next_index + 4 + value.length >= total_size) { flushCommands(); } @@ -1170,9 +1368,11 @@ function uniformMatrix3fvOpt(location, transpose, value) { buffer_data[next_index + 3] = value.length; buffer_data.set(value, next_index + 4); next_index += 4 + value.length; + ++commandCount; } function uniformMatrix4fvOpt(location, transpose, value) { + // console.log('GLOpt: uniformMatrix4fv'); if (next_index + 4 + value.length >= total_size) { flushCommands(); } @@ -1182,27 +1382,33 @@ function uniformMatrix4fvOpt(location, transpose, value) { buffer_data[next_index + 3] = value.length; buffer_data.set(value, next_index + 4); next_index += 4 + value.length; + ++commandCount; } function useProgramOpt(program) { + // console.log('GLOpt: useProgram'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_USE_PROGRAM; buffer_data[next_index + 1] = program ? program._id : 0; next_index += 2; + ++commandCount; } function validateProgramOpt(program) { + // console.log('GLOpt: validateProgram'); if (next_index + 2 >= total_size) { flushCommands(); } buffer_data[next_index] = GL_COMMAND_VALIDATE_PROGRAM; buffer_data[next_index + 1] = program ? program._id : 0; next_index += 2; + ++commandCount; } function vertexAttrib1fOpt(index, x) { + // console.log('GLOpt: vertexAttrib1f'); if (next_index + 3 >= total_size) { flushCommands(); } @@ -1210,9 +1416,11 @@ function vertexAttrib1fOpt(index, x) { buffer_data[next_index + 1] = index; buffer_data[next_index + 2] = x; next_index += 3; + ++commandCount; } function vertexAttrib2fOpt(index, x, y) { + // console.log('GLOpt: vertexAttrib2f'); if (next_index + 4 >= total_size) { flushCommands(); } @@ -1221,9 +1429,11 @@ function vertexAttrib2fOpt(index, x, y) { buffer_data[next_index + 2] = x; buffer_data[next_index + 3] = y; next_index += 4; + ++commandCount; } function vertexAttrib3fOpt(index, x, y, z) { + // console.log('GLOpt: vertexAttrib3f'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -1233,9 +1443,11 @@ function vertexAttrib3fOpt(index, x, y, z) { buffer_data[next_index + 3] = y; buffer_data[next_index + 4] = z; next_index += 5; + ++commandCount; } function vertexAttrib4fOpt(index, x, y, z, w) { + // console.log('GLOpt: vertexAttrib4f'); if (next_index + 6 >= total_size) { flushCommands(); } @@ -1246,9 +1458,11 @@ function vertexAttrib4fOpt(index, x, y, z, w) { buffer_data[next_index + 4] = z; buffer_data[next_index + 5] = w; next_index += 6; + ++commandCount; } function vertexAttrib1fvOpt(index, value) { + // console.log('GLOpt: vertexAttrib1fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1257,9 +1471,11 @@ function vertexAttrib1fvOpt(index, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function vertexAttrib2fvOpt(index, value) { + // console.log('GLOpt: vertexAttrib2fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1268,9 +1484,11 @@ function vertexAttrib2fvOpt(index, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function vertexAttrib3fvOpt(index, value) { + // console.log('GLOpt: vertexAttrib3fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1279,9 +1497,11 @@ function vertexAttrib3fvOpt(index, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function vertexAttrib4fvOpt(index, value) { + // console.log('GLOpt: vertexAttrib4fv'); if (next_index + 3 + value.length >= total_size) { flushCommands(); } @@ -1290,9 +1510,11 @@ function vertexAttrib4fvOpt(index, value) { buffer_data[next_index + 2] = value.length; buffer_data.set(value, next_index + 3); next_index += 3 + value.length; + ++commandCount; } function vertexAttribPointerOpt(index, size, type, normalized, stride, offset) { + // console.log('GLOpt: vertexAttribPointer'); if (next_index + 7 >= total_size) { flushCommands(); } @@ -1304,9 +1526,11 @@ function vertexAttribPointerOpt(index, size, type, normalized, stride, offset) { buffer_data[next_index + 5] = stride; buffer_data[next_index + 6] = offset; next_index += 7; + ++commandCount; } function viewportOpt(x, y, width, height) { + // console.log('GLOpt: viewport'); if (next_index + 5 >= total_size) { flushCommands(); } @@ -1316,6 +1540,7 @@ function viewportOpt(x, y, width, height) { buffer_data[next_index + 3] = width; buffer_data[next_index + 4] = height; next_index += 5; + ++commandCount; } function isSupportTypeArray() {