~ubuntu-branches/ubuntu/precise/clutter-1.0/precise

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/cogl-pipeline-opengl.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-06-14 15:42:20 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614154220-tx3wzg90gppl2zqw
Tags: 1.6.16-0ubuntu1
* Resynchronize on Debian
* New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
646
646
 
647
647
  if (G_UNLIKELY (ctx->max_activateable_texture_units == -1))
648
648
    {
649
 
#if defined (HAVE_COGL_GL)
650
 
      GLint max_tex_coords;
651
 
      GLint max_combined_tex_units;
652
 
      GE (glGetIntegerv (GL_MAX_TEXTURE_COORDS, &max_tex_coords));
653
 
      GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
654
 
                         &max_combined_tex_units));
655
 
      ctx->max_activateable_texture_units =
656
 
        MAX (max_tex_coords - 1, max_combined_tex_units);
657
 
#elif defined (HAVE_COGL_GLES2)
658
 
      GLint max_vertex_attribs;
659
 
      GLint max_combined_tex_units;
660
 
      GE (glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs));
661
 
      GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
662
 
                         &max_combined_tex_units));
 
649
      GLint values[3];
 
650
      int n_values = 0;
 
651
      int i;
 
652
 
 
653
#ifdef HAVE_COGL_GL
 
654
      /* GL_MAX_TEXTURE_COORDS is provided for both GLSL and ARBfp. It
 
655
         defines the number of texture coordinates that can be
 
656
         uploaded (but doesn't necessarily relate to how many texture
 
657
         images can be sampled) */
 
658
      if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL) ||
 
659
          cogl_features_available (COGL_FEATURE_SHADERS_ARBFP))
 
660
        /* Previously this code subtracted the value by one but there
 
661
           was no explanation for why it did this and it doesn't seem
 
662
           to make sense so it has been removed */
 
663
        GE (glGetIntegerv (GL_MAX_TEXTURE_COORDS, values + n_values++));
 
664
 
 
665
      /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but
 
666
         not ARBfp */
 
667
      if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
 
668
        GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
 
669
                           values + n_values++));
 
670
#endif /* HAVE_COGL_GL */
 
671
 
 
672
#ifdef HAVE_COGL_GLES2
 
673
 
 
674
      GE (glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, values + n_values));
663
675
      /* Two of the vertex attribs need to be used for the position
664
676
         and color */
665
 
      ctx->max_activateable_texture_units =
666
 
        MAX (max_vertex_attribs - 2, max_combined_tex_units);
667
 
#else
 
677
      values[n_values++] -= 2;
 
678
 
 
679
      GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
 
680
                         values + n_values++));
 
681
 
 
682
#else /* HAVE_COGL_GLES2 */
 
683
 
 
684
      /* GL_MAX_TEXTURE_UNITS defines the number of units that are
 
685
         usable from the fixed function pipeline, therefore it isn't
 
686
         available in GLES2. These are also tied to the number of
 
687
         texture coordinates that can be uploaded so it should be less
 
688
         than that available from the shader extensions */
668
689
      GE (glGetIntegerv (GL_MAX_TEXTURE_UNITS,
669
 
                         &ctx->max_activateable_texture_units));
670
 
#endif
 
690
                         values + n_values++));
 
691
 
 
692
#endif /* HAVE_COGL_GLES2 */
 
693
 
 
694
      g_assert (n_values <= G_N_ELEMENTS (values) &&
 
695
                n_values > 0);
 
696
 
 
697
      /* Use the maximum value */
 
698
      ctx->max_activateable_texture_units = values[0];
 
699
      for (i = 1; i < n_values; i++)
 
700
        ctx->max_activateable_texture_units =
 
701
          MAX (values[i], ctx->max_activateable_texture_units);
671
702
    }
672
703
 
673
704
  return ctx->max_activateable_texture_units;