Skip to content

Commit

Permalink
merged in angleproject code as od 8.21.13
Browse files Browse the repository at this point in the history
  • Loading branch information
stammen committed Aug 21, 2013
1 parent 9344b54 commit 0db37af
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 168 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Google Inc.
Adrienne Walker
[email protected]
Justin Schuh
Scott Graham

Adobe Systems Inc.
Alexandru Chiculita
Expand Down
7 changes: 4 additions & 3 deletions include/GLSLANG/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ typedef enum {
} ShDataType;

typedef enum {
SH_PRECISION_HIGHP = 0x5001,
SH_PRECISION_MEDIUMP = 0x5002,
SH_PRECISION_LOWP = 0x5003
SH_PRECISION_HIGHP = 0x5001,
SH_PRECISION_MEDIUMP = 0x5002,
SH_PRECISION_LOWP = 0x5003,
SH_PRECISION_UNDEFINED = 0
} ShPrecisionType;

typedef enum {
Expand Down
2 changes: 1 addition & 1 deletion src/common/version.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MAJOR_VERSION 1
#define MINOR_VERSION 2
#define BUILD_VERSION 0
#define BUILD_REVISION 2438
#define BUILD_REVISION 2440

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
Expand Down
12 changes: 12 additions & 0 deletions src/compiler/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
floatingPoint.matrix = false;
floatingPoint.array = false;

TPublicType sampler;
sampler.size = 1;
sampler.matrix = false;
sampler.array = false;

switch(shaderType)
{
case SH_FRAGMENT_SHADER:
Expand All @@ -242,6 +247,13 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
break;
default: assert(false && "Language not supported");
}
// We set defaults for all the sampler types, even those that are
// only available if an extension exists.
for (int samplerType = EbtGuardSamplerBegin + 1;
samplerType < EbtGuardSamplerEnd; ++samplerType) {
sampler.type = static_cast<TBasicType>(samplerType);
symbolTable.setDefaultPrecision(sampler, EbpLow);
}

InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);

Expand Down
4 changes: 3 additions & 1 deletion src/compiler/ShaderLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ void ShGetVariableInfo(const ShHandle handle,
*precision = SH_PRECISION_HIGHP;
break;
default:
ASSERT(false);
// Some types does not support precision, for example, boolean.
*precision = SH_PRECISION_UNDEFINED;
break;
}

// This size must match that queried by
Expand Down
14 changes: 8 additions & 6 deletions src/compiler/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ class TSymbolTable {
void dump(TInfoSink &infoSink) const;

bool setDefaultPrecision(const TPublicType& type, TPrecision prec) {
if (IsSampler(type.type))
return true; // Skip sampler types for the time being
if (type.type != EbtFloat && type.type != EbtInt)
return false; // Only set default precision for int/float
if (!supportsPrecision(type.type))
return false;
if (type.size != 1 || type.matrix || type.array)
return false; // Not allowed to set for aggregate types
int indexOfLastElement = static_cast<int>(precisionStack.size()) - 1;
Expand All @@ -350,9 +348,8 @@ class TSymbolTable {

// Searches down the precisionStack for a precision qualifier for the specified TBasicType
TPrecision getDefaultPrecision(TBasicType type) {
if (type != EbtFloat && type != EbtInt)
if (!supportsPrecision(type))
return EbpUndefined;

int level = static_cast<int>(precisionStack.size()) - 1;
assert(level >= 0); // Just to be safe. Should not happen.
PrecisionStackLevel::iterator it;
Expand All @@ -371,6 +368,11 @@ class TSymbolTable {
private:
int currentLevel() const { return static_cast<int>(table.size()) - 1; }

bool supportsPrecision(TBasicType type) {
// Only supports precision for int, float, and sampler types.
return type == EbtFloat || type == EbtInt || IsSampler(type);
}

int uniqueId; // for unique identification in code generation
std::vector<TSymbolTableLevel*> table;
typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
Expand Down
6 changes: 6 additions & 0 deletions src/compiler/glslang.l
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ int reserved_word(yyscan_t yyscanner) {
return 0;
}

void yyerror(YYLTYPE* lloc, TParseContext* context, const char* reason) {
context->error(*lloc, reason, yyget_text(context->scanner));
context->recover();
}

int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL;
if (yylex_init_extra(context, &scanner))
Expand Down Expand Up @@ -316,6 +321,7 @@ int glslang_scan(size_t count, const char* const string[], const int length[],
// Initialize preprocessor.
if (!context->preprocessor.init(count, string, length))
return 1;
context->preprocessor.setMaxTokenLength(SH_MAX_TOKEN_LENGTH);

// Define extension macros.
const TExtensionBehavior& extBehavior = context->extensionBehavior();
Expand Down
Loading

0 comments on commit 0db37af

Please sign in to comment.