{
std::string name;
std::string source;
+ Msp::GL::SL::Compiler::Mode compile_mode;
+ std::map<std::string, int> spec_values;
std::map<Msp::GL::SL::Stage::Type, std::string> expected_output;
std::string expected_error;
};
IO::BufferedFile file(fn);
TestCase test_case;
test_case.name = FS::basename(fn);
+ test_case.compile_mode = GL::SL::Compiler::PROGRAM;
string *target = &test_case.source;
while(!file.eof())
{
if(line=="*/")
continue;
- string::size_type expected = line.find("Expected output:");
- if(expected!=string::npos)
+ string::size_type pos = line.find("Expected output:");
+ if(pos!=string::npos)
{
- string stage = strip(line.substr(expected+16));
+ string stage = strip(line.substr(pos+16));
if(stage=="vertex")
target = &test_case.expected_output[GL::SL::Stage::VERTEX];
else if(stage=="geometry")
continue;
}
- expected = line.find("Expected error:");
- if(expected!=string::npos)
+ pos = line.find("Expected error:");
+ if(pos!=string::npos)
{
target = &test_case.expected_error;
continue;
}
+ pos = line.find("Compile mode:");
+ if(pos!=string::npos)
+ {
+ string mode = strip(line.substr(pos+13));
+ if(mode=="module")
+ test_case.compile_mode = GL::SL::Compiler::MODULE;
+ else if(mode=="program")
+ test_case.compile_mode = GL::SL::Compiler::PROGRAM;
+ else
+ throw runtime_error("Unknown compile mode "+mode);
+ continue;
+ }
+
+ pos = line.find("Specialize:");
+ if(pos!=string::npos)
+ {
+ vector<string> parts = split(line.substr(pos+11));
+ int value = 0;
+ if(parts[1]=="true")
+ value = 1;
+ else if(parts[1]=="false")
+ value = 0;
+ else
+ value = lexical_cast<int>(parts[1]);
+ test_case.spec_values[parts[0]] = value;
+ continue;
+ }
+
*target += line;
*target += '\n';
}
try
{
compiler.set_source(test_case->source, "<test>");
- compiler.compile(GL::SL::Compiler::PROGRAM);
+ if(test_case->compile_mode==GL::SL::Compiler::PROGRAM)
+ compiler.specialize(test_case->spec_values);
+ compiler.compile(test_case->compile_mode);
}
catch(const GL::SL::invalid_shader_source &exc)
{