b=619798; upgrade ANGLE to r511; r+a=vlad
authorVladimir Vukicevic <vladimir@pobox.com>
Thu, 16 Dec 2010 12:49:06 -0800
changeset 59413 2c2aed8d77031c30b3986ab55baad2ae3a7ebee0
parent 59412 8b6d5951bc1d1cd30ca451eae3c9ee0fdb45e494
child 59414 075bb085d7552d94be7b00aa724cb0e8228049be
push id17616
push uservladimir@mozilla.com
push dateThu, 16 Dec 2010 20:50:24 +0000
treeherdermozilla-central@075bb085d755 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs619798
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=619798; upgrade ANGLE to r511; r+a=vlad
content/canvas/test/webgl/webgl-conformance-tests.html
gfx/angle/CONTRIBUTORS
gfx/angle/README.mozilla
gfx/angle/angle-bug-40.patch
gfx/angle/angle-bug-93.patch
gfx/angle/src/compiler/ParseHelper.cpp
gfx/angle/src/compiler/Types.h
gfx/angle/src/compiler/preprocessor/cpp.c
gfx/angle/src/libEGL/Surface.cpp
gfx/angle/src/libEGL/libEGL.cpp
gfx/angle/src/libGLESv2/Program.cpp
gfx/angle/src/libGLESv2/Shader.cpp
--- a/content/canvas/test/webgl/webgl-conformance-tests.html
+++ b/content/canvas/test/webgl/webgl-conformance-tests.html
@@ -230,17 +230,17 @@ function start() {
         break;
     };
   };
 
   var reporter = new Reporter();
   var iframe = document.getElementById("testframe");
   var testHarness = new WebGLTestHarnessModule.TestHarness(
       iframe,
-      '00_test_list.txt',
+      '00_testFIXME_list.txt',
       function(type, msg, success) {
         return reporter.reportFunc(type, msg, success);
       });
   window.webglTestHarness = testHarness;
   var button = document.getElementById("runTestsButton");
   button.onclick = function() {
     testHarness.runTests();
   };
--- a/gfx/angle/CONTRIBUTORS
+++ b/gfx/angle/CONTRIBUTORS
@@ -10,15 +10,23 @@ TransGaming Inc.
  Nicolas Capens
  Daniel Koch
  Andrew Lewycky
  Gavriel State
  Shannon Woods
 
 Google Inc.
  Henry Bridge
+ N. Duca
  Vangelis Kokkevis
  Alok Priyadarshi
  Alastair Patrick
+ Kenneth Russel
+ Adrienne Walker
+
+Mozilla Corp.
+ Vladimir Vukicevic
+ Benoit Jacob
 
 Aitor Moreno <aitormoreno at gmail.com>
 Jim Hauxwell <james at dattrax.co.uk>
-Vladimir Vukicevic <vladimir at mozilla.com>
+ddefrostt
+timeless
--- a/gfx/angle/README.mozilla
+++ b/gfx/angle/README.mozilla
@@ -1,21 +1,17 @@
 This is the ANGLE project, from http://code.google.com/p/angleproject/.
 
-Current revision: r498
+Current revision: r511
 
 Local patches:
     angle-shared.patch - add declspec dllexport/dllimport support on win32
 
     angle-fixes.patch - fix angle issues 51 & 52
 
-    angle-bug-40.patch - fix angle issue 40: freeze when compiling bad #ifdef shader
-
-    angle-bug-93.patch - fix angle issue 93: was leaking locale objects
-
 == Visual Studio Solution Files ==
 
 The VS solution/project files that are used to build ANGLE are built
 with VS2008 in upstream ANGLE.  Because our build machines use VS2005,
 they need to be downgraded using
 http://www.emmet-gray.com/Articles/ProjectConverter.htm before being
 checked in with an ANGLE update.
 
