Support precision for sampler types.

BUG=
R=alokp@chromium.org

Review URL: https://codereview.appspot.com/12833045
diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp
index 37b5ab2..90065a6 100644
--- a/src/compiler/Compiler.cpp
+++ b/src/compiler/Compiler.cpp
@@ -241,6 +241,11 @@
     floatingPoint.secondarySize = 1;
     floatingPoint.array = false;
 
+    TPublicType sampler;
+    sampler.primarySize = 1;
+    sampler.secondarySize = 1;
+    sampler.array = false;
+
     switch(shaderType)
     {
       case SH_FRAGMENT_SHADER:
@@ -252,6 +257,13 @@
         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);
 
diff --git a/src/compiler/SymbolTable.h b/src/compiler/SymbolTable.h
index d4849d2..1c2f0ef 100644
--- a/src/compiler/SymbolTable.h
+++ b/src/compiler/SymbolTable.h
@@ -332,10 +332,8 @@
     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.isAggregate())
             return false; // Not allowed to set for aggregate types
         int indexOfLastElement = static_cast<int>(precisionStack.size()) - 1;
@@ -346,19 +344,18 @@
     // Searches down the precisionStack for a precision qualifier for the specified TBasicType
     TPrecision getDefaultPrecision( TBasicType type){
 
-        // unsigned integers use the same precision as signed
-        if (type == EbtUInt)
-            type = EbtInt;
-
-        if (type != EbtFloat && type != EbtInt)
+        if (!supportsPrecision(type))
             return EbpUndefined;
 
+        // unsigned integers use the same precision as signed
+        TBasicType baseType = (type == EbtUInt) ? EbtInt : type;
+
         int level = static_cast<int>(precisionStack.size()) - 1;
         assert(level >= 0); // Just to be safe. Should not happen.
         PrecisionStackLevel::iterator it;
         TPrecision prec = EbpUndefined; // If we dont find anything we return this. Should we error check this?
         while (level >= 0) {
-            it = precisionStack[level]->find(type);
+            it = precisionStack[level]->find(baseType);
             if (it != precisionStack[level]->end()) {
                 prec = (*it).second;
                 break;
@@ -371,6 +368,11 @@
 private:
     ESymbolLevel currentLevel() const { return static_cast<ESymbolLevel>(table.size() - 1); }
 
+    bool supportsPrecision(TBasicType type) {
+      // Only supports precision for int, float, and sampler types.
+      return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
+    }
+
     std::vector<TSymbolTableLevel*> table;
     typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
     std::vector< PrecisionStackLevel*> precisionStack;