From e68b8d68741f2559a4be34d53b8aa3c7ed761471 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Mon, 9 Apr 2012 19:35:41 +0300 Subject: [PATCH] gles: sanity check GL_COMBINED_TEXTURE_IMAGE_UNITS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit At least the Android software GL implementation doesn't return the proper value for this, but rather returns 0. The GL(ES) specification mandates a minimum value of 2, so use this as a fall-back value. Signed-off-by: Imre Deak Signed-off-by: José Fonseca --- glstate_images.cpp | 9 +++++++++ glstate_params.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/glstate_images.cpp b/glstate_images.cpp index 2c7c66b..2d70d99 100644 --- a/glstate_images.cpp +++ b/glstate_images.cpp @@ -425,11 +425,20 @@ dumpTextures(JSONWriter &json, Context &context) json.beginObject(); GLint active_texture = GL_TEXTURE0; glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); + GLint max_texture_coords = 0; glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords); GLint max_combined_texture_image_units = 0; glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units); GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords); + + /* + * At least the Android software GL implementation doesn't return the + * proper value for this, but rather returns 0. The GL(ES) specification + * mandates a minimum value of 2, so use this as a fall-back value. + */ + max_units = std::min(max_units, 2); + for (GLint unit = 0; unit < max_units; ++unit) { GLenum texture = GL_TEXTURE0 + unit; glActiveTexture(texture); diff --git a/glstate_params.py b/glstate_params.py index ad8e258..7c29932 100644 --- a/glstate_params.py +++ b/glstate_params.py @@ -392,7 +392,7 @@ class StateDumper: print ' glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);' print ' GLint max_combined_texture_image_units = 0;' print ' glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);' - print ' GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);' + print ' GLint max_units = std::min(std::max(max_combined_texture_image_units, max_texture_coords), 2);' print ' for (GLint unit = 0; unit < max_units; ++unit) {' print ' char name[32];' print ' snprintf(name, sizeof name, "GL_TEXTURE%i", unit);' -- 2.43.0