test-cogl-materials: Use GL_MAX_VERTEX_ATTRIBS on GLES2
When determining the maximum number of layers we also need to take into account GL_MAX_VERTEX_ATTRIBS on GLES2. Cogl needs one vertex attrib for each texture unit plus two for the position and color.
This commit is contained in:
parent
bdeb555ae1
commit
afe3929618
@ -155,19 +155,27 @@ test_using_all_layers (TestState *state, int x, int y)
|
|||||||
/* FIXME: Cogl doesn't provide a way to query the maximum number of
|
/* FIXME: Cogl doesn't provide a way to query the maximum number of
|
||||||
texture layers so for now we'll just ask GL directly. */
|
texture layers so for now we'll just ask GL directly. */
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
{
|
||||||
|
GLint n_image_units, n_attribs;
|
||||||
/* GLES 2 doesn't have GL_MAX_TEXTURE_UNITS and it uses
|
/* GLES 2 doesn't have GL_MAX_TEXTURE_UNITS and it uses
|
||||||
GL_MAX_TEXTURE_IMAGE_UNITS instead */
|
GL_MAX_TEXTURE_IMAGE_UNITS instead */
|
||||||
glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n_layers);
|
glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n_image_units);
|
||||||
/* Cogl can't support more than 16 layers under GLES 2 */
|
/* Cogl needs a vertex attrib for each layer to upload the texture
|
||||||
if (n_layers > 16)
|
coordinates */
|
||||||
n_layers = 16;
|
glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, &n_attribs);
|
||||||
|
/* We can't use two of the attribs because they are used by the
|
||||||
|
position and color */
|
||||||
|
n_attribs -= 2;
|
||||||
|
n_layers = MIN (n_attribs, n_image_units);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
glGetIntegerv (GL_MAX_TEXTURE_UNITS, &n_layers);
|
glGetIntegerv (GL_MAX_TEXTURE_UNITS, &n_layers);
|
||||||
|
#endif
|
||||||
|
/* FIXME: is this still true? */
|
||||||
/* Cogl currently can't cope with more than 32 layers so we'll also
|
/* Cogl currently can't cope with more than 32 layers so we'll also
|
||||||
limit the maximum to that. */
|
limit the maximum to that. */
|
||||||
if (n_layers > 32)
|
if (n_layers > 32)
|
||||||
n_layers = 32;
|
n_layers = 32;
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < n_layers; i++)
|
for (i = 0; i < n_layers; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user