Skip to content

Conversation

@juj
Copy link
Collaborator

@juj juj commented Jan 27, 2017

Optimize away temporary garbage created in WebGL 2 glInvalidateFramebuffer() and glInvalidateSubFramebuffer() functions.

#if USE_WEBGL2
// For glInvalidateFramebuffer and glInvalidateSubFramebuffer, create a set of short fixed-length arrays to avoid
// having to generate any garbage in those functions.
GL.tempFixedLengthArray = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to declare this on the object, tempFixedLengthArray: [], , that way it isn't a new property at this time, better for JS optimizations.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with those minor comments

for (var i = 0; i < numAttachments; i++)
list.push({{{ makeGetValue('attachments', 'i*4', 'i32') }}});
#if GL_ASSERTIONS
assert(numAttachments < GL.tempFixedLengthArray.length, 'Invalid count of numAttachments='+numAttachments+' passed to glInvalidateFramebuffer (that many attachment points do not exist in GL)';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces before and after +

for (var i = 0; i < numAttachments; i++)
list.push({{{ makeGetValue('attachments', 'i*4', 'i32') }}});
#if GL_ASSERTIONS
assert(numAttachments < GL.tempFixedLengthArray.length, 'Invalid count of numAttachments='+numAttachments+' passed to glInvalidateSubFramebuffer (that many attachment points do not exist in GL)';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

…uffer() and glInvalidateSubFramebuffer() functions.
@juj juj force-pushed the no_garbage_in_glinvalidateframebuffer branch from 863a074 to 2bc6946 Compare January 27, 2017 15:06
@juj
Copy link
Collaborator Author

juj commented Jan 28, 2017

Addressed comments and tested out in real world codebase, which shows we're garbage clean here now.

@juj juj merged commit e16dfd0 into emscripten-core:incoming Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants