|
14 | 14 | assert(MAX_WEBGL_VERSION >= 2, 'isCurrentContextWebGL2 called without webgl2 support');
|
15 | 15 | if (MIN_WEBGL_VERSION >= 2) return 'true';
|
16 | 16 | return 'GL.currentContext.version >= 2';
|
17 |
| - } |
| 17 | + }; |
18 | 18 | null;
|
19 | 19 | }}}
|
20 | 20 |
|
@@ -1677,14 +1677,11 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
|
1677 | 1677 | } else if (pixels) {
|
1678 | 1678 | var heap = heapObjectForWebGLType(type);
|
1679 | 1679 | GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, heap, toTypedArrayIndex(pixels, heap));
|
1680 |
| - } else { |
1681 |
| - GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, null); |
| 1680 | + return; |
1682 | 1681 | }
|
1683 |
| - return; |
1684 | 1682 | }
|
1685 | 1683 | #endif
|
1686 |
| - var pixelData = null; |
1687 |
| - if (pixels) pixelData = emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, 0); |
| 1684 | + var pixelData = pixels ? emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, 0) : null; |
1688 | 1685 | GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixelData);
|
1689 | 1686 | },
|
1690 | 1687 |
|
@@ -1855,16 +1852,14 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
|
1855 | 1852 | } else {
|
1856 | 1853 | GLctx.bufferData(target, size, usage);
|
1857 | 1854 | }
|
1858 |
| - } else { |
1859 |
| -#endif |
1860 |
| - // N.b. here first form specifies a heap subarray, second form an integer |
1861 |
| - // size, so the ?: code here is polymorphic. It is advised to avoid |
1862 |
| - // randomly mixing both uses in calling code, to avoid any potential JS |
1863 |
| - // engine JIT issues. |
1864 |
| - GLctx.bufferData(target, data ? HEAPU8.subarray(data, data+size) : size, usage); |
1865 |
| -#if MAX_WEBGL_VERSION >= 2 |
| 1855 | + return; |
1866 | 1856 | }
|
1867 | 1857 | #endif
|
| 1858 | + // N.b. here first form specifies a heap subarray, second form an integer |
| 1859 | + // size, so the ?: code here is polymorphic. It is advised to avoid |
| 1860 | + // randomly mixing both uses in calling code, to avoid any potential JS |
| 1861 | + // engine JIT issues. |
| 1862 | + GLctx.bufferData(target, data ? HEAPU8.subarray(data, data+size) : size, usage); |
1868 | 1863 | },
|
1869 | 1864 |
|
1870 | 1865 | glBufferSubData: (target, offset, size, data) => {
|
@@ -3813,8 +3808,8 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
|
3813 | 3808 | buf = GL.getTempIndexBuffer(size);
|
3814 | 3809 | GLctx.bindBuffer(0x8893 /*GL_ELEMENT_ARRAY_BUFFER*/, buf);
|
3815 | 3810 | GLctx.bufferSubData(0x8893 /*GL_ELEMENT_ARRAY_BUFFER*/,
|
3816 |
| - 0, |
3817 |
| - HEAPU8.subarray(indices, indices + size)); |
| 3811 | + 0, |
| 3812 | + HEAPU8.subarray(indices, indices + size)); |
3818 | 3813 | // the index is now 0
|
3819 | 3814 | indices = 0;
|
3820 | 3815 | }
|
@@ -4159,12 +4154,13 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
|
4159 | 4154 | return 0;
|
4160 | 4155 | }
|
4161 | 4156 |
|
4162 |
| - if (!(mapping.access & 0x10)) /* GL_MAP_FLUSH_EXPLICIT_BIT */ |
| 4157 | + if (!(mapping.access & 0x10)) { /* GL_MAP_FLUSH_EXPLICIT_BIT */ |
4163 | 4158 | if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible.
|
4164 | 4159 | GLctx.bufferSubData(target, mapping.offset, HEAPU8, mapping.mem, mapping.length);
|
4165 | 4160 | } else {
|
4166 | 4161 | GLctx.bufferSubData(target, mapping.offset, HEAPU8.subarray(mapping.mem, mapping.mem+mapping.length));
|
4167 | 4162 | }
|
| 4163 | + } |
4168 | 4164 | _free(mapping.mem);
|
4169 | 4165 | mapping.mem = 0;
|
4170 | 4166 | return 1;
|
|
0 commit comments