Skip to content

Webgl2 part 2#3782

Merged
juj merged 16 commits intoemscripten-core:incomingfrom
juj:webgl2_part_2
Oct 2, 2015
Merged

Webgl2 part 2#3782
juj merged 16 commits intoemscripten-core:incomingfrom
juj:webgl2_part_2

Conversation

@juj
Copy link
Collaborator

@juj juj commented Sep 16, 2015

Not yet to merge, just marking this down. This shows currently all WebGL2_part_1 commits as well, I'll refresh this once #3757 is merged.

@juj juj added the GL label Sep 16, 2015
@juj juj force-pushed the webgl2_part_2 branch 2 times, most recently from 119faca to c260605 Compare September 30, 2015 04:35
@juj
Copy link
Collaborator Author

juj commented Sep 30, 2015

Refreshed this pull request after the #3757 is now merged. @kripken: how does this look?

Copy link
Member

Choose a reason for hiding this comment

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

Why not use a method on GL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to move away the methods on GL, because they are not subject to dead code elimination. I'll have a followup to this pull request that moves more functions away from GL, especially those getters that might not necessarily even be called by some applications. That feels much cleaner to me since it straightforwardly uses the __deps architecture. The PR #3298 is similar in the idea (which still needs to be resolved somehow, but I don't yet know what would be the best way)

Copy link
Member

Choose a reason for hiding this comment

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

I feel it would be cleaner to do it with entire objects, like a GL2 object with WebGL2 stuff, or if that isn't specific enough, then some sub-objects.

If even that isn't enough, individual methods are ok, but in that case it might be nicer to have them not begin with underscores, since we use that for compiled code (and js library code implementing a C interface).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the underscore so that it gets expanded to a double underscore and a lowercase letter, i.e. __w..., because that conforms to the set of names reserved to the implementation in ISO C. See http://crasseux.com/books/ctutorial/Reserved-words-in-C.html :

"all identifiers regardless of use that begin with either two underscores or an underscore followed by a capital letter are reserved names. This is so that the library and header files can define functions, variables, and macros for internal purposes without risk of conflict with names in user programs."

Even though objects would be cleaner in some sense, I don't think they are technically as good, since it is quite easy to add these functions as global functions to get the __deps benefits. I think we should favor that whenever sensible. I recall you mentioned that closure would be able to DCE inside the objects, but since very few projects use closure and it's not favored any more for general use, we should not assume that. I am not looking to nuke the whole GL object, but just those getter functions that might not be needed by some programs. It does not feel like a big loss in cleanliness, but it can shave off a considerable number of lines practically for free?

Copy link
Member

Choose a reason for hiding this comment

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

I feel like the ISO C standard is not what we want here, since these aren't C methods, nor even JS methods implementing C methods. It's just a normal JS method, so

function webGLValidateMapBufferTarget(arg) {
  ..
}

is the most JavaScript-ey.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea ws to cater for C code that is being compiled. If user code happened to have a global function void webGLValidateMapBufferTarget(), that would get mangled to _webGLValidateMapBufferTarget and conflict with the JS side function. That's why I added the extra underscore. But sure, I can rename this, but then perhaps use emscriptenWebGLValidateMapBufferTarget or similar?

Copy link
Member

Choose a reason for hiding this comment

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

I don't follow, why would it conflict if this method has no underscore, and the user code has a global function with that name, which would end up with an underscore? Not having an underscore is protection against such collisions?

Yes, emscripten prefix sounds good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, updated the pull request to use emscripten prefix instead of underscore _. How does that look?

…by bound target, when it needs to be tracked by object name instead. Move GL.validateBufferTarget inside FULL_ES3 for dead code elimination.
@kripken
Copy link
Member

kripken commented Oct 2, 2015

Thanks, lgtm.

juj added a commit that referenced this pull request Oct 2, 2015
@juj juj merged commit 12c3158 into emscripten-core:incoming Oct 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants