Repository navigation
Conversation
| ' }' + | ||
| '}' | ||
| ); | ||
|
|
There was a problem hiding this comment.
Can this be moved to a separate .glsl file?
|
Looks great At first I was a bit skeptical about using pragmas. They add an extra layer of abstraction and make you read a bunch of extra files to understand what's actually going on in the shaders. It does make it a lot cleaner and reduces a ton of ugly repetition though. I think it's worth it! Besides the couple of things I commented on in the diff this looks ready |
|
Should we build on glslify explicitly for the shader rewriting functionality? |
|
As best I can tell, glslify does not provide any functionality that affects this feature. glslify's API allows us to import and export functions from other glsl files but not inject definitions at compile time. glsl also has a system for source transforms but we don't seem to gain anything by using that vs replacing the pragmas ourselves. |
b8be27b to
0c5fd69
Compare
|
I managed to find a somewhat elegant design for parameterized pragmas, leveraging Javascript's As of this commit, a pragma defined as {
'define mapbox': 'attribute $1 float a_mapbox;'
}Will replace a pragma written as #pragma mapbox: define mapbox highpWith this code attribute highp float a_mapbox; |
| defines += '#define ' + macros[m] + '\n'; | ||
| } | ||
| var definesSource = ''; | ||
| for (var j = 0; definesSource && j < definesSource.length; j++) { |
There was a problem hiding this comment.
definesSource && j < definesSource.length is always false, because definesSource is an empty string. Is this intended?
There was a problem hiding this comment.
The line should read defines && j < defines.length. Unfortunately, this codepath is only used by the overdraw inspector, which is not tested. I'll push a fix shortly.
* Rename macros to defines * Rename addPaintAttributes to populatePaintArrays * Add support for pragmas in useProgram * Replace shader boilerplate with pragmas * Inject shader functions at compiletime * Move shader utility functions into a glsl file * Support arguments in shader pragmas, remove precision from bucket definition
Refactoring
This pull request contains some vocabulary refactoring within bucket, aiming for conceptual correctness. For example, the
paintAttributesarray contained much more data than just attributes.Pragma Statements
This pull request allows us to expand property function styling support while keeping our codebase DRY and readable. It adds
#pragmastatements to the shaders which generate definition and initialization boilerplate.Before
After
cc @jfirebaugh @mourner @ansis