@@ -504,7 +504,7 @@ var emscriptenCpuProfiler = {
504
504
505
505
// Work around Microsoft Edge bug where webGLContext.function.length always returns 0.
506
506
webGLFunctionLength : function ( f ) {
507
- var l0 = [ 'getContextAttributes' , 'isContextLost' , 'getSupportedExtensions' , 'createBuffer' , 'createFramebuffer' , 'createProgram' , 'createRenderbuffer' , 'createTexture' , 'finish' , 'flush' , 'getError' , 'createVertexArray' , 'createQuery' , 'createSampler' , 'createTransformFeedback' , 'endTransformFeedback' , 'pauseTransformFeedback' , 'resumeTransformFeedback' ] ;
507
+ var l0 = [ 'getContextAttributes' , 'isContextLost' , 'getSupportedExtensions' , 'createBuffer' , 'createFramebuffer' , 'createProgram' , 'createRenderbuffer' , 'createTexture' , 'finish' , 'flush' , 'getError' , 'createVertexArray' , 'createQuery' , 'createSampler' , 'createTransformFeedback' , 'endTransformFeedback' , 'pauseTransformFeedback' , 'resumeTransformFeedback' , 'makeXRCompatible' ] ;
508
508
var l1 = [ 'getExtension' , 'activeTexture' , 'blendEquation' , 'checkFramebufferStatus' , 'clear' , 'clearDepth' , 'clearStencil' , 'compileShader' , 'createShader' , 'cullFace' , 'deleteBuffer' , 'deleteFramebuffer' , 'deleteProgram' , 'deleteRenderbuffer' , 'deleteShader' , 'deleteTexture' , 'depthFunc' , 'depthMask' , 'disable' , 'disableVertexAttribArray' , 'enable' , 'enableVertexAttribArray' , 'frontFace' , 'generateMipmap' , 'getAttachedShaders' , 'getParameter' , 'getProgramInfoLog' , 'getShaderInfoLog' , 'getShaderSource' , 'isBuffer' , 'isEnabled' , 'isFramebuffer' , 'isProgram' , 'isRenderbuffer' , 'isShader' , 'isTexture' , 'lineWidth' , 'linkProgram' , 'stencilMask' , 'useProgram' , 'validateProgram' , 'deleteQuery' , 'isQuery' , 'deleteVertexArray' , 'bindVertexArray' , 'isVertexArray' , 'drawBuffers' , 'readBuffer' , 'endQuery' , 'deleteSampler' , 'isSampler' , 'isSync' , 'deleteSync' , 'deleteTransformFeedback' , 'isTransformFeedback' , 'beginTransformFeedback' ] ;
509
509
var l2 = [ 'attachShader' , 'bindBuffer' , 'bindFramebuffer' , 'bindRenderbuffer' , 'bindTexture' , 'blendEquationSeparate' , 'blendFunc' , 'depthRange' , 'detachShader' , 'getActiveAttrib' , 'getActiveUniform' , 'getAttribLocation' , 'getBufferParameter' , 'getProgramParameter' , 'getRenderbufferParameter' , 'getShaderParameter' , 'getShaderPrecisionFormat' , 'getTexParameter' , 'getUniform' , 'getUniformLocation' , 'getVertexAttrib' , 'getVertexAttribOffset' , 'hint' , 'pixelStorei' , 'polygonOffset' , 'sampleCoverage' , 'shaderSource' , 'stencilMaskSeparate' , 'uniform1f' , 'uniform1fv' , 'uniform1i' , 'uniform1iv' , 'uniform2fv' , 'uniform2iv' , 'uniform3fv' , 'uniform3iv' , 'uniform4fv' , 'uniform4iv' , 'vertexAttrib1f' , 'vertexAttrib1fv' , 'vertexAttrib2fv' , 'vertexAttrib3fv' , 'vertexAttrib4fv' , 'vertexAttribDivisor' , 'beginQuery' , 'invalidateFramebuffer' , 'getFragDataLocation' , 'uniform1ui' , 'uniform1uiv' , 'uniform2uiv' , 'uniform3uiv' , 'uniform4uiv' , 'vertexAttribI4iv' , 'vertexAttribI4uiv' , 'getQuery' , 'getQueryParameter' , 'bindSampler' , 'getSamplerParameter' , 'fenceSync' , 'getSyncParameter' , 'bindTransformFeedback' , 'getTransformFeedbackVarying' , 'getIndexedParameter' , 'getUniformIndices' , 'getUniformBlockIndex' , 'getActiveUniformBlockName' ] ;
510
510
var l3 = [ 'bindAttribLocation' , 'bufferData' , 'bufferSubData' , 'drawArrays' , 'getFramebufferAttachmentParameter' , 'stencilFunc' , 'stencilOp' , 'texParameterf' , 'texParameteri' , 'uniform2f' , 'uniform2i' , 'uniformMatrix2fv' , 'uniformMatrix3fv' , 'uniformMatrix4fv' , 'vertexAttrib2f' , 'getBufferSubData' , 'getInternalformatParameter' , 'uniform2ui' , 'uniformMatrix2x3fv' , 'uniformMatrix3x2fv' , 'uniformMatrix2x4fv' , 'uniformMatrix4x2fv' , 'uniformMatrix3x4fv' , 'uniformMatrix4x3fv' , 'clearBufferiv' , 'clearBufferuiv' , 'clearBufferfv' , 'samplerParameteri' , 'samplerParameterf' , 'clientWaitSync' , 'waitSync' , 'transformFeedbackVaryings' , 'bindBufferBase' , 'getActiveUniforms' , 'getActiveUniformBlockParameter' , 'uniformBlockBinding' ] ;
@@ -578,7 +578,7 @@ var emscriptenCpuProfiler = {
578
578
} ,
579
579
580
580
hookWebGLFunction : function ( f , glCtx ) {
581
- var section = ( this . hotGLFunctions . incudes ( f ) || f . startsWith ( 'uniform' ) || f . startsWith ( 'vertexAttrib' ) ) ? 0 : 1 ;
581
+ var section = ( this . hotGLFunctions . includes ( f ) || f . startsWith ( 'uniform' ) || f . startsWith ( 'vertexAttrib' ) ) ? 0 : 1 ;
582
582
var realf = 'real_' + f ;
583
583
glCtx [ realf ] = glCtx [ f ] ;
584
584
var numArgs = this . webGLFunctionLength ( f ) ; // On Firefox & Chrome, could do "glCtx[realf].length", but that doesn't work on Edge, which always reports 0.
@@ -641,6 +641,27 @@ var emscriptenCpuProfiler = {
641
641
this . endSection ( 0 ) ;
642
642
return ret ;
643
643
} ;
644
+ glCtx [ 'bufferData' ] = ( a1 , a2 , a3 , a4 , a5 ) => {
645
+ // WebGL1/2 versions have different parameters (not just extra ones)
646
+ var ret = ( a4 !== undefined ) ? glCtx [ 'real_bufferData' ] ( a1 , a2 , a3 , a4 , a5 ) : glCtx [ 'real_bufferData' ] ( a1 , a2 , a3 ) ;
647
+ return ret ;
648
+ } ;
649
+ const matrixFuncs = [ 'uniformMatrix2fv' , 'uniformMatrix3fv' , 'uniformMatrix4fv' ] ;
650
+ matrixFuncs . forEach ( f => {
651
+ glCtx [ f ] = ( a1 , a2 , a3 , a4 , a5 ) => {
652
+ // WebGL2 version has 2 extra optional parameters, ensure we forward them
653
+ var ret = ( a4 !== undefined ) ? glCtx [ 'real_' + f ] ( a1 , a2 , a3 , a4 , a5 ) : glCtx [ 'real_' + f ] ( a1 , a2 , a3 ) ;
654
+ return ret ;
655
+ }
656
+ } ) ;
657
+ const ndvFuncs = [ 'uniform1fv' , 'uniform1iv' , 'uniform2fv' , 'uniform2iv' , 'uniform3fv' , 'uniform3iv' , 'uniform4fv' , 'uniform4iv' ] ;
658
+ ndvFuncs . forEach ( f => {
659
+ glCtx [ f ] = ( a1 , a2 , a3 , a4 ) => {
660
+ // WebGL2 version has 1 extra parameter, ensure we forward them
661
+ var ret = ( a4 !== undefined ) ? glCtx [ 'real_' + f ] ( a1 , a2 , a3 , a4 ) : glCtx [ 'real_' + f ] ( a1 , a2 , a3 ) ;
662
+ return ret ;
663
+ }
664
+ } ) ;
644
665
}
645
666
} ;
646
667
@@ -674,3 +695,6 @@ function cpuprofiler_add_hooks() { emscriptenCpuProfiler.initialize(); }
674
695
if ( typeof document != 'undefined' ) {
675
696
emscriptenCpuProfiler . initialize ( ) ;
676
697
}
698
+
699
+ // Declared in globalThis so that `onclick` handlers work when `-sMODULARIZE=1`
700
+ globalThis . emscriptenCpuProfiler = emscriptenCpuProfiler ;
0 commit comments