Path: blob/main/public/webretro/source/patches/emscripten.patch
1224 views
--- upstream/emscripten/src/library_webgl.js 2021-03-05 12:32:24.000000000 -08001+++ upstream/emscripten/src/library_webgl.js 2022-05-02 10:19:02.461667100 -07002@@ -3486,6 +3486,7 @@3glDrawElements: function(mode, count, type, indices) {4#if FULL_ES25var buf;6+ var vertices = 0;7if (!GLctx.currentElementArrayBufferBinding) {8var size = GL.calcBufLength(1, type, 0, count);9buf = GL.getTempIndexBuffer(size);10@@ -3493,12 +3494,26 @@11GLctx.bufferSubData(0x8893 /*GL_ELEMENT_ARRAY_BUFFER*/,120,13HEAPU8.subarray(indices, indices + size));14+15+ // Detecting vertex count if attributes' data should be loaded16+ var array_classes = {17+ '5121' /* GL_UNSIGNED_BYTE */: Uint8Array,18+ '5123' /* GL_UNSIGNED_SHORT */: Uint16Array,19+ '5125' /* GL_UNSIGNED_INT */: Uint32Array};20+ for (var i = 0; i < GL.currentContext.maxVertexAttribs; i++) {21+ var cb = GL.currentContext.clientBuffers[i];22+ if (cb.clientside && cb.enabled && array_classes[type]) {23+ vertices = Math.max.apply(null, new array_classes[type](HEAPU8.buffer, indices, count)) + 1;24+ break;25+ }26+ }27+28// the index is now 029indices = 0;30}3132// bind any client-side buffers33- GL.preDrawHandleClientVertexAttribBindings(count);34+ GL.preDrawHandleClientVertexAttribBindings(vertices);35#endif3637GLctx.drawElements(mode, count, type, indices);38@@ -3716,7 +3731,7 @@39glMapBufferRange__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget'],40glMapBufferRange: function(target, offset, length, access) {41if (access != 0x1A && access != 0xA) {42- err("glMapBufferRange is only supported when access is MAP_WRITE|INVALIDATE_BUFFER");43+ warnOnce("glMapBufferRange is only supported when access is MAP_WRITE|INVALIDATE_BUFFER");44return 0;45}46474849