Merge branch 'glsl-ext' of https://github.com/nicebyte/glslang into nicebyte-glsl-ext
This commit is contained in:
commit
62f84fd5a3
@ -1196,38 +1196,48 @@ int C_DECL main(int argc, char* argv[])
|
|||||||
// .frag = fragment
|
// .frag = fragment
|
||||||
// .comp = compute
|
// .comp = compute
|
||||||
//
|
//
|
||||||
EShLanguage FindLanguage(const std::string& name, bool parseSuffix)
|
// Additionally, the file names may end in .<stage>.glsl and .<stage>.hlsl
|
||||||
|
// where <stage> is one of the stages listed above.
|
||||||
|
//
|
||||||
|
EShLanguage FindLanguage(const std::string& name, bool parseStageName)
|
||||||
{
|
{
|
||||||
size_t ext = 0;
|
std::string stage_name;
|
||||||
std::string suffix;
|
if (shaderStageName) {
|
||||||
|
stage_name = shaderStageName;
|
||||||
if (shaderStageName)
|
} else if (parseStageName) {
|
||||||
suffix = shaderStageName;
|
// Note: "first" extension means "first from the end", i.e.
|
||||||
else {
|
// if the file is named foo.vert.glsl, then "glsl" is first,
|
||||||
// Search for a suffix on a filename: e.g, "myfile.frag". If given
|
// "vert" is second.
|
||||||
// the suffix directly, we skip looking for the '.'
|
size_t first_ext_start = name.find_last_of(".");
|
||||||
if (parseSuffix) {
|
bool has_first_ext = first_ext_start != std::string::npos;
|
||||||
ext = name.rfind('.');
|
size_t second_ext_start =
|
||||||
if (ext == std::string::npos) {
|
has_first_ext ? name.find_last_of(".", first_ext_start - 1) : std::string::npos;
|
||||||
usage();
|
bool has_second_ext = second_ext_start != std::string::npos;
|
||||||
return EShLangVertex;
|
std::string first_ext = name.substr(first_ext_start + 1, std::string::npos);
|
||||||
}
|
bool uses_unified_ext = has_first_ext && (first_ext == "glsl" ||
|
||||||
++ext;
|
first_ext == "hlsl");
|
||||||
|
if (has_first_ext && !uses_unified_ext) {
|
||||||
|
stage_name = first_ext;
|
||||||
|
} else if (uses_unified_ext && has_second_ext) {
|
||||||
|
stage_name = name.substr(second_ext_start + 1, first_ext_start - second_ext_start - 1);
|
||||||
|
} else {
|
||||||
|
usage();
|
||||||
|
return EShLangVertex;
|
||||||
}
|
}
|
||||||
suffix = name.substr(ext, std::string::npos);
|
} else {
|
||||||
|
stage_name = name;
|
||||||
}
|
}
|
||||||
|
if (stage_name == "vert")
|
||||||
if (suffix == "vert")
|
|
||||||
return EShLangVertex;
|
return EShLangVertex;
|
||||||
else if (suffix == "tesc")
|
else if (stage_name == "tesc")
|
||||||
return EShLangTessControl;
|
return EShLangTessControl;
|
||||||
else if (suffix == "tese")
|
else if (stage_name == "tese")
|
||||||
return EShLangTessEvaluation;
|
return EShLangTessEvaluation;
|
||||||
else if (suffix == "geom")
|
else if (stage_name == "geom")
|
||||||
return EShLangGeometry;
|
return EShLangGeometry;
|
||||||
else if (suffix == "frag")
|
else if (stage_name == "frag")
|
||||||
return EShLangFragment;
|
return EShLangFragment;
|
||||||
else if (suffix == "comp")
|
else if (stage_name == "comp")
|
||||||
return EShLangCompute;
|
return EShLangCompute;
|
||||||
|
|
||||||
usage();
|
usage();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user