Skip to content
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

New shader enhancements #1102

Merged
merged 31 commits into from
Sep 5, 2013
Merged

Conversation

gbeatty
Copy link
Contributor

@gbeatty gbeatty commented Aug 30, 2013

Extracted glsl constants, structs, and functions into individual glsl files.
Build now builds constants.js structs.js and functions.js for use in ShaderProgram.js.
ShaderProgram.js builds a dependency graph for all functions used in the shader being compiled and determines the order the functions need to be defined in.
Only functions, structs, constants that are referenced are included in the final shader.

@gbeatty
Copy link
Contributor Author

gbeatty commented Aug 30, 2013

@pjcozzi Looks like I had a rebase issue somewhere in here. One of your changes got in here somehow. Is this a problem?

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

JSHint is failing. It is run automatically when we push to a branch. See https://travis-ci.org/AnalyticalGraphicsInc/cesium/builds/10815857

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

@pjcozzi Looks like I had a rebase issue somewhere in here. One of your changes got in here somehow. Is this a problem?

Generally we like to clean these up. In this case, it is trivial enough that I don't think it is a problem. However 4762e8c isn't even my commit IIRC. If @shunter has an easy solution, we'll do it.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

@fstoner this may break your new code or at the least, we will want to update some of your code to use this new system. @gbeatty can help you. We'll need to determine what goes into the built-ins and what is in the sensor library. I imagine it will be straightforward as we've done it in the past.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

@gbeatty it would be fun to see if this affects compile/link times. We can fine-grained test the compile/link code, but we should also test the entire ShaderProgram constructor to be fair. What's your gut? Faster on mobile, but it won't matter on desktop?

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

Update CHANGES.md. If the time differences are insignificant, we can just say something like "Improved runtime generation of GLSL shaders."

UniformDatatype) {

"use strict";
/*global console*/
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this in this file.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

Why did we rename all the GLSL files to have a czm_ prefix? It creates extra noise when browsing and sorting them. I intentionally didn't include it when I first started this.

}

function generateDependencies(currentNode, dependencyNodes, shaderBuiltinDictionary) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I have a bunch of whitespace comments coming. We like to keep the Cesium code consistent.

Remove whitespace here.

@pjcozzi
Copy link
Contributor

pjcozzi commented Aug 31, 2013

Can you introduce new built-in getLambertDiffuse and getSpecular GLSL functions (with czm_ prefixes, of course). In #1053, I duplicated them in CentralBodyFS.glsl and phong.glsl since we didn't have support for dependencies.

@@ -34,10 +36,36 @@ defineSuite([

beforeAll(function() {
context = createContext();

CzmBuiltins.czm_circularDependency1 = 'void czm_circularDependency1() { czm_circularDependency2(); }';
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's indirectly tested elsewhere, but we should have a test here that includes comments.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 3, 2013

Debug and release look pretty good. I think we are close. Make sure to update CHANGES.md with your next round. Let me know when it is ready.

@gbeatty
Copy link
Contributor Author

gbeatty commented Sep 4, 2013

Ready for another review

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 4, 2013

Cool. Will look at this shortly. Did you do any timings yet?

@@ -6,6 +6,7 @@ Beta Releases

### b21 - 2013-10-01
* Added `CorridorOutlineGeometry`.
* Improved runtime generation of GLSL shaders.
Copy link
Contributor

Choose a reason for hiding this comment

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

We also added new czm_ functions, right?

};

// combine automatic uniforms and Cesium built-ins
var _czmBuiltinsAndUniforms;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is declared here, then used above so it is using JavaScript's hoisting feature. We avoid this. Declare it above.

Do what you want, but I probably wouldn't do it this way at all; it makes the tests harder to follow. Instead, why not put _czmBuiltinsAndUniforms on ShaderProgram (again, it is private for testing) and just let the tests modify it as they did before? It feels cleaner and more direct.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 4, 2013

Just those comments, then this is ready to merge.

@gbeatty
Copy link
Contributor Author

gbeatty commented Sep 4, 2013

ready to go

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 5, 2013

Tests are good in Chrome and Firefox. Code looks good (ShaderProgramSpec.js no longer needs CzmBuiltins, but I'll remove it in master).

Merging. Thanks @gbeatty

pjcozzi added a commit that referenced this pull request Sep 5, 2013
@pjcozzi pjcozzi merged commit 58379b3 into CesiumGS:master Sep 5, 2013
@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 5, 2013

CC #1031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants