13
13
if ( MIN_WEBGL_VERSION >= 2 ) return 'true' ;
14
14
if ( MAX_WEBGL_VERSION <= 1 ) return 'false' ;
15
15
return 'GL.currentContext.version >= 2' ;
16
- }
16
+ } ;
17
+
17
18
null ;
18
19
} } }
19
20
@@ -1517,14 +1518,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1517
1518
glCompressedTexImage2D : ( target , level , internalFormat , width , height , border , imageSize , data ) = > {
1518
1519
#if MAX_WEBGL_VERSION >= 2
1519
1520
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1520
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1521
- // those always when possible.
1522
1521
if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1523
1522
GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , imageSize , data ) ;
1524
- } else {
1525
- GLctx . compressedTexImage2D( target , level, internalFormat, width, height, border, HEAPU8 , data, imageSize) ;
1523
+ return ;
1526
1524
}
1525
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1526
+ GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , HEAPU8 , data , imageSize ) ;
1527
1527
return ;
1528
+ #endif
1528
1529
}
1529
1530
#endif
1530
1531
GLctx . compressedTexImage2D ( target , level , internalFormat , width , height , border , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
@@ -1534,14 +1535,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1534
1535
glCompressedTexSubImage2D : ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) = > {
1535
1536
#if MAX_WEBGL_VERSION >= 2
1536
1537
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1537
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1538
- // those always when possible.
1539
1538
if ( GLctx . currentPixelUnpackBufferBinding || ! imageSize ) {
1540
1539
GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , imageSize , data ) ;
1541
- } else {
1542
- GLctx . compressedTexSubImage2D( target , level, xoffset, yoffset, width, height, format, HEAPU8 , data, imageSize) ;
1540
+ return ;
1543
1541
}
1542
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1543
+ GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , HEAPU8 , data , imageSize ) ;
1544
1544
return ;
1545
+ #endif
1545
1546
}
1546
1547
#endif
1547
1548
GLctx . compressedTexSubImage2D ( target , level , xoffset , yoffset , width , height , format , data ? { { { makeHEAPView ( 'U8' , 'data' , 'data+imageSize' ) } } } : null ) ;
@@ -1636,20 +1637,21 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1636
1637
}
1637
1638
#endif
1638
1639
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1639
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1640
- // those always when possible.
1641
1640
if ( GLctx . currentPixelUnpackBufferBinding ) {
1642
1641
GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ) ;
1643
- } else if ( pixels ) {
1642
+ return ;
1643
+ }
1644
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1645
+ if ( pixels ) {
1644
1646
var heap = heapObjectForWebGLType ( type ) ;
1645
1647
GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , heap , toTypedArrayIndex ( pixels , heap ) ) ;
1646
- } else {
1647
- GLctx . texImage2D( target , level, internalFormat, width, height, border, format, type, null) ;
1648
+ return ;
1648
1649
}
1649
- return ;
1650
+ #endif
1650
1651
}
1651
1652
#endif
1652
- GLctx . texImage2D ( target , level, internalFormat, width, height, border, format, type, pixels ? emscriptenWebGLGetTexPixelData ( type, format, width, height, pixels, internalFormat ) : null ) ;
1653
+ var pixelData = pixels ? emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , internalFormat ) : null ;
1654
+ GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixelData ) ;
1653
1655
} ,
1654
1656
1655
1657
glTexSubImage2D__deps : [ '$emscriptenWebGLGetTexPixelData'
@@ -1669,21 +1671,20 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1669
1671
}
1670
1672
#endif
1671
1673
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1672
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1673
- // those always when possible.
1674
1674
if ( GLctx . currentPixelUnpackBufferBinding ) {
1675
1675
GLctx . texSubImage2D( target , level, xoffset, yoffset, width, height, format, type, pixels) ;
1676
- } else if ( pixels ) {
1676
+ return ;
1677
+ }
1678
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1679
+ if ( pixels ) {
1677
1680
var heap = heapObjectForWebGLType ( type ) ;
1678
1681
GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , heap , toTypedArrayIndex ( pixels , heap ) ) ;
1679
- } else {
1680
- GLctx . texSubImage2D( target , level, xoffset, yoffset, width, height, format, type, null) ;
1682
+ return ;
1681
1683
}
1682
- return ;
1684
+ #endif
1683
1685
}
1684
1686
#endif
1685
- var pixelData = null ;
1686
- if ( pixels ) pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , 0 ) ;
1687
+ var pixelData = pixels ? emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , 0 ) : null ;
1687
1688
GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , pixelData ) ;
1688
1689
} ,
1689
1690
@@ -1695,16 +1696,16 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1695
1696
glReadPixels : ( x , y , width , height , format , type , pixels ) => {
1696
1697
#if MAX_WEBGL_VERSION >= 2
1697
1698
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1698
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1699
- // those always when possible.
1700
1699
if ( GLctx . currentPixelPackBufferBinding ) {
1701
1700
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 ) ;
1701
+ return ;
1706
1702
}
1703
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1704
+ var heap = heapObjectForWebGLType ( type ) ;
1705
+ var target = toTypedArrayIndex ( pixels , heap ) ;
1706
+ GLctx . readPixels ( x , y , width , height , format , type , heap , target ) ;
1707
1707
return ;
1708
+ #endif
1708
1709
}
1709
1710
#endif
1710
1711
var pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , format ) ;
@@ -1841,36 +1842,30 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
1841
1842
}
1842
1843
#endif
1843
1844
1844
- #if MAX_WEBGL_VERSION >= 2
1845
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1845
1846
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.
1847
+ // If size is zero, WebGL would interpret uploading the whole input
1848
+ // arraybuffer (starting from given offset), which would not make sense in
1849
+ // WebAssembly, so avoid uploading if size is zero. However we must still
1850
+ // call bufferData to establish a backing storage of zero bytes.
1852
1851
if ( data && size ) {
1853
1852
GLctx . bufferData ( target , HEAPU8 , usage , data , size ) ;
1854
1853
} else {
1855
1854
GLctx . bufferData ( target , size , usage ) ;
1856
1855
}
1857
- } else {
1858
- #endif
1859
- // N.b. here first form specifies a heap subarray, second form an integer
1860
- // size, so the ?: code here is polymorphic. It is advised to avoid
1861
- // randomly mixing both uses in calling code, to avoid any potential JS
1862
- // engine JIT issues.
1863
- GLctx . bufferData ( target , data ? HEAPU8 . subarray ( data , data + size ) : size , usage ) ;
1864
- #if MAX_WEBGL_VERSION >= 2
1856
+ return ;
1865
1857
}
1866
1858
#endif
1859
+ // N.b. here first form specifies a heap subarray, second form an integer
1860
+ // size, so the ?: code here is polymorphic. It is advised to avoid
1861
+ // randomly mixing both uses in calling code, to avoid any potential JS
1862
+ // engine JIT issues.
1863
+ GLctx . bufferData ( target , data ? HEAPU8 . subarray ( data , data + size ) : size , usage ) ;
1867
1864
} ,
1868
1865
1869
1866
glBufferSubData : ( target , offset , size , data ) = > {
1870
- #if MAX_WEBGL_VERSION >= 2
1867
+ #if WEBGL_USE_GARBAGE_FREE_APIS
1871
1868
if ( { { { isCurrentContextWebGL2( ) } } } ) {
1872
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
1873
- // those always when possible.
1874
1869
size && GLctx . bufferSubData ( target , offset , HEAPU8 , data , size ) ;
1875
1870
return ;
1876
1871
}
@@ -2433,8 +2428,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2433
2428
count && GLctx . uniform1iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count ) ;
2434
2429
#else
2435
2430
2436
- #if MAX_WEBGL_VERSION >= 2
2437
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2431
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2432
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2438
2433
count && GLctx . uniform1iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count) ;
2439
2434
return ;
2440
2435
}
@@ -2474,8 +2469,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2474
2469
count && GLctx . uniform2iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 2 ) ;
2475
2470
#else
2476
2471
2477
- #if MAX_WEBGL_VERSION >= 2
2478
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2472
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2473
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2479
2474
count && GLctx . uniform2iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 2 ) ;
2480
2475
return ;
2481
2476
}
@@ -2516,8 +2511,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2516
2511
count && GLctx . uniform3iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 3 ) ;
2517
2512
#else
2518
2513
2519
- #if MAX_WEBGL_VERSION >= 2
2520
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2514
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2515
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2521
2516
count && GLctx . uniform3iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 3 ) ;
2522
2517
return ;
2523
2518
}
@@ -2559,9 +2554,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2559
2554
count && GLctx . uniform4iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 4 ) ;
2560
2555
#else
2561
2556
2562
- #if MAX_WEBGL_VERSION >= 2
2563
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2564
- // those always when possible.
2557
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2565
2558
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2566
2559
count && GLctx . uniform4iv ( webglGetUniformLocation ( location ) , HEAP32 , { { { getHeapOffset ( 'value' , 'i32' ) } } } , count * 4 ) ;
2567
2560
return ;
@@ -2605,8 +2598,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2605
2598
count && GLctx . uniform1fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count ) ;
2606
2599
#else
2607
2600
2608
- #if MAX_WEBGL_VERSION >= 2
2609
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
2601
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2602
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
2610
2603
count && GLctx . uniform1fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count ) ;
2611
2604
return ;
2612
2605
}
@@ -2646,9 +2639,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2646
2639
count && GLctx . uniform2fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 2 ) ;
2647
2640
#else
2648
2641
2649
- #if MAX_WEBGL_VERSION >= 2
2650
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2651
- // those always when possible.
2642
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2652
2643
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2653
2644
count && GLctx . uniform2fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 2 ) ;
2654
2645
return ;
@@ -2690,9 +2681,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2690
2681
count && GLctx . uniform3fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 3 ) ;
2691
2682
#else
2692
2683
2693
- #if MAX_WEBGL_VERSION >= 2
2694
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2695
- // those always when possible.
2684
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2696
2685
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2697
2686
count && GLctx . uniform3fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 3 ) ;
2698
2687
return ;
@@ -2735,9 +2724,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2735
2724
count && GLctx . uniform4fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2736
2725
#else
2737
2726
2738
- #if MAX_WEBGL_VERSION >= 2
2739
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2740
- // those always when possible.
2727
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2741
2728
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2742
2729
count && GLctx . uniform4fv ( webglGetUniformLocation ( location ) , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2743
2730
return ;
@@ -2785,9 +2772,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2785
2772
count && GLctx . uniformMatrix2fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2786
2773
#else
2787
2774
2788
- #if MAX_WEBGL_VERSION >= 2
2789
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2790
- // those always when possible.
2775
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2791
2776
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2792
2777
count && GLctx . uniformMatrix2fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 4 ) ;
2793
2778
return ;
@@ -2831,9 +2816,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2831
2816
count && GLctx . uniformMatrix3fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 9 ) ;
2832
2817
#else
2833
2818
2834
- #if MAX_WEBGL_VERSION >= 2
2835
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2836
- // those always when possible.
2819
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2837
2820
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2838
2821
count && GLctx . uniformMatrix3fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 9 ) ;
2839
2822
return ;
@@ -2882,9 +2865,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
2882
2865
count && GLctx . uniformMatrix4fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 16 ) ;
2883
2866
#else
2884
2867
2885
- #if MAX_WEBGL_VERSION >= 2
2886
- // WebGL 2 provides new garbage-free entry points to call to WebGL. Use
2887
- // those always when possible.
2868
+ #if WEBGL_USE_GARBAGE_FREE_APIS
2888
2869
if ( { { { isCurrentContextWebGL2( ) } } } ) {
2889
2870
count && GLctx . uniformMatrix4fv ( webglGetUniformLocation ( location ) , ! ! transpose , HEAPF32 , { { { getHeapOffset ( 'value' , 'float' ) } } } , count * 16 ) ;
2890
2871
return ;
@@ -4158,12 +4139,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
4158
4139
return 0 ;
4159
4140
}
4160
4141
4161
- if ( ! ( mapping . access & 0x10 ) ) /* GL_MAP_FLUSH_EXPLICIT_BIT */
4162
- if ( { { { isCurrentContextWebGL2( ) } } } ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
4142
+ if ( ! ( mapping . access & 0x10 ) ) { /* GL_MAP_FLUSH_EXPLICIT_BIT */
4143
+ #if WEBGL_USE_GARBAGE_FREE_APIS
4144
+ if ( { { { isCurrentContextWebGL2( ) } } } ) {
4163
4145
GLctx . bufferSubData ( target , mapping . offset , HEAPU8 , mapping . mem , mapping . length ) ;
4164
- } else {
4165
- GLctx . bufferSubData( target , mapping. offset , HEAPU8 . subarray ( mapping . mem, mapping. mem + mapping . length ) ) ;
4166
- }
4146
+ } else
4147
+ #endif
4148
+ GLctx . bufferSubData ( target , mapping . offset , HEAPU8 . subarray ( mapping . mem , mapping . mem + mapping . length ) ) ;
4149
+ }
4167
4150
_free ( mapping . mem ) ;
4168
4151
mapping . mem = 0 ;
4169
4152
return 1 ;
0 commit comments