Skip to content

Commit fbf4387

Browse files
author
marco trivellato
committed
Revert "Optimize away temporary garbage created in WebGL 2 glInvalidateFramebuffer() and glInvalidateSubFramebuffer() functions."
This reverts commit 2bc6946.
1 parent 622d964 commit fbf4387

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

src/library_gl.js

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ var LibraryGL = {
6262
stringCache: {},
6363
#if USE_WEBGL2
6464
stringiCache: {},
65-
tempFixedLengthArray: [],
6665
#endif
6766

6867
packAlignment: 4, // default alignment is 4 bytes
@@ -76,14 +75,6 @@ var LibraryGL = {
7675
for (var i = 0; i < GL.MINI_TEMP_BUFFER_SIZE; i++) {
7776
GL.miniTempBufferViews[i] = GL.miniTempBuffer.subarray(0, i+1);
7877
}
79-
80-
#if USE_WEBGL2
81-
// For glInvalidateFramebuffer and glInvalidateSubFramebuffer, create a set of short fixed-length arrays to avoid
82-
// having to generate any garbage in those functions.
83-
for (var i = 0; i < 32; i++) {
84-
GL.tempFixedLengthArray.push(new Array(i).fill(0));
85-
}
86-
#endif
8778
},
8879

8980
// Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error
@@ -1686,26 +1677,18 @@ var LibraryGL = {
16861677
#if USE_WEBGL2
16871678
glInvalidateFramebuffer__sig: 'viii',
16881679
glInvalidateFramebuffer: function(target, numAttachments, attachments) {
1689-
#if GL_ASSERTIONS
1690-
assert(numAttachments < GL.tempFixedLengthArray.length, 'Invalid count of numAttachments=' + numAttachments + ' passed to glInvalidateFramebuffer (that many attachment points do not exist in GL)';
1691-
#endif
1692-
var list = GL.tempFixedLengthArray[numAttachments];
1693-
for (var i = 0; i < numAttachments; i++) {
1694-
list[i] = {{{ makeGetValue('attachments', 'i*4', 'i32') }}};
1695-
}
1680+
var list = [];
1681+
for (var i = 0; i < numAttachments; i++)
1682+
list.push({{{ makeGetValue('attachments', 'i*4', 'i32') }}});
16961683

16971684
GLctx['invalidateFramebuffer'](target, list);
16981685
},
16991686

17001687
glInvalidateSubFramebuffer__sig: 'viiiiiii',
17011688
glInvalidateSubFramebuffer: function(target, numAttachments, attachments, x, y, width, height) {
1702-
#if GL_ASSERTIONS
1703-
assert(numAttachments < GL.tempFixedLengthArray.length, 'Invalid count of numAttachments=' + numAttachments + ' passed to glInvalidateSubFramebuffer (that many attachment points do not exist in GL)';
1704-
#endif
1705-
var list = GL.tempFixedLengthArray[numAttachments];
1706-
for (var i = 0; i < numAttachments; i++) {
1707-
list[i] = {{{ makeGetValue('attachments', 'i*4', 'i32') }}};
1708-
}
1689+
var list = [];
1690+
for (var i = 0; i < numAttachments; i++)
1691+
list.push({{{ makeGetValue('attachments', 'i*4', 'i32') }}});
17091692

17101693
GLctx['invalidateSubFramebuffer'](target, list, x, y, width, height);
17111694
},

0 commit comments

Comments
 (0)