Set the stream source frequencies for instanced draw calls. Searches for an indexed (non-instanced) attribute to ensure it gets mapped to stream 0.

TRAC #19489
Signed-off-by: Daniel Koch
Author: Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@969 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 147bd0f..2b3863f 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 //
@@ -1943,7 +1943,7 @@
 
         if (context)
         {
-            context->drawArrays(mode, first, count);
+            context->drawArrays(mode, first, count, 0);
         }
     }
     catch(std::bad_alloc&)
@@ -1963,11 +1963,14 @@
             return error(GL_INVALID_VALUE);
         }
 
-        gl::Context *context = gl::getNonLostContext();
-
-        if (context)
+        if (primcount > 0)
         {
-            context->drawArraysInstanced(mode, first, count, primcount);
+            gl::Context *context = gl::getNonLostContext();
+
+            if (context)
+            {
+                context->drawArrays(mode, first, count, primcount);
+            }
         }
     }
     catch(std::bad_alloc&)
@@ -2007,7 +2010,7 @@
                 return error(GL_INVALID_ENUM);
             }
         
-            context->drawElements(mode, count, type, indices);
+            context->drawElements(mode, count, type, indices, 0);
         }
     }
     catch(std::bad_alloc&)
@@ -2028,26 +2031,29 @@
             return error(GL_INVALID_VALUE);
         }
 
-        gl::Context *context = gl::getNonLostContext();
-
-        if (context)
+        if (primcount > 0)
         {
-            switch (type)
+            gl::Context *context = gl::getNonLostContext();
+
+            if (context)
             {
-              case GL_UNSIGNED_BYTE:
-              case GL_UNSIGNED_SHORT:
-                break;
-              case GL_UNSIGNED_INT:
-                if (!context->supports32bitIndices())
+                switch (type)
                 {
-                    return error(GL_INVALID_ENUM);    
+                  case GL_UNSIGNED_BYTE:
+                  case GL_UNSIGNED_SHORT:
+                    break;
+                  case GL_UNSIGNED_INT:
+                    if (!context->supports32bitIndices())
+                    {
+                        return error(GL_INVALID_ENUM);    
+                    }
+                    break;
+                  default:
+                    return error(GL_INVALID_ENUM);
                 }
-                break;
-              default:
-                return error(GL_INVALID_ENUM);
+            
+                context->drawElements(mode, count, type, indices, primcount);
             }
-        
-            context->drawElementsInstanced(mode, count, type, indices, primcount);
         }
     }
     catch(std::bad_alloc&)