-
Notifications
You must be signed in to change notification settings - Fork 358
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
Track File Dependencies in ShaderStage #1032
Track File Dependencies in ShaderStage #1032
Conversation
This change allows shader generator code to look at file dependencies in ShaderStages. This is done by adding the file path of a SourceCodeNode to the ShaderStage's set of dependencies whenever a function definition is emitted. Also, ShaderStage is changed to allow returning the set of include files that it requires. Includes a unit test to check that a material's shader dependencies actually exist as files.
Hi @solid-angle, A few notes:
|
Well I really believe these dependencies are associated with a particular generated shader stage, so I'm not sure having the API on the context makes sense - I was trying to mirror how includes were handled, and keep the changes minimal. I think what makes this somewhat confusing is ShaderStage handles caching includes but GenContext handles caching source files. Perhaps it would make most sense to separate caching from dependency tracking, make GenContext responsible for caching both includes and source files, and track dependencies on ShaderStage. I'm open to reworking this but I think that inconsistency needs to be resolved. |
Thanks for the clarification and info. I didn't look at include scope at the stage level. Adding source caching at the Stage level makes sense and is consistent then. |
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 looks like a good improvement, @solid-angle, and I had just one question about the data type of the new method argument and stored data.
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.
Looks good to me, thanks @solid-angle!
This change allows an application to retrieve file dependencies from generated shaders caused by shader includes (via ShaderStage::addInclude) and SourceCodeNode source blocks taken from a file. We add ShaderStage::getIncludes, ShaderStage::addSourceDependency, and ShaderStage::getSourceDependencies. SourceCodeNode is modified to call addSourceDependency.
Changes
This change allows an application to retrieve file dependencies from generated shaders caused by shader includes (via ShaderStage::addInclude) and SourceCodeNode source blocks taken from a file.
We add ShaderStage::getIncludes, ShaderStage::addSourceDependency, and ShaderStage::getSourceDependencies. SourceCodeNode is modified to call addSourceDependency.
Testing
A small unit test is added to verify getSourceDependencies returns valid files. We didn't want to make the test hardcode any dependencies as that would make it break when other parts of the library changed the set of dependencies.
Motivation
Use case: an application may want to cache generated or compiled shaders. In order to do a dependency check on the cache, it needs access to the set of input files that went into generation. There was no way to retrieve these two types of dependencies using the existing API.