@@ -1518,14 +1518,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1518
1518
glCompressedTexImage2D : ( target , level , internalFormat , width , height , border , imageSize , data ) = > {
1519
1519
#if MAX_WEBGL_VERSION >= 2
1520
1520
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1521
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1522
- // those always when possible.
1523
1521
if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1524
1522
GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , imageSize , data ) ;
1525
- } else {
1526
- GLctx . compressedTexImage2D( target , level, internalFormat, width, height, border, HEAPU8 , data, imageSize) ;
1523
+ return ;
1527
1524
}
1525
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1526
+ GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , HEAPU8 , data , imageSize ) ;
1528
1527
return ;
1528
+ #endif
1529
1529
}
1530
1530
#endif
1531
1531
GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
@@ -1535,14 +1535,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1535
1535
glCompressedTexSubImage2D : ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) = > {
1536
1536
#if MAX_WEBGL_VERSION >= 2
1537
1537
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1538
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1539
- // those always when possible.
1540
1538
if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1541
1539
GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) ;
1542
- } else {
1543
- GLctx . compressedTexSubImage2D( target , level, xoffset, yoffset, width, height, format, HEAPU8 , data, imageSize) ;
1540
+ return ;
1544
1541
}
1542
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1543
+ GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , HEAPU8 , data , imageSize ) ;
1545
1544
return ;
1545
+ #endif
1546
1546
}
1547
1547
#endif
1548
1548
GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
@@ -1637,18 +1637,18 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1637
1637
}
1638
1638
#endif
1639
1639
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1640
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1641
- // those always when possible.
1642
1640
if ( GLctx . currentPixelUnpackBufferBinding ) {
1643
1641
GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ) ;
1644
1642
return ;
1645
1643
}
1644
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1646
1645
if ( pixels ) {
1647
1646
var heap = heapObjectForWebGLType ( type ) ;
1648
1647
var index = toTypedArrayIndex ( pixels , heap ) ;
1649
1648
GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , heap , index ) ;
1650
1649
return ;
1651
1650
}
1651
+ #endif
1652
1652
}
1653
1653
#endif
1654
1654
var pixelData = pixels ? emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , internalFormat ) : null ;
@@ -1672,15 +1672,17 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1672
1672
}
1673
1673
#endif
1674
1674
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1675
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1676
- // those always when possible.
1677
1675
if ( GLctx . currentPixelUnpackBufferBinding ) {
1678
1676
GLctx . texSubImage2D( target , level, xoffset, yoffset, width, height, format, type, pixels) ;
1679
- } else if ( pixels ) {
1677
+ return ;
1678
+ }
1679
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1680
+ if ( pixels ) {
1680
1681
var heap = heapObjectForWebGLType ( type ) ;
1681
1682
GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , heap , toTypedArrayIndex ( pixels , heap ) ) ;
1682
1683
return ;
1683
1684
}
1685
+ #endif
1684
1686
}
1685
1687
#endif
1686
1688
var pixelData = pixels ? emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , 0 ) : null ;
@@ -1695,16 +1697,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1695
1697
glReadPixels : ( x , y , width , height , format , type , pixels ) => {
1696
1698
#if MAX_WEBGL_VERSION >= 2
1697
1699
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1698
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1699
- // those always when possible.
1700
1700
if ( GLctx . currentPixelPackBufferBinding ) {
1701
1701
GLctx . readPixels ( x , y , width , height , format , type , pixels ) ;
1702
- } else {
1703
- var heap = heapObjectForWebGLType ( type ) ;
1704
- var target = toTypedArrayIndex ( pixels , heap ) ;
1705
- GLctx . readPixels ( x , y , width , height , format , type , heap , target ) ;
1702
+ return ;
1706
1703
}
1704
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1705
+ var heap = heapObjectForWebGLType ( type ) ;
1706
+ var target = toTypedArrayIndex ( pixels , heap ) ;
1707
+ GLctx . readPixels ( x , y , width , height , format , type , heap , target ) ;
1707
1708
return ;
1709
+ #endif
1708
1710
}
1709
1711
#endif
1710
1712
var pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , format ) ;
@@ -1841,14 +1843,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1841
1843
}
1842
1844
#endif
1843
1845
1844
- #if MAX_WEBGL_VERSION >= 2
1846
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1845
1847
if ( { { { isCurrentContextWebGL2 ( ) } } } ) {
1846
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1847
- // those always when possible. If size is zero, WebGL would interpret
1848
- // uploading the whole input arraybuffer (starting from given offset),
1849
- // which would not make sense in WebAssembly, so avoid uploading if size
1850
- // is zero. However we must still call bufferData to establish a backing
1851
- // storage of zero bytes.
1848
+ // If size is zero, WebGL would interpret uploading the whole input
1849
+ // arraybuffer (starting from given offset), which would not make sense in
1850
+ // WebAssembly, so avoid uploading if size is zero. However we must still
1851
+ // call bufferData to establish a backing storage of zero bytes.
1852
1852
if ( data && size ) {
1853
1853
GLctx . bufferData ( target , HEAPU8 , usage , data , size ) ;
1854
1854
} else {
@@ -1865,10 +1865,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1865
1865
} ,
1866
1866
1867
1867
glBufferSubData : ( target , offset , size , data ) = > {
1868
- #if MAX_WEBGL_VERSION >= 2
1868
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1869
1869
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1870
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1871
- // those always when possible.
1872
1870
size && GLctx . bufferSubData ( target , offset , HEAPU8 , data , size ) ;
1873
1871
return ;
1874
1872
}
@@ -2431,8 +2429,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2431
2429
count && GLctx . uniform1iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count ) ;
2432
2430
#else
2433
2431
2434
- #if MAX_WEBGL_VERSION >= 2
2435
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2432
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2433
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2436
2434
count && GLctx . uniform1iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count) ;
2437
2435
return ;
2438
2436
}
@@ -2472,8 +2470,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2472
2470
count && GLctx . uniform2iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 2 ) ;
2473
2471
#else
2474
2472
2475
- #if MAX_WEBGL_VERSION >= 2
2476
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2473
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2474
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2477
2475
count && GLctx . uniform2iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 2 ) ;
2478
2476
return ;
2479
2477
}
@@ -2514,8 +2512,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2514
2512
count && GLctx . uniform3iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 3 ) ;
2515
2513
#else
2516
2514
2517
- #if MAX_WEBGL_VERSION >= 2
2518
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2515
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2516
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2519
2517
count && GLctx . uniform3iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 3 ) ;
2520
2518
return ;
2521
2519
}
@@ -2557,9 +2555,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2557
2555
count && GLctx . uniform4iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 4 ) ;
2558
2556
#else
2559
2557
2560
- #if MAX_WEBGL_VERSION >= 2
2561
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2562
- // those always when possible.
2558
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2563
2559
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2564
2560
count && GLctx . uniform4iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 4 ) ;
2565
2561
return ;
@@ -2603,8 +2599,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2603
2599
count && GLctx . uniform1fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count ) ;
2604
2600
#else
2605
2601
2606
- #if MAX_WEBGL_VERSION >= 2
2607
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2602
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2603
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2608
2604
count && GLctx . uniform1fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count ) ;
2609
2605
return ;
2610
2606
}
@@ -2644,9 +2640,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2644
2640
count && GLctx . uniform2fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 2 ) ;
2645
2641
#else
2646
2642
2647
- #if MAX_WEBGL_VERSION >= 2
2648
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2649
- // those always when possible.
2643
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2650
2644
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2651
2645
count && GLctx . uniform2fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 2 ) ;
2652
2646
return ;
@@ -2671,7 +2665,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2671
2665
} ,
2672
2666
2673
2667
glUniform3fv__deps : [ '$webglGetUniformLocation'
2674
- #if GL_POOL_TEMP_BUFFERS && MIN_WEBGL_VERSION == 1
2668
+ #if GL_POOL_TEMP_BUFFERS && ! ( MIN_WEBGL_VERSION >= 2 && WEBGL_USE_GARBAGE_FREE_APIS )
2675
2669
, '$miniTempWebGLFloatBuffers'
2676
2670
#endif
2677
2671
] ,
@@ -2681,16 +2675,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2681
2675
assert ( ( value % 4 ) == 0 , 'Pointer to float data passed to glUniform3fv must be aligned to four bytes!' + value ) ;
2682
2676
#endif
2683
2677
2684
- #if MIN_WEBGL_VERSION >= 2
2678
+ #if MIN_WEBGL_VERSION >= 2 && WEBGL_USE_GARBAGE_FREE_APIS
2685
2679
#if GL_ASSERTIONS
2686
2680
assert ( GL . currentContext . version >= 2 ) ;
2687
2681
#endif
2688
2682
count && GLctx . uniform3fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 3 ) ;
2689
2683
#else
2690
2684
2691
- #if MAX_WEBGL_VERSION >= 2
2692
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2693
- // those always when possible.
2685
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2694
2686
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2695
2687
count && GLctx . uniform3fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 3 ) ;
2696
2688
return ;
@@ -2733,9 +2725,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2733
2725
count && GLctx . uniform4fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2734
2726
#else
2735
2727
2736
- #if MAX_WEBGL_VERSION >= 2
2737
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2738
- // those always when possible.
2728
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2739
2729
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2740
2730
count && GLctx . uniform4fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2741
2731
return ;
@@ -2783,9 +2773,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2783
2773
count && GLctx . uniformMatrix2fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2784
2774
#else
2785
2775
2786
- #if MAX_WEBGL_VERSION >= 2
2787
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2788
- // those always when possible.
2776
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2789
2777
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2790
2778
count && GLctx . uniformMatrix2fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2791
2779
return ;
@@ -2829,9 +2817,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2829
2817
count && GLctx . uniformMatrix3fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 9 ) ;
2830
2818
#else
2831
2819
2832
- #if MAX_WEBGL_VERSION >= 2
2833
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2834
- // those always when possible.
2820
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2835
2821
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2836
2822
count && GLctx . uniformMatrix3fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 9 ) ;
2837
2823
return ;
@@ -2863,7 +2849,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2863
2849
} ,
2864
2850
2865
2851
glUniformMatrix4fv__deps : [ '$webglGetUniformLocation'
2866
- #if GL_POOL_TEMP_BUFFERS && MIN_WEBGL_VERSION == 1
2852
+ #if GL_POOL_TEMP_BUFFERS && ! ( MIN_WEBGL_VERSION >= 2 && WEBGL_USE_GARBAGE_FREE_APIS )
2867
2853
, '$miniTempWebGLFloatBuffers'
2868
2854
#endif
2869
2855
] ,
@@ -2873,16 +2859,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2873
2859
assert ( ( value & 3 ) == 0 , 'Pointer to float data passed to glUniformMatrix4fv must be aligned to four bytes!' ) ;
2874
2860
#endif
2875
2861
2876
- #if MIN_WEBGL_VERSION >= 2
2862
+ #if MIN_WEBGL_VERSION >= 2 && WEBGL_USE_GARBAGE_FREE_APIS
2877
2863
#if GL_ASSERTIONS
2878
2864
assert ( GL . currentContext . version >= 2 ) ;
2879
2865
#endif
2880
2866
count && GLctx . uniformMatrix4fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 16 ) ;
2881
2867
#else
2882
2868
2883
- #if MAX_WEBGL_VERSION >= 2
2884
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2885
- // those always when possible.
2869
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2886
2870
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2887
2871
count && GLctx . uniformMatrix4fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 16 ) ;
2888
2872
return ;
@@ -2921,7 +2905,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2921
2905
var view = { { { makeHEAPView ( 'F32' , 'value' , 'value+count*64' ) } } } ;
2922
2906
}
2923
2907
GLctx . uniformMatrix4fv ( webglGetUniformLocation ( location ) , ! ! transpose , view ) ;
2924
- #endif // MIN_WEBGL_VERSION >= 2
2908
+ #endif // MIN_WEBGL_VERSION >= 2 && WEBGL_USE_GARBAGE_FREE_APIS
2925
2909
} ,
2926
2910
2927
2911
glBindBuffer : ( target , buffer ) = > {
@@ -4157,11 +4141,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
4157
4141
}
4158
4142
4159
4143
if ( ! ( mapping . access & 0x10 ) ) { /* GL_MAP_FLUSH_EXPLICIT_BIT */
4160
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
4144
+ #if WEBGL_USE_GARBAGE_FREE_APIS
4145
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
4161
4146
GLctx . bufferSubData ( target , mapping . offset , HEAPU8 , mapping . mem , mapping . length ) ;
4162
- } else {
4163
- GLctx . bufferSubData ( target , mapping . offset , HEAPU8 . subarray ( mapping . mem , mapping . mem + mapping . length ) ) ;
4164
- }
4147
+ } else
4148
+ #endif
4149
+ GLctx . bufferSubData ( target , mapping . offset , HEAPU8 . subarray ( mapping . mem , mapping . mem + mapping . length ) ) ;
4165
4150
}
4166
4151
_free ( mapping . mem ) ;
4167
4152
mapping . mem = 0 ;
0 commit comments