-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor shader source classes, in order to work around a Firefox bug. #2214
Conversation
The Firefox bug prevents shaders from compiling with the CORDIC algorithm, so we detect Firefox and fall back to the original algorithm. Issue #2197. The overall goal of the refactoring is to allow `#defines` to affect built-in functions, which was not possible before. In order to do this, we need the `#defines` to appear at the top of the source, so I've merged the procedural shader generation previously done in `ShaderProgram` with the generation done in `createShaderSource`. * `createShaderSource` (private) is removed and replaced by `ShaderSource`. `ShaderSource` now manages an array of `#defines`, concating source shaders, and automatically including built-in functions, keeping everything in the correct order. * `ShaderCache` (and by extension `Context.createShaderProgram` and `Context.replaceShaderProgram`) now accept either `ShaderSource` objects, or a single string, for vertex and fragment shaders. * `ShaderProgram` constructor (private) now takes an options object. It also exposes the vertex and fragment shaders as `ShaderSource` objects instead of strings. External code can still clone the `ShaderSources` and then screw around with the implementation to make new shaders procedurally, as `OIT` does.
* @param {Boolean} isFragmentShader True if this shader will be a fragment shader. | ||
* @returns {String} The combined shader string. | ||
*/ | ||
ShaderSource.prototype.getCombinedShader = function(isFragmentShader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit hacky, right? I had no idea what this parameter did when I looked at code calling this function. Why not two separate functions: one for vertex shaders and another for fragment shaders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I split into two functions.
Thanks @shunter. Just those comments. FF 33 on Windows looks good. There's a few test failures (below) but I would not worry given this version of ANGLE.
|
OK |
I think I've addressed your comments. I merged in master as well. I believe the remaining Firefox test failures are all long-standing issues. |
Very nice, thanks. Can you update CHANGES.md for the FF fix in master and reply to the forum? https://groups.google.com/forum/#!msg/cesium-dev/-NRjGK1rcdU/ozcB3Ux5CJgJ |
…Crash Refactor shader source classes, in order to work around a Firefox bug.
The Firefox bug prevents shaders from compiling with the CORDIC algorithm, so we detect Firefox and fall back to the original algorithm. Issue #2197.
The overall goal of the refactoring is to allow
#defines
to affect built-in functions, which was not possible before. In order to do this, we need the#defines
to appear at the top of the source, so I've merged the procedural shader generation previously done inShaderProgram
with the generation done increateShaderSource
.createShaderSource
(private) is removed and replaced byShaderSource
.ShaderSource
now manages an array of#defines
, concating source shaders, and automatically including built-in functions, keeping everything in the correct order.ShaderCache
(and by extensionContext.createShaderProgram
andContext.replaceShaderProgram
) now accept eitherShaderSource
objects, or a single string, for vertex and fragment shaders.ShaderProgram
constructor (private) now takes an options object. It also exposes the vertex and fragment shaders asShaderSource
objects instead of strings. External code can still clone theShaderSources
and then screw around with the implementation to make new shaders procedurally, asOIT
does.