deleted file mode 100644
--- a/gfx/angle/angle-bug-40.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-# HG changeset patch
-# Parent 29f85e1308509423edf7da745dcb5ad2b2c1d88d
-diff --git a/gfx/angle/src/compiler/preprocessor/cpp.c b/gfx/angle/src/compiler/preprocessor/cpp.c
---- a/gfx/angle/src/compiler/preprocessor/cpp.c
-+++ b/gfx/angle/src/compiler/preprocessor/cpp.c
-@@ -489,19 +489,18 @@ static int CPPifdef(int defined, yystype
- 	cpp->elsetracker++;
-     cpp->elsedepth[cpp->elsetracker] = 0;
-     if (token != CPP_IDENTIFIER) {
-             defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
-     } else {
-         Symbol *s = LookUpSymbol(macros, name);
-         token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-         if (token != '\n') {
--            CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
--            while (token != '\n')
--                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-+            CPPErrorToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
-+            return 0;
-         }
-         if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
-             token = CPPelse(1, yylvalpp);
-     }
-     return token;
- } // CPPifdef
- 
- static int CPPline(yystypepp * yylvalpp) 
deleted file mode 100644
--- a/gfx/angle/angle-bug-93.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-# HG changeset patch
-# Parent fc2b34772d39957b66ae1bcb9f3f0d1af9cdb3e8
-diff --git a/gfx/angle/src/compiler/util.cpp b/gfx/angle/src/compiler/util.cpp
---- a/gfx/angle/src/compiler/util.cpp
-+++ b/gfx/angle/src/compiler/util.cpp
-@@ -13,17 +13,20 @@
-     #include <locale.h>
- #else
-     #include <sstream>
- #endif
- 
- double atof_dot(const char *str)
- {
- #ifdef _MSC_VER
--    return _atof_l(str, _create_locale(LC_NUMERIC, "C"));
-+    _locale_t l = _create_locale(LC_NUMERIC, "C");
-+    double result = _atof_l(str, l);
-+    _free_locale(l);
-+    return result;
- #else
-     double result;
-     std::istringstream s(str);
-     std::locale l("C");
-     s.imbue(l);
-     s >> result;
-     return result;
- #endif
--- a/gfx/angle/src/compiler/ParseHelper.cpp
+++ b/gfx/angle/src/compiler/ParseHelper.cpp
@@ -540,17 +540,17 @@ bool TParseContext::constructorErrorChec
         }
     }
 
     if (overFull) {
         error(line, "too many arguments", "constructor", "");
         return true;
     }
     
