HW accelerated activity - ¿cómo obtener el límite de tamaño de textura de OpenGL?


Estoy tratando de habilitar la aceleración hw en Honeycomb, y mostrar algunos mapas de bits en Canvas. Todo funciona bien, pero para mapas de bits grandes (>2048 en una dimensión), obtengo un error en el registro:

OpenGLRenderer: Mapa de bits demasiado grande para ser cargado en una textura

Sé que esto se debe a la limitación de hw, y puedo solucionarlo reduciendo el tamaño máximo del mapa de bits que se mostrará si la aceleración de hw está habilitada (comprobación por Vista.isHardwareAccelerated()).

Mi pregunta es: ¿cómo fácilmente determine el tamaño máximo de textura disponible para el dibujo de mapa de bits por hardware. 2048 parece ser límite en mi dispositivo, pero puede ser diferente en diferentes.

Editar: No estoy creando la aplicación OpenGL, solo la aplicación normal, que puede utilizar la aceleración hw. Por lo tanto, no estoy familiarizado con OpenGL en absoluto, solo veo el error relacionado con OpenGL en el registro, y busco resolverlo.

Author: Pointer Null, 2011-09-15

4 answers

Actualmente el límite mínimo es 2048px (es decir, el hardware debe soportar texturas al menos 2048x2048.) En ICS introduciremos una nueva API en la clase Canvas que te dará esta información:
Canvas.getMaximumBitmapWidth() y Canvas.getMaximumBitmapHeight().

 64
Author: Romain Guy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-04 10:55:48

Otra forma de obtener el tamaño máximo permitido sería recorrer todas las configuraciones EGL10 y realizar un seguimiento del tamaño más grande.

public static int getMaxTextureSize() {
    // Safe minimum default size
    final int IMAGE_MAX_BITMAP_DIMENSION = 2048;

    // Get EGL Display
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    // Initialise
    int[] version = new int[2];
    egl.eglInitialize(display, version);

    // Query total number of configurations
    int[] totalConfigurations = new int[1];
    egl.eglGetConfigs(display, null, 0, totalConfigurations);

    // Query actual list configurations
    EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
    egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);

    int[] textureSize = new int[1];
    int maximumTextureSize = 0;

    // Iterate through all the configurations to located the maximum texture size
    for (int i = 0; i < totalConfigurations[0]; i++) {
        // Only need to check for width since opengl textures are always squared
        egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);

        // Keep track of the maximum texture size
        if (maximumTextureSize < textureSize[0])
            maximumTextureSize = textureSize[0];
    }

    // Release
    egl.eglTerminate(display);

    // Return largest texture size found, or default
    return Math.max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION);
}

A partir de mis pruebas, esto es bastante confiable y no requiere que cree una instancia. En cuanto al rendimiento, esto tomó 18 milisegundos para ejecutarse en mi Nota 2 y solo 4 milisegundos en mi G3.

 16
Author: Pkmmte,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-08 23:36:34

Si desea conocer dinámicamente el límite de tamaño de textura de su dispositivo (porque cambia dependiendo del dispositivo), debe llamar a este método:

int[] maxTextureSize = new int[1];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);

Y no olvide que para algún dispositivo (el Nexus One, por ejemplo), el tamaño de la textura debe ser una potencia de 2 !

Sé que mi respuesta llega mucho tiempo después de la última actualización de este tema...lo siento

 6
Author: VinceFR,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-07-26 08:43:04

Según la especificación, llamando a glGetIntegerv con GL_MAX_TEXTURE_SIZE.

GL_MAX_TEXTURE_SIZE params devuelve un valor. El valor da una estimación aproximada de la textura más grande que el LM puede manejar. El valor debe ser al menos 64.

Http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml

 3
Author: K-ballo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-09-18 08:00:39