@@ -545,45 +545,45 @@ var LibraryHtml5WebGL = {
545
545
emscripten_webgl_get_parameter_i64v : ( param , dst ) => writeI53ToI64 ( dst , GLctx . getParameter ( param ) ) ,
546
546
} ;
547
547
548
- function handleWebGLProxying ( funcs ) {
549
- #if SHARED_MEMORY
550
- // Process 'sync_on_webgl_context_handle_thread' and 'sync_on_current_webgl_context_thread' pseudo-proxying modes
551
- // to appropriate proxying mechanism, either proxying on-demand, unconditionally, or never, depending on build modes.
552
- // 'sync_on_webgl_context_handle_thread' is used for function signatures that take a HTML5 WebGL context handle
553
- // object as the first argument. 'sync_on_current_webgl_context_thread' is used for functions that operate on the
554
- // implicit "current WebGL context" as activated via emscripten_webgl_make_current() function.
555
548
549
+ function handleWebGLProxying ( funcs ) {
550
+ #if PTHREADS
551
+ // Process 'sync_on_webgl_context_handle_thread' and
552
+ // 'sync_on_current_webgl_context_thread' pseudo-proxying modes to appropriate
553
+ // proxying mechanism, either proxying on-demand, unconditionally, or never,
554
+ // depending on build modes.
555
+ // 'sync_on_webgl_context_handle_thread' is used for function signatures that
556
+ // take a HTML5 WebGL context handle object as the first argument.
557
+ // 'sync_on_current_webgl_context_thread' is used for functions that operate on
558
+ // the implicit "current WebGL context" as activated via
559
+ // emscripten_webgl_make_current() function.
556
560
function listOfNFunctionArgs ( func ) {
557
- var args = [ ] ;
561
+ const args = [ ] ;
558
562
for ( var i = 0 ; i < func . length ; ++ i ) {
559
563
args . push ( 'p' + i ) ;
560
564
}
561
565
return args ;
562
566
}
563
567
564
- var targetingOffscreenCanvas , targetingOffscreenFramebuffer ;
565
- #if OFFSCREENCANVAS_SUPPORT
566
- targetingOffscreenCanvas = true ;
567
- #endif
568
- #if OFFSCREEN_FRAMEBUFFER
569
- targetingOffscreenFramebuffer = true ;
570
- #endif
568
+ const targetingOffscreenCanvas = { { { OFFSCREENCANVAS_SUPPORT } } } ;
569
+ const targetingOffscreenFramebuffer = { { { OFFSCREEN_FRAMEBUFFER } } } ;
571
570
572
- for ( var i in funcs ) {
571
+ for ( const i in funcs ) {
573
572
// Is this a function that takes GL context handle as first argument?
574
- var proxyContextHandle = funcs [ i + '__proxy' ] == 'sync_on_webgl_context_handle_thread' ;
573
+ const proxyContextHandle = funcs [ i + '__proxy' ] == 'sync_on_webgl_context_handle_thread' ;
575
574
576
575
// Is this a function that operates on the implicit current GL context object?
577
- var proxyCurrentContext = funcs [ i + '__proxy' ] == 'sync_on_current_webgl_context_thread' ;
576
+ const proxyCurrentContext = funcs [ i + '__proxy' ] == 'sync_on_current_webgl_context_thread' ;
578
577
579
578
if ( ! proxyContextHandle && ! proxyCurrentContext ) {
580
579
continue; // no resolving of pseudo-proxying needed for this function.
581
580
}
582
581
583
582
if ( targetingOffscreenCanvas && ( targetingOffscreenFramebuffer || proxyContextHandle ) ) {
584
- // Dynamically check at runtime whether the current thread owns the GL context handle/current GL context
585
- // object. If not, proxy the call to main thread.
586
- // TODO: this handles the calling pthread and main thread cases, but not yet the case from pthread->pthread.
583
+ // Dynamically check at runtime whether the current thread owns the GL context
584
+ // handle/current GL context object. If not, proxy the call to main thread.
585
+ // TODO: this handles the calling pthread and main thread cases, but not yet
586
+ // the case from pthread->pthread.
587
587
const sig = funcs [ i + '__sig' ] || LibraryManager . library [ i + '__sig' ]
588
588
assert ( sig ) ;
589
589
funcs [ i + '_calling_thread' ] = funcs [ i ] ;
@@ -594,10 +594,10 @@ function handleWebGLProxying(funcs) {
594
594
funcs [ i + '__deps' ] . push ( i + '_calling_thread' ) ;
595
595
funcs [ i + '__deps' ] . push ( i + '_main_thread' ) ;
596
596
delete funcs [ i + '__proxy' ] ;
597
- var funcArgs = listOfNFunctionArgs ( funcs [ i ] ) ;
598
- var funcArgsString = funcArgs . join ( ',' ) ;
599
- var retStatement = sig [ 0 ] != 'v' ? 'return' : '' ;
600
- var contextCheck = proxyContextHandle ? 'GL.contexts[p0]' : 'GLctx' ;
597
+ const funcArgs = listOfNFunctionArgs ( funcs [ i ] ) ;
598
+ const funcArgsString = funcArgs . join ( ',' ) ;
599
+ const retStatement = sig [ 0 ] != 'v' ? 'return' : '' ;
600
+ const contextCheck = proxyContextHandle ? 'GL . contexts [ p0 ] ' : 'GLctx ';
601
601
var funcBody = `${ retStatement } ${ contextCheck } ? _${ i } _calling_thread(${ funcArgsString } ) : _${ i } _main_thread(${ funcArgsString } );` ;
602
602
if ( funcs [ i + '_before_on_calling_thread' ] ) {
603
603
funcs [ i + '__deps' ] . push ( '$' + i + '_before_on_calling_thread' ) ;
@@ -606,8 +606,8 @@ function handleWebGLProxying(funcs) {
606
606
funcArgs . push ( funcBody ) ;
607
607
funcs [ i ] = new ( Function . prototype . bind . call ( Function , Function , ...funcArgs ) ) ;
608
608
} else if ( targetingOffscreenFramebuffer ) {
609
- // When targeting only OFFSCREEN_FRAMEBUFFER, unconditionally proxy all GL calls to
610
- // main thread.
609
+ // When targeting only OFFSCREEN_FRAMEBUFFER, unconditionally proxy all GL
610
+ // calls to main thread.
611
611
funcs [ i + '__proxy '] = 'sync' ;
612
612
} else {
613
613
// Building without OFFSCREENCANVAS_SUPPORT or OFFSCREEN_FRAMEBUFFER; or building
@@ -620,10 +620,10 @@ function handleWebGLProxying(funcs) {
620
620
#else
621
621
// In single threaded mode just delete our custom __proxy addributes, otherwise
622
622
// they will causes errors in the JS compiler.
623
- for ( var i in funcs ) {
623
+ for ( const i in funcs ) {
624
624
delete funcs [ i + '__proxy '] ;
625
625
}
626
- #endif // SHARED_MEMORY
626
+ #endif // PTHREADS
627
627
}
628
628
629
629
handleWebGLProxying ( LibraryHtml5WebGL ) ;
0 commit comments