Add a new shader-versioning infrastructure capable of handling multiple profiles, desktop/ES, many versions, features coming and going in different versions across different profiles, and extensions.

NB: *Use* of this infrastructure is so far only skeletal.

Fixed a few typos and minor issues along the way.


git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@19951 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2012-12-13 00:05:26 +00:00
parent 5d3e2e35b6
commit 9fd55bd338
31 changed files with 1662 additions and 706 deletions

View file

@ -3,6 +3,8 @@
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//All rights reserved.
//
//Copyright (C) 2012 LunarG, Inc.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions
//are met:
@ -568,7 +570,7 @@ void CPPShInfoLogMsg(const char *msg)
void CPPErrorToInfoLog(char *msg)
{
((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
((TParseContext *)cpp->pC)->error(yylineno, "CPP error:", "",msg,"");
GlobalParseContext->recover();
}
@ -708,6 +710,48 @@ void ResetTString(void)
((TParseContext *)cpp->pC)->HashErrMsg = "";
}
void SetVersion(int version)
{
((TParseContext *)cpp->pC)->version = version;
}
const int FirstProfileVersion = 150;
// Important assumption: SetVersion() is called before SetProfile(), and is always called
// if there is a version, sending in a ENoProfile if there is no profile given.
void SetProfile(EProfile profile)
{
int version = ((TParseContext *)cpp->pC)->version;
if (profile == ENoProfile) {
if (version == 100 || version == 300) {
CPPErrorToInfoLog("versions 100 and 300 require specifying the es profile");
((TParseContext *)cpp->pC)->profile = ENoProfile;
} else if (version >= FirstProfileVersion)
((TParseContext *)cpp->pC)->profile = ECoreProfile;
else
((TParseContext *)cpp->pC)->profile = ENoProfile;
} else {
// a profile was provided...
if (version == 100 || version == 300) {
if (profile != EEsProfile)
CPPErrorToInfoLog("versions 100 and 300 only support the es profile");
((TParseContext *)cpp->pC)->profile = EEsProfile;
} else {
if (profile == EEsProfile) {
CPPErrorToInfoLog("only versions 100 and 300 support the es profile");
if (version >= FirstProfileVersion)
((TParseContext *)cpp->pC)->profile = ECoreProfile;
else
((TParseContext *)cpp->pC)->profile = ENoProfile;
} else {
// typical desktop case... e.g., "#version 410 core"
((TParseContext *)cpp->pC)->profile = profile;
}
}
}
}
TBehavior GetBehavior(const char* behavior)
{
if (!strcmp("require", behavior))