evas: Evas_3D - add texture units count checking.
authorDmytro Dadyka <d.dadyka@dmail.com>
Mon, 23 Feb 2015 13:20:45 +0000 (14:20 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 23 Feb 2015 14:41:37 +0000 (15:41 +0100)
Reviewers: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2023

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/modules/evas/engines/gl_common/evas_gl_3d.c
src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c

index 403aea6..eab4351 100644 (file)
@@ -1262,10 +1262,17 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
         evas_normal_matrix_get(&data->matrix_normal, matrix_mv);
      }
 
-   // TODO Add correct numbering
    int num;
    glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &num);
    data->smap_sampler = num - 1;
+
+   if (data->texture_count >= num)
+     if ((data->flags & E3D_SHADER_FLAG_SHADOWED) || (data->texture_count > num))
+       {
+          ERR("Too many textures for your graphics configuration.");
+          return EINA_FALSE;
+       }
+
    return EINA_TRUE;
 }
 
index 82b0676..f522881 100644 (file)
@@ -15,6 +15,7 @@ struct _E3D_Renderer
    Eina_Bool      vertex_attrib_enable[E3D_MAX_VERTEX_ATTRIB_COUNT];
    Eina_Bool      depth_test_enable;
    GLuint         texDepth;
+   GLint         smap_sampler;
 };
 
 static inline GLenum
@@ -173,8 +174,12 @@ _renderer_texture_bind(E3D_Renderer *renderer, E3D_Draw_Data *data)
                }
           }
      }
-     glActiveTexture(GL_TEXTURE0 + data->smap_sampler);
-     glBindTexture(GL_TEXTURE_2D, renderer->texDepth);
+   if ((data->flags & E3D_SHADER_FLAG_SHADOWED) && (renderer->smap_sampler != data->smap_sampler))
+     {
+        glActiveTexture(GL_TEXTURE0 + data->smap_sampler);
+        glBindTexture(GL_TEXTURE_2D, renderer->texDepth);
+        renderer->smap_sampler = data->smap_sampler;
+     }
 }
 
 static inline void