Serialize/deserialize shader groups #381
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'll introduce this set of changes by illustrating the "killer app":
This tar file contains a serialized description (in "shadergroup") of the shader group network -- shaders, instance parameter values, connections -- and the oso of every shader referenced by the group. These can be reconstituted to debug the shader from testshade or any other debugging-conducive environment, which does not have to be the original renderer.
This involves three parts:
Part 1:
Added a new variety of ShaderGroupBegin() that accepts a string containing "commands" that easily and human-readably describe the entire setup of a ShaderGroup, equivalent to a set of Parameter, Shader, and ConnectShaders calls. Here is an example:
Added --group command to testshade so this can be tested and used from the
command line. Here's an example:
(Commas are an allowed substitute for semicolons for statement separators, and the last statement separator is optional if it's at the end of the string; this makes it easier for command line use, where semicolons have special meaning in some contexts like our test scripts.)
Part 2:
The mirror image of this, where we can serialize (turn into a command string) an existing ShaderGroup. This is done by retrieving the group attribute "pickle":
will print
Part 3:
shadingsys->archive_shadergroup(group,filename) will create an archive file (tar, tar.gz, or zip, depending on the file extension) containing a serialized description of the shader group as well as oso files for every shader referenced in the group.
Also, new ShadingSystem attributes "archive_groupname" and "archive_filename" will cause the named group to be automatically archived to the given filename, right after it is set up.