-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathemscripten.patch
45 lines (43 loc) · 1.95 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
39
40
41
42
43
44
45
--- upstream/emscripten/src/library_webgl.js 2023-12-23 00:07:24.746592847 -0600
+++ upstream/emscripten/src/library_webgl.js 2023-12-23 00:06:51.298796601 -0600
@@ -3907,6 +3907,7 @@
glDrawElements: (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);
@@ -3914,12 +3915,25 @@
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);
@@ -4163,7 +4177,7 @@
glMapBufferRange__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget', 'malloc'],
glMapBufferRange: (target, offset, length, access) => {
if ((access & (0x1/*GL_MAP_READ_BIT*/ | 0x20/*GL_MAP_UNSYNCHRONIZED_BIT*/)) != 0) {
- err("glMapBufferRange access does not support MAP_READ or MAP_UNSYNCHRONIZED");
+ warnOnce("glMapBufferRange access does not support MAP_READ or MAP_UNSYNCHRONIZED");
return 0;
}