-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathemscripten.patch
38 lines (36 loc) · 1.48 KB
/
emscripten.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- upstream/emscripten/src/library_webgl.js 2021-03-05 12:32:24.000000000 -0800
+++ upstream/emscripten/src/library_webgl.js 2022-05-02 10:19:02.461667100 -0700
@@ -3486,6 +3486,7 @@
glDrawElements: function(mode, count, type, indices) {
#if FULL_ES2
var buf;
+ var vertices = 0;
if (!GLctx.currentElementArrayBufferBinding) {
var size = GL.calcBufLength(1, type, 0, count);
buf = GL.getTempIndexBuffer(size);
@@ -3493,12 +3494,26 @@
GLctx.bufferSubData(0x8893 /*GL_ELEMENT_ARRAY_BUFFER*/,
0,
HEAPU8.subarray(indices, indices + size));
+
+ // Detecting vertex count if attributes' data should be loaded
+ var array_classes = {
+ '5121' /* GL_UNSIGNED_BYTE */: Uint8Array,
+ '5123' /* GL_UNSIGNED_SHORT */: Uint16Array,
+ '5125' /* GL_UNSIGNED_INT */: Uint32Array};
+ for (var i = 0; i < GL.currentContext.maxVertexAttribs; i++) {
+ var cb = GL.currentContext.clientBuffers[i];
+ if (cb.clientside && cb.enabled && array_classes[type]) {
+ vertices = Math.max.apply(null, new array_classes[type](HEAPU8.buffer, indices, count)) + 1;
+ break;
+ }
+ }
+
// the index is now 0
indices = 0;
}
// bind any client-side buffers
- GL.preDrawHandleClientVertexAttribBindings(count);
+ GL.preDrawHandleClientVertexAttribBindings(vertices);
#endif
GLctx.drawElements(mode, count, type, indices);