-    if (op == EOpConstructStruct && !type->isArray() && type->getStruct()->size() != function.getParamCount()) {
+    if (op == EOpConstructStruct && !type->isArray() && int(type->getStruct()->size()) != function.getParamCount()) {
         error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");
         return true;
     }
 
     if (!type->isMatrix()) {
         if ((op != EOpConstructStruct && size != 1 && size < type->getObjectSize()) ||
             (op == EOpConstructStruct && size < type->getObjectSize())) {
             error(line, "not enough data provided for construction", "constructor", "");
--- a/gfx/angle/src/compiler/Types.h
+++ b/gfx/angle/src/compiler/Types.h
@@ -80,31 +80,31 @@ typedef TMap<TTypeList*, TTypeList*>::it
 // Base class for things that have a type.
 //
 class TType {
 public:
     POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
     TType() {}
     TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
             type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
-            structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
+            maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
     {
     }
     explicit TType(const TPublicType &p) :
             type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
-            structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
+            maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), fieldName(0), mangled(0), typeName(0)
     {
         if (p.userDef) {
             structure = p.userDef->getStruct();
             typeName = NewPoolTString(p.userDef->getTypeName().c_str());
         }
     }
     TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
             type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
-            structure(userDef), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0)
+            maxArraySize(0), arrayInformationType(0), structure(userDef), structureSize(0), fieldName(0), mangled(0)
     {
         typeName = NewPoolTString(n.c_str());
     }
 
     void copyType(const TType& copyOf, TStructureMap& remapper)
     {
         type = copyOf.type;
         precision = copyOf.precision;
--- a/gfx/angle/src/compiler/preprocessor/cpp.c
+++ b/gfx/angle/src/compiler/preprocessor/cpp.c
@@ -186,16 +186,19 @@ static int CPPdefine(yystypepp * yylvalp
         memcpy(mac.args, args, argc * sizeof(int));
         token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
 	}
     mac.body = NewTokenStream(GetAtomString(atable, name), macros->pool);
     while (token != '\n') {
         if (token == '\\') {
             CPPErrorToInfoLog("The line continuation character (\\) is not part of the OpenGL ES Shading Language");
             return token;
+        } else if (token <= 0) { // EOF or error
+            CPPErrorToInfoLog("unexpected end of input in #define preprocessor directive - expected a newline");
+            return 0;
         }
         RecordToken(mac.body, token, yylvalpp);
         token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
     };
 
     symb = LookUpSymbol(macros, name);
     if (symb) {
         if (!symb->details.mac.undef) {
@@ -262,19 +265,23 @@ static int CPPundef(yystypepp * yylvalpp
 
 static int CPPelse(int matchelse, yystypepp * yylvalpp)
 {
     int atom,depth=0;
     int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
 	
 	while (token > 0) {
         if (token != '#') {
-		    while (token != '\n')
+            while (token != '\n') {
                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-            
+                if (token <= 0) { // EOF or error
+                    CPPErrorToInfoLog("unexpected end of input in #else preprocessor directive - expected a newline");
+                    return 0;
+                }
+            }
             token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
             continue;
         }
 		if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)
 			continue;
         atom = yylvalpp->sc_ident;
         if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){
             depth++; cpp->ifdepth++; cpp->elsetracker++;
@@ -290,18 +297,23 @@ static int CPPelse(int matchelse, yystyp
                 --cpp->elsetracker;
                 --cpp->ifdepth;
             }
         else if (((int)(matchelse) != 0)&& depth==0) {
 			if (atom == elseAtom ) {
                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
                 if (token != '\n') {
                     CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
-                    while (token != '\n')
+                    while (token != '\n') {
                         token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                        if (token <= 0) { // EOF or error
+                            CPPErrorToInfoLog("unexpected end of input following #else preprocessor directive - expected a newline");
+                            return 0;
+                        }
+                    }
                 } 
 				break;
 			} 
 			else if (atom == elifAtom) {
                 /* we decrement cpp->ifdepth here, because CPPif will increment
                  * it and we really want to leave it alone */
 				if (cpp->ifdepth){
 					--cpp->ifdepth;
@@ -462,19 +474,24 @@ static int CPPif(yystypepp * yylvalpp) {
     if (!cpp->ifdepth++)
         ifloc = *cpp->tokenLoc;
 	if(cpp->ifdepth >MAX_IF_NESTING){
         CPPErrorToInfoLog("max #if nesting depth exceeded");
 		return 0;
 	}
 	token = eval(token, MIN_PREC, &res, &err, yylvalpp);
     if (token != '\n') {
-        CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");
-        while (token != '\n')
+        CPPWarningToInfoLog("unexpected tokens following #if preprocessor directive - expected a newline");
+        while (token != '\n') {
             token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            if (token <= 0) { // EOF or error
+                CPPErrorToInfoLog("unexpected end of input in #if preprocessor directive - expected a newline");
+                return 0;
+            }
+        }
     } 
     if (!res && !err) {
         token = CPPelse(1, yylvalpp);
     }
 
     return token;
 } // CPPif
 
@@ -489,18 +506,24 @@ static int CPPifdef(int defined, yystype
 	cpp->elsetracker++;
     cpp->elsedepth[cpp->elsetracker] = 0;
     if (token != CPP_IDENTIFIER) {
             defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
     } else {
         Symbol *s = LookUpSymbol(macros, name);
         token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
         if (token != '\n') {
-            CPPErrorToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
-            return 0;
+            CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
+            while (token != '\n') {
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                if (token <= 0) { // EOF or error
+                    CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline");
+                    return 0;
+                }
+            }
         }
         if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
             token = CPPelse(1, yylvalpp);
     }
     return token;
 } // CPPifdef
 
 static int CPPline(yystypepp * yylvalpp) 
@@ -538,17 +561,20 @@ static int CPPline(yystypepp * yylvalpp)
 }
 
 static int CPPerror(yystypepp * yylvalpp) {
 
 	int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
     const char *message;
 	
     while (token != '\n') {
-		if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){
+        if (token <= 0){
+            CPPErrorToInfoLog("unexpected end of input in #error preprocessor directive - expected a newline");
+            return 0;
+        }else if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){
             StoreStr(yylvalpp->symbol_name);
 		}else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){
 			StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
 		}else {
 		    StoreStr(GetStringOfAtom(atable,token));
 		}
 		token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
 	}
@@ -721,35 +747,46 @@ int readCPPline(yystypepp * yylvalpp)
 			 if(ChkCorrectElseNesting()){
                  if (!cpp->ifdepth ){
                      CPPErrorToInfoLog("#else mismatch");
                      cpp->CompileError=1;
                  }
                  token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
                  if (token != '\n') {
                      CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
-                     while (token != '\n')
+                     while (token != '\n') {
                          token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                         if (token <= 0) { // EOF or error
+                             CPPErrorToInfoLog("unexpected end of input in #ifdef preprocessor directive - expected a newline");
+                             return 0;
+                         }
+                     }
                  }
 			     token = CPPelse(0, yylvalpp);
              }else{
                  CPPErrorToInfoLog("#else after a #else");
                  cpp->ifdepth=0;
                  cpp->pastFirstStatement = 1;
                  return 0;
              }
 		} else if (yylvalpp->sc_ident == elifAtom) {
             if (!cpp->ifdepth){
                  CPPErrorToInfoLog("#elif mismatch");
                  cpp->CompileError=1;
             } 
             // this token is really a dont care, but we still need to eat the tokens
             token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); 
-            while (token != '\n')
+            while (token != '\n') {
                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                if (token <= 0) { // EOF or error
+                    CPPErrorToInfoLog("unexpect tokens following #elif preprocessor directive - expected a newline");
+                    cpp->CompileError = 1;
+                    break;
+                }
+            }
 		    token = CPPelse(0, yylvalpp);
         } else if (yylvalpp->sc_ident == endifAtom) {
 		     --cpp->elsetracker;
              if (!cpp->ifdepth){
                  CPPErrorToInfoLog("#endif mismatch");
                  cpp->CompileError=1;
              }
              else
--- a/gfx/angle/src/libEGL/Surface.cpp
+++ b/gfx/angle/src/libEGL/Surface.cpp
@@ -338,26 +338,30 @@ void Surface::subclassWindow()
   SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
   mWindowSubclassed = true;
 }
 
 void Surface::unsubclassWindow()
 {
   if(!mWindowSubclassed)
     return;
+
+  // un-subclass
+  LONG parentWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc));
+
   // Check the windowproc is still SurfaceWindowProc.
   // If this assert fails, then it is likely the application has subclassed the
   // hwnd as well and did not unsubclass before destroying its EGL context. The
   // application should be modified to either subclass before initializing the
   // EGL context, or to unsubclass before destroying the EGL context.
-  ASSERT(GetWindowLong(mWindow, GWL_WNDPROC) == reinterpret_cast<LONG>(SurfaceWindowProc));
+  if(parentWndFunc) {
+    LONG prevWndFunc = SetWindowLong(mWindow, GWL_WNDPROC, parentWndFunc);
+    ASSERT(prevWndFunc == reinterpret_cast<LONG>(SurfaceWindowProc));
+  }
 
-  // un-subclass
-  LONG prevWndFunc = reinterpret_cast<LONG>(GetProp(mWindow, kParentWndProc));
-  SetWindowLong(mWindow, GWL_WNDPROC, prevWndFunc);
   RemoveProp(mWindow, kSurfaceProperty);
   RemoveProp(mWindow, kParentWndProc);
   mWindowSubclassed = false;
 }
 
 bool Surface::checkForOutOfDateSwapChain()
 {
     RECT client;
--- a/gfx/angle/src/libEGL/libEGL.cpp
+++ b/gfx/angle/src/libEGL/libEGL.cpp
@@ -355,16 +355,18 @@ EGLSurface __stdcall eglCreateWindowSurf
                     break;
                   case EGL_VG_COLORSPACE:
                     return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                   case EGL_VG_ALPHA_FORMAT:
                     return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                   default:
                     return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                 }
+
+                attrib_list += 2;
             }
         }
 
         if (display->hasExistingWindowSurface(window))
         {
             return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
         }
 
--- a/gfx/angle/src/libGLESv2/Program.cpp
+++ b/gfx/angle/src/libGLESv2/Program.cpp
@@ -198,17 +198,17 @@ GLint Program::getSamplerMapping(unsigne
 
     GLint logicalTextureUnit = -1;
 
     if (mSamplers[samplerIndex].active)
     {
         logicalTextureUnit = mSamplers[samplerIndex].logicalTextureUnit;
     }
 
-    if (logicalTextureUnit < MAX_TEXTURE_IMAGE_UNITS)
+    if (logicalTextureUnit >= 0 && logicalTextureUnit < MAX_TEXTURE_IMAGE_UNITS)
     {
         return logicalTextureUnit;
     }
 
     return -1;
 }
 
 SamplerType Program::getSamplerType(unsigned int samplerIndex)
@@ -1654,24 +1654,25 @@ bool Program::linkUniforms(ID3DXConstant
 }
 
 // Adds the description of a constant found in the binary shader to the list of uniforms
 // Returns true if succesful (uniform not already defined)
 bool Program::defineUniform(const D3DXHANDLE &constantHandle, const D3DXCONSTANT_DESC &constantDescription, std::string name)
 {
     if (constantDescription.RegisterSet == D3DXRS_SAMPLER)
     {
-        unsigned int samplerIndex = constantDescription.RegisterIndex;
-
-        assert(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0]));
-
-        mSamplers[samplerIndex].active = true;
-        mSamplers[samplerIndex].type = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? SAMPLER_CUBE : SAMPLER_2D;
-        mSamplers[samplerIndex].logicalTextureUnit = 0;
-        mSamplers[samplerIndex].dirty = true;
+        for (unsigned int samplerIndex = constantDescription.RegisterIndex; samplerIndex < constantDescription.RegisterIndex + constantDescription.RegisterCount; samplerIndex++)
+        {
+            ASSERT(samplerIndex < sizeof(mSamplers)/sizeof(mSamplers[0]));
+
+            mSamplers[samplerIndex].active = true;
+            mSamplers[samplerIndex].type = (constantDescription.Type == D3DXPT_SAMPLERCUBE) ? SAMPLER_CUBE : SAMPLER_2D;
+            mSamplers[samplerIndex].logicalTextureUnit = 0;
+            mSamplers[samplerIndex].dirty = true;
+        }
     }
 
     switch(constantDescription.Class)
     {
       case D3DXPC_STRUCT:
         {
             for (unsigned int arrayIndex = 0; arrayIndex < constantDescription.Elements; arrayIndex++)
             {
@@ -2220,24 +2221,24 @@ bool Program::applyUniform1iv(GLint loca
         {
             return false;
         }
 
         if (constantDescription.RegisterSet == D3DXRS_SAMPLER)
         {
             unsigned int firstIndex = mConstantTablePS->GetSamplerIndex(constantPS);
 
-            for (unsigned int samplerIndex = firstIndex; samplerIndex < firstIndex + count; samplerIndex++)
+            for (int i = 0; i < count; i++)
             {
-                GLint mappedSampler = v[0];
-
-                if (samplerIndex >= 0 && samplerIndex < MAX_TEXTURE_IMAGE_UNITS)
+                unsigned int samplerIndex = firstIndex + i;
+
+                if (samplerIndex < MAX_TEXTURE_IMAGE_UNITS)
                 {
                     ASSERT(mSamplers[samplerIndex].active);
-                    mSamplers[samplerIndex].logicalTextureUnit = mappedSampler;
+                    mSamplers[samplerIndex].logicalTextureUnit = v[i];
                     mSamplers[samplerIndex].dirty = true;
                 }
             }
 
             return true;
         }
     }
 
@@ -2576,26 +2577,32 @@ void Program::getAttachedShaders(GLsizei
     if (count)
     {
         *count = total;
     }
 }
 
 void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
 {
-    unsigned int attribute = 0;
-    for (unsigned int i = 0; i < index; i++)
+    // Skip over inactive attributes
+    unsigned int activeAttribute = 0;
+    unsigned int attribute;
+    for (attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
     {
-        do
+        if (mLinkedAttribute[attribute].name.empty())
         {
-            attribute++;
-
-            ASSERT(attribute < MAX_VERTEX_ATTRIBS);   // index must be smaller than getActiveAttributeCount()
+            continue;
         }
-        while (mLinkedAttribute[attribute].name.empty());
+
+        if (activeAttribute == index)
+        {
+            break;
+        }
+
+        activeAttribute++;
     }
 
     if (bufsize > 0)
     {
         const char *string = mLinkedAttribute[attribute].name.c_str();
 
         strncpy(name, string, bufsize);
         name[bufsize - 1] = '\0';
@@ -2643,19 +2650,19 @@ GLint Program::getActiveAttributeMaxLeng
 
 void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
 {
     // Skip over internal uniforms
     unsigned int activeUniform = 0;
     unsigned int uniform;
     for (uniform = 0; uniform < mUniforms.size(); uniform++)
     {
-        while (mUniforms[uniform]->name.substr(0, 3) == "dx_")
+        if (mUniforms[uniform]->name.substr(0, 3) == "dx_")
         {
-            uniform++;
+            continue;
         }
 
         if (activeUniform == index)
         {
             break;
         }
 
         activeUniform++;
--- a/gfx/angle/src/libGLESv2/Shader.cpp
+++ b/gfx/angle/src/libGLESv2/Shader.cpp
@@ -238,17 +238,17 @@ void Shader::parseVaryings()
     {
         const char *input = strstr(mHlsl, "// Varyings") + 12;
 
         while(true)
         {
             char varyingType[256];
             char varyingName[256];
 
-            int matches = sscanf(input, "static %s %s", varyingType, varyingName);
+            int matches = sscanf(input, "static %255s %255s", varyingType, varyingName);
 
             if (matches != 2)
             {
                 break;
             }
 
             char *array = strstr(varyingName, "[");
             int size = 1;
@@ -468,17 +468,17 @@ void VertexShader::parseAttributes()
     {
         const char *input = strstr(mHlsl, "// Attributes") + 14;
 
         while(true)
         {
             char attributeType[256];
             char attributeName[256];
 
-            int matches = sscanf(input, "static %s _%s", attributeType, attributeName);
+            int matches = sscanf(input, "static %255s _%255s", attributeType, attributeName);
 
             if (matches != 2)
             {
                 break;
             }
 
             mAttributes.push_back(Attribute(parseType(attributeType), attributeName));