cogl: Fix checks of the number of available texture units
We were checking the number of texture units against the GL enum that is used in glGetInteger() to query that number. Let's abstract this in a little function. Took the opportunity to dig a bit on the usage of GL limits for the number of texture (image) units and document our use of them. We'll need something finer grained if we want to fully exploit texture image units with a programmable pipeline.
This commit is contained in:
parent
87d19b8d18
commit
52cb54f5fa
@ -101,6 +101,8 @@ CoglTextureUnit *
|
||||
_cogl_get_texture_unit (int index_);
|
||||
void
|
||||
_cogl_destroy_texture_units (void);
|
||||
guint
|
||||
_cogl_get_max_texture_image_units (void);
|
||||
|
||||
void
|
||||
_cogl_flush_face_winding (void);
|
||||
|
@ -48,12 +48,6 @@
|
||||
#include "../gles/cogl-gles2-wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COGL_GLES
|
||||
#define COGL_MATERIAL_MAX_TEXTURE_UNITS GL_MAX_TEXTURE_UNITS
|
||||
#else
|
||||
#define COGL_MATERIAL_MAX_TEXTURE_UNITS GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COGL_GL
|
||||
#define glActiveTexture ctx->drv.pf_glActiveTexture
|
||||
#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
|
||||
@ -828,7 +822,7 @@ cogl_material_set_layer (CoglHandle material_handle,
|
||||
_cogl_material_pre_change_notify (material, FALSE, NULL);
|
||||
|
||||
material->n_layers = g_list_length (material->layers);
|
||||
if (material->n_layers >= COGL_MATERIAL_MAX_TEXTURE_UNITS)
|
||||
if (material->n_layers >= _cogl_get_max_texture_image_units ())
|
||||
{
|
||||
if (!(material->flags & COGL_MATERIAL_FLAG_SHOWN_SAMPLER_WARNING))
|
||||
{
|
||||
@ -1537,7 +1531,7 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material,
|
||||
|
||||
layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DIRTY;
|
||||
|
||||
if ((i+1) >= COGL_MATERIAL_MAX_TEXTURE_UNITS)
|
||||
if ((i+1) >= _cogl_get_max_texture_image_units ())
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -788,6 +788,36 @@ _cogl_destroy_texture_units (void)
|
||||
g_list_free (ctx->texture_units);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is more complicated than that, another pass needs to be done when
|
||||
* cogl have a neat way of saying if we are using the fixed function pipeline
|
||||
* or not (for the GL case):
|
||||
* MAX_TEXTURE_UNITS: fixed function pipeline, a texture unit has both a
|
||||
* sampler and a set of texture coordinates
|
||||
* MAX_TEXTURE_IMAGE_UNITS: number of samplers one can use from a fragment
|
||||
* program/shader (ARBfp1.0 asm/GLSL)
|
||||
* MAX_VERTEX_TEXTURE_UNITS: number of samplers one can use from a vertex
|
||||
* program/shader (can be 0)
|
||||
* MAX_COMBINED_TEXTURE_IMAGE_UNITS: Maximum samplers one can use, counting both
|
||||
* the vertex and fragment shaders
|
||||
*
|
||||
* If both the vertex shader and the fragment processing stage access the same
|
||||
* texture image unit, then that counts as using two texture image units
|
||||
* against the latter limit: http://www.opengl.org/sdk/docs/man/xhtml/glGet.xml
|
||||
*
|
||||
* Note that, for now, we use GL_MAX_TEXTURE_UNITS as we are exposing the
|
||||
* fixed function pipeline.
|
||||
*/
|
||||
guint
|
||||
_cogl_get_max_texture_image_units (void)
|
||||
{
|
||||
GLint nb_texture_image_units;
|
||||
|
||||
GE( glGetIntegerv(GL_MAX_TEXTURE_UNITS, &nb_texture_image_units) );
|
||||
|
||||
return nb_texture_image_units;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_push_matrix (void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user