Skip to content

Commit beae086

Browse files
committed
testshade -group now accepts a file containing the serialized group,
in addition to accepting a serialized group fully spelled out on the command line.
1 parent b8e59aa commit beae086

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/testshade/testshade.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4141
#include <OpenImageIO/imagebufalgo_util.h>
4242
#include <OpenImageIO/argparse.h>
4343
#include <OpenImageIO/strutil.h>
44+
#include <OpenImageIO/filesystem.h>
4445
#include <OpenImageIO/timer.h>
4546

4647
#include "OSL/oslexec.h"
@@ -236,10 +237,25 @@ static void
236237
action_groupspec (int argc, const char *argv[])
237238
{
238239
shadingsys->ShaderGroupEnd ();
240+
std::string groupspec (argv[1]);
241+
if (OIIO::Filesystem::exists (groupspec)) {
242+
// If it names a file, use the contents of the file as the group
243+
// specification.
244+
std::ifstream in;
245+
OIIO::Filesystem::open (in, groupspec);
246+
groupspec.clear();
247+
while (in.good()) {
248+
std::string line;
249+
std::getline (in, line);
250+
groupspec += line + "\n";
251+
}
252+
in.close ();
253+
}
239254
if (verbose)
240255
std::cout << "Processing group specification:\n---\n"
241-
<< argv[1] << "\n---\n";
242-
shadergroup = shadingsys->ShaderGroupBegin (groupname, "surface", argv[1]);
256+
<< groupspec << "\n---\n";
257+
add_shader (0, NULL); // becuase this is what sets the options
258+
shadergroup = shadingsys->ShaderGroupBegin (groupname, "surface", groupspec);
243259
}
244260

245261

0 commit comments

Comments
 (0)