@@ -1236,120 +1236,25 @@ var LibraryGL = {
12361236 }
12371237 } ,
12381238
1239- #if USE_WEBGL2
1240- $emscriptenWebGLGetHeapForType: function ( type ) {
1241- switch ( type ) {
1242- case 0x1400 /* GL_BYTE */ :
1243- return HEAP8 ;
1244- case 0x1401 /* GL_UNSIGNED_BYTE */ :
1245- return HEAPU8 ;
1246- case 0x1402 /* GL_SHORT */ :
1247- return HEAP16 ;
1248- case 0x1403 /* GL_UNSIGNED_SHORT */ :
1249- case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */ :
1250- case 0x8033 /* GL_UNSIGNED_SHORT_4_4_4_4 */ :
1251- case 0x8034 /* GL_UNSIGNED_SHORT_5_5_5_1 */ :
1252- case 0x8D61 /* GL_HALF_FLOAT_OES */ :
1253- case 0x140B /* GL_HALF_FLOAT */ :
1254- return HEAPU16 ;
1255- case 0x1404 /* GL_INT */ :
1256- return HEAP32 ;
1257- case 0x1405 /* GL_UNSIGNED_INT */ :
1258- case 0x84FA /* GL_UNSIGNED_INT_24_8_WEBGL/GL_UNSIGNED_INT_24_8 */ :
1259- case 0x8C3E /* GL_UNSIGNED_INT_5_9_9_9_REV */ :
1260- case 0x8368 /* GL_UNSIGNED_INT_2_10_10_10_REV */ :
1261- case 0x8C3B /* GL_UNSIGNED_INT_10F_11F_11F_REV */ :
1262- case 0x84FA /* GL_UNSIGNED_INT_24_8 */ :
1263- return HEAPU32 ;
1264- case 0x1406 /* GL_FLOAT */ :
1265- return HEAPF32 ;
1266- default :
1267- return null ;
1268- }
1269- } ,
1270-
1271- $emscriptenWebGLGetShiftForType : function ( type ) {
1272- switch ( type ) {
1273- case 0x1400 /* GL_BYTE */ :
1274- case 0x1401 /* GL_UNSIGNED_BYTE */ :
1275- return 0 ;
1276- case 0x1402 /* GL_SHORT */ :
1277- case 0x1403 /* GL_UNSIGNED_SHORT */ :
1278- case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */ :
1279- case 0x8033 /* GL_UNSIGNED_SHORT_4_4_4_4 */ :
1280- case 0x8034 /* GL_UNSIGNED_SHORT_5_5_5_1 */ :
1281- case 0x8D61 /* GL_HALF_FLOAT_OES */ :
1282- case 0x140B /* GL_HALF_FLOAT */ :
1283- return 1 ;
1284- case 0x1404 /* GL_INT */ :
1285- case 0x1406 /* GL_FLOAT */ :
1286- case 0x1405 /* GL_UNSIGNED_INT */ :
1287- case 0x84FA /* GL_UNSIGNED_INT_24_8_WEBGL/GL_UNSIGNED_INT_24_8 */ :
1288- case 0x8C3E /* GL_UNSIGNED_INT_5_9_9_9_REV */ :
1289- case 0x8368 /* GL_UNSIGNED_INT_2_10_10_10_REV */ :
1290- case 0x8C3B /* GL_UNSIGNED_INT_10F_11F_11F_REV */ :
1291- case 0x84FA /* GL_UNSIGNED_INT_24_8 */ :
1292- return 2 ;
1293- default :
1294- return 0 ;
1295- }
1296- } ,
1297- #endif
1298-
12991239 glTexImage2D__sig: 'viiiiiiiii' ,
1300- glTexImage2D__deps : [ '$emscriptenWebGLGetTexPixelData' , '$emscriptenWebGLGetHeapForType' , '$emscriptenWebGLGetShiftForType' ] ,
1240+ glTexImage2D__deps : [ '$emscriptenWebGLGetTexPixelData' ] ,
13011241 glTexImage2D : function ( target , level , internalFormat , width , height , border , format , type , pixels ) {
1302- #if USE_WEBGL2
1303- if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1304- if ( GLctx . currentPixelUnpackBufferBinding ) {
1305- GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ) ;
1306- } else if ( pixels != 0 ) {
1307- GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , emscriptenWebGLGetHeapForType ( type ) , pixels >> emscriptenWebGLGetShiftForType ( type ) ) ;
1308- } else {
1309- GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , null ) ;
1310- }
1311- return ;
1312- }
1313- #endif
1314-
13151242 var pixelData = null ;
13161243 if ( pixels ) pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , internalFormat ) ;
13171244 GLctx . texImage2D ( target , level , internalFormat , width , height , border , format , type , pixelData ) ;
13181245 } ,
13191246
13201247 glTexSubImage2D__sig : 'viiiiiiiii' ,
1321- glTexSubImage2D__deps : [ '$emscriptenWebGLGetTexPixelData' , '$emscriptenWebGLGetHeapForType' , '$emscriptenWebGLGetShiftForType' ] ,
1248+ glTexSubImage2D__deps : [ '$emscriptenWebGLGetTexPixelData' ] ,
13221249 glTexSubImage2D : function ( target , level , xoffset , yoffset , width , height , format , type , pixels ) {
1323- #if USE_WEBGL2
1324- if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1325- if ( GLctx . currentPixelUnpackBufferBinding ) {
1326- GLctx . texSubImage2D ( target , level , internalFormat , width , height , border , format , type , pixels ) ;
1327- } else if ( pixels != 0 ) {
1328- GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , emscriptenWebGLGetHeapForType ( type ) , pixels >> emscriptenWebGLGetShiftForType ( type ) ) ;
1329- } else {
1330- GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , null ) ;
1331- }
1332- return ;
1333- }
1334- #endif
13351250 var pixelData = null ;
13361251 if ( pixels ) pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , 0 ) ;
13371252 GLctx . texSubImage2D ( target , level , xoffset , yoffset , width , height , format , type , pixelData ) ;
13381253 } ,
13391254
13401255 glReadPixels__sig : 'viiiiiii' ,
1341- glReadPixels__deps : [ '$emscriptenWebGLGetTexPixelData' , '$emscriptenWebGLGetHeapForType' , '$emscriptenWebGLGetShiftForType' ] ,
1256+ glReadPixels__deps : [ '$emscriptenWebGLGetTexPixelData' ] ,
13421257 glReadPixels : function ( x , y , width , height , format , type , pixels ) {
1343- #if USE_WEBGL2
1344- if ( GL . currentContext . version >= 2 ) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
1345- if ( GLctx . currentPixelPackBufferBinding ) {
1346- GLctx . readPixels ( x , y , width , height , format , type , pixels ) ;
1347- } else {
1348- GLctx . readPixels ( x , y , width , height , format , type , emscriptenWebGLGetHeapForType ( type ) , pixels >> emscriptenWebGLGetShiftForType ( type ) ) ;
1349- }
1350- return ;
1351- }
1352- #endif
13531258 var pixelData = emscriptenWebGLGetTexPixelData ( type , format , width , height , pixels , format ) ;
13541259 if ( ! pixelData ) {
13551260 GL . recordError ( 0x0500 /*GL_INVALID_ENUM*/ ) ;
@@ -1806,27 +1711,15 @@ var LibraryGL = {
18061711 } ,
18071712
18081713 glTexImage3D__sig: 'viiiiiiiiii' ,
1809- glTexImage3D__deps : [ '$emscriptenWebGLGetTexPixelData' , '$emscriptenWebGLGetHeapForType' , '$emscriptenWebGLGetShiftForType' ] ,
1810- glTexImage3D : function ( target , level , internalFormat , width , height , depth , border , format , type , pixels ) {
1811- if ( GLctx . currentPixelUnpackBufferBinding ) {
1812- GLctx [ 'texImage3D' ] ( target , level , internalFormat , width , height , depth , border , format , type , pixels ) ;
1813- } else if ( pixels != 0 ) {
1814- GLctx [ 'texImage3D' ] ( target , level , internalFormat , width , height , depth , border , format , type , emscriptenWebGLGetHeapForType ( type ) , pixels >> emscriptenWebGLGetShiftForType ( type ) ) ;
1815- } else {
1816- GLctx [ 'texImage3D' ] ( target , level , internalFormat , width , height , depth , border , format , type , null ) ;
1817- }
1714+ glTexImage3D : function ( target , level , internalFormat , width , height , depth , border , format , type , data ) {
1715+ GLctx [ 'texImage3D' ] ( target , level , internalFormat , width , height , depth , border , format , type ,
1716+ HEAPU8 . subarray ( data ) ) ;
18181717 } ,
18191718
18201719 glTexSubImage3D__sig : 'viiiiiiiiiii' ,
1821- glTexSubImage3D__deps : [ '$emscriptenWebGLGetTexPixelData' , '$emscriptenWebGLGetHeapForType' , '$emscriptenWebGLGetShiftForType' ] ,
1822- glTexSubImage3D : function ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type , pixels ) {
1823- if ( GLctx . currentPixelUnpackBufferBinding ) {
1824- GLctx [ 'texSubImage3D' ] ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type , pixels ) ;
1825- } else if ( pixels != 0 ) {
1826- GLctx [ 'texSubImage3D' ] ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type , emscriptenWebGLGetHeapForType ( type ) , pixels >> emscriptenWebGLGetShiftForType ( type ) ) ;
1827- } else {
1828- GLctx [ 'texSubImage3D' ] ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type , null ) ;
1829- }
1720+ glTexSubImage3D : function ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type , data ) {
1721+ GLctx [ 'texSubImage3D' ] ( target , level , xoffset , yoffset , zoffset , width , height , depth , format , type ,
1722+ HEAPU8 . subarray ( data ) ) ;
18301723 } ,
18311724
18321725 // Queries
@@ -3240,19 +3133,6 @@ var LibraryGL = {
32403133 }
32413134#endif
32423135
3243- #if USE_WEBGL2
3244- if ( target == 0x88EB /*GL_PIXEL_PACK_BUFFER*/ ) {
3245- // In WebGL 2 glReadPixels entry point, we need to use a different WebGL 2 API function call when a buffer is bound to
3246- // GL_PIXEL_PACK_BUFFER_BINDING point, so must keep track whether that binding point is non-null to know what is
3247- // the proper API function to call.
3248- GLctx . currentPixelPackBufferBinding = buffer ;
3249- } else if ( target == 0x88EC /*GL_PIXEL_UNPACK_BUFFER*/ ) {
3250- // In WebGL 2 glTexImage2D, glTexSubImage2D, glTexImage3D and glTexSubImage3D entry points, we need to use a different WebGL 2 API function
3251- // call when a buffer is bound to GL_PIXEL_UNPACK_BUFFER_BINDING point, so must keep track whether that binding point is non-null to know what
3252- // is the proper API function to call.
3253- GLctx . currentPixelUnpackBufferBinding = buffer ;
3254- }
3255- #endif
32563136 GLctx . bindBuffer ( target , bufferObj ) ;
32573137 } ,
32583138
0 commit comments