Driver crashes with glTexCoordPointer(1,GL_FLOAT..

This topic contains 3 replies, has 2 voices, and was last updated by  Tobias Hector 4 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31008

    elmar
    Member

    Dear support team,

    we are currently porting a large application to the new x86 Android smartphones (Intel Medfield). I’m testing on the Motorola RAZR i, which has been shipped with this OpenGL ES 1.0 driver:

    Vendor=Imagination Technologies, Renderer=PowerVR SGX 540, Version=OpenGL ES-CM 1.1

    Unfortunately, I ran into troubles getting multitexturing to work properly. I started to isolate the problem(s) by putting together a minimum example code (attached below), this code works fine on nVIDIA/AMD GPUs.

    What I need is actually rather simple:

    1) Interpolate between two textures using a per-triangle interpolation factor (the example below uses the primary color coming from a GL_COLOR_ARRAY as this interpolation factor).

    2) Interpolate the result with a pre-defined single (fog) color using another per-triangle interpolation factor. This step is used to add the fog. In normal OpenGL, our application uses glFogCoordPointer for this, but this doesn’t exist in OpenGL ES, so I tried to emulate it using a third texture unit. My idea was to bind a 256×1 RGBA texture to the third unit (*not* shown in the example below!). All pixels in this texture have the fog color, but the alpha changes from 0 to 255. Using the GL_DECAL function, I then only need to supply a single texture X-coordinate ranging from 0..1 to add the custom fog. Unfortunately the driver crashes when I supply only a single texture coordinate with

    glTexCoordPointer(1,…..

    (stack trace follows below).

    Our contacts at Intel are already waiting impatiently for the port to finish, so any help is highly appreciated. Supplying two instead of one texture coordinate would reduce performance, so I was hoping for a better workaround 😉

    Kind regards and many thanks,
    Elmar

    Stacktrace:

    11-04 17:47:21.836 27412 27426 F libc    : Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
    11-04 17:47:22.036 27429 27429 I DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    11-04 17:47:22.036 27429 27429 I DEBUG   : Build fingerprint: ‘motorola/XT890_rtgb/smi:4.0.4/8.7.1I-110_IFW-31/1348340390:user/release-keys’
    11-04 17:47:22.036 27429 27429 I DEBUG   : pid: 27412, tid: 27426 >>> org.libsdl.app <<<
    11-04 17:47:22.036 27429 27429 I DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    11-04 17:47:22.036 27429 27429 I DEBUG   : eax 00000000 ebx 640eb5a0 ecx 00000030 edx 65067408
    11-04 17:47:22.036 27429 27429 I DEBUG   : esi 098d97c0 edi 00000003
    11-04 17:47:22.036 27429 27429 I DEBUG   : xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b
    11-04 17:47:22.036 27429 27429 I DEBUG   : eip 4001fd70 ebp 53b7dc98 esp 53b7dc7c flags 00010246
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 eip: 00019d70 /system/lib/libc.so (memcpy+0x40)
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 eip: 0000ce97 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 eip: 0000e29f /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #03 eip: 0000ff27 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #04 eip: 00006472 /system/lib/libGLESv1_CM.so (glDrawArrays+0x32)
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #05 eip: 00105920 /data/data/org.libsdl.app/files/yasara.so (tst_multitexture+0x240)
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #06 eip: 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   : stack:
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc7c 640a9c8f /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc80 65067408 /dev/dri/card0
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc84 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc88 00000030
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc8c 53bcb148 /system/vendor/lib/libsrv_um.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc90 640a9c69 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc94 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #00 53b7dc98 53b7dcf8
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dc9c 64067e97 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dca0 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dca4 65067408 /dev/dri/card0
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dca8 00000010
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcac 00000003
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcb0 098da730 [heap]
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcb4 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcb8 00000002
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcbc 00000030
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcc0 53b9fe09 /system/vendor/lib/libsrv_um.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcc4 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcc8 098da730 [heap]
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dccc 098da19c [heap]
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcd0 0000002a
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcd4 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #01 53b7dcd8 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     …… ……
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dcfc 6406929f /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd00 00000003
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd04 00000001
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd08 640e6ff4 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd0c 640dbc40 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd10 0987dc50 [heap]
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd14 0987dd20 [heap]
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd18 00000000
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd1c 00000001
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd20 640a4ade /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd24 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd28 6406914b /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd2c 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.286 27429 27429 I DEBUG   :     #02 53b7dd30 098d97c0 [heap]
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #02 53b7dd34 00000003
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #02 53b7dd38 53b7ddb8
    11-04 17:47:22.296 27429 27429 I DEBUG   :     …… ……
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd3c 6406af27 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd40 098d97c0 [heap]
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd44 00000006
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd48 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd4c 00000003
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd50 00000003
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd54 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd58 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd5c 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd60 00000003
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd64 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd68 53b7ddb8
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd6c 640aaabb /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd70 64081b69 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd74 640eb5a0 /system/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_121.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #03 53b7dd78 53b7ddb8
    11-04 17:47:22.296 27429 27429 I DEBUG   :     …… ……
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddbc 416ff472 /system/lib/libGLESv1_CM.so (glDrawArrays+0x32)
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddc0 00000006
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddc4 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddc8 00000003
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddcc 5312f024 /data/data/org.libsdl.app/files/yasara.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddd0 416ff449 /system/lib/libGLESv1_CM.so (glDrawArrays+0x9)
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddd4 5311ca4c /data/data/org.libsdl.app/files/yasara.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #04 53b7ddd8 5312efe8 /data/data/org.libsdl.app/files/yasara.so
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312efec 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312eff0 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312eff4 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312eff8 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312effc 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f000 c2c80000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f004 42c80000 /dev/ashmem/dalvik-heap (deleted)
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f008 c2c80000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f00c 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f010 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f014 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f018 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f01c 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f020 00000000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f024 80808080
    11-04 17:47:22.296 27429 27429 I DEBUG   :     #06 5312f028 c2c80000
    11-04 17:47:22.296 27429 27429 I DEBUG   :     …… ……

    EXAMPLE PROGRAM:
    ================
    struct vec2f
    { float x;
    float y; };
    struct vec3f
    { float x;
    float y;
    float z; };

    struct tstvertex
    { struct vec3f pos;      /* The vertex position */
    struct vec2f texpos[3];/* The three texture positions */
    int32 blend; };           /* Blending factor (a color) */

    #define TST_VERTICES 3
    struct tstvertex tst_vertex[]=
    { { {-100,100,-100}, { {0,0},{0,0},{0,0} }, 0x80808080 },
    { {-100,-100,-100},{ {0,0},{0,0},{0,0} }, 0x80808080 },
    { {100,-100,-100}, { {0,0},{0,0},{0,0} }, 0x80808080 } };

    /* THE THREE TEXTURE COLORS ARE RED, GREEN AND DARK BLUE (THE LATTER WITH ALPHA 128) */
    #define TST_TEXTURES 3
    unsigned char tst_texcoltab[TST_TEXTURES][4]={ {255,0,0,255}, {0,255,0,255}, {0,0,128,128} };

    void tst_multitexture(void)
    { int i;
    GLuint textab[TST_TEXTURES];

    /* SETUP PROJECTION, 640×480 */
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(-320,320,-240,240,0,1000);
    /* CREATE THREE TEXTURES, SETUP ENVIRONMENTS AND COORDINATE ARRAYS */
    glGenTextures(TST_TEXTURES,textab);
    for (i=0;i<TST_TEXTURES;i++)
    { glActiveTexture(GL_TEXTURE0+i);
        glBindTexture(GL_TEXTURE_2D,textab);
        glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,1,1,0,GL_RGBA,GL_UNSIGNED_BYTE,&tst_texcoltab
    );
        glEnable(GL_TEXTURE_2D);
        glMultiTexCoord4f(GL_TEXTURE_2D,0,0,0,0);
        if (!i)
        { /* TEXTURE UNIT 0 IS SIMPLE */
          glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE); }
        else if (i==1)
        { /* TEXTURE UNIT 1 INTERPOLATES THE TEXTURE FROM UNIT 0… */
          glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE);
          glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_INTERPOLATE);
          glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA,GL_INTERPOLATE);
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC0_RGB,GL_PREVIOUS);
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC0_ALPHA,GL_PREVIOUS);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB,GL_SRC_COLOR);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_ALPHA,GL_SRC_ALPHA);
          /* …WITH ITS OWN TEXTURE… */
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC1_RGB,GL_TEXTURE);
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC1_ALPHA,GL_TEXTURE);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB,GL_SRC_COLOR);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_ALPHA,GL_SRC_ALPHA);
          /* …USING THE PRIMARY COLOR AS INTERPOLATION FACTOR */
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC2_RGB,GL_PRIMARY_COLOR);
          glTexEnvi(GL_TEXTURE_ENV,GL_SRC2_ALPHA,GL_PRIMARY_COLOR);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB,GL_SRC_COLOR);
          glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_ALPHA,GL_SRC_ALPHA); }
        else
        { /* TEXTURE UNIT 2 FINALLY INTERPOLATES WITH ITS OWN TEXTURE
            (EXCLUDING ALPHA) USING ITS OWN ALPHA AS INTERPOLATION FACTOR */
          glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); }
        /* ENABLE TEXTURE COORDINATES */    
        glClientActiveTexture(GL_TEXTURE0+i);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        /* !!!!!!!!!!! WORKS IF 1 IS REPLACED WITH 2 !!!!!!!!!!!!! */
        glTexCoordPointer(1,GL_FLOAT,sizeof(*tst_vertex),&tst_vertex[0].texpos
    ); }
    /* ENABLE VERTICES */
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,sizeof(*tst_vertex),&tst_vertex[0].pos);
    /* ENABLE BLENDING FACTOR USED BY TEXTURE UNIT 1 */
    glEnableClientState(GL_COLOR_ARRAY);
    glColorPointer(4,GL_UNSIGNED_BYTE,sizeof(*tst_vertex),&tst_vertex[0].blend);
    /* DRAW THE TRIANGLE */
    glDrawArrays(GL_TRIANGLES,0,TST_VERTICES);
    /* DISABLE AGAIN */
    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
    for (i=TST_TEXTURES-1;i>=0;i–)
    { glActiveTexture(GL_TEXTURE0+i);
        glDisable(GL_TEXTURE_2D);
        glClientActiveTexture(GL_TEXTURE0+i);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY); }
    glDeleteTextures(3,textab);
    glPopMatrix(); }

    #36263

    Hi Elmar,

    Sorry for taking so long to reply to this, we’re trying to keep on top of the forum but this one slipped through the cracks I’m afraid! The crash you’re seeing in this app is typical of an incorrectly set pointer value, as the crash is in glDrawArrays.

    If you look at the glTexCoordPointer reference page for OpenGLES 1 (http://www.khronos.org/opengles/sdk/1.1/docs/man/glTexCoordPointer.xml) you’ll see that 1 is an invalid value and can generate an error. Because of this error, the default values are used to capture the pointer instead – which points at NULL, causing a crash when glDrawArrays tries to access it.

    Hope this helps? Again, apologies for the late reply!

    Regards,
    Tobias

    #36264

    elmar
    Member

    Tobias said:

    Hi Elmar,

    Sorry for taking so long to reply to this, we’re trying to keep on top of the forum but this one slipped through the cracks I’m afraid! The crash you’re seeing in this app is typical of an incorrectly set pointer value, as the crash is in glDrawArrays.

    If you look at the glTexCoordPointer reference page for OpenGLES 1 (http://www.khronos.org/opengles/sdk/1.1/docs/man/glTexCoordPointer.xml) you’ll see that 1 is an invalid value and can generate an error.

    Hi Tobias,

    many thanks for your reply and sorry for the false alarm. Seems like I accidentally looked at the OpenGL docs, where 1 is totally valid 😉

    Best regards,
    Elmar

    #36265

    Hi Elmar,

    No problem! Just glad your app is working now :)!

    Regards,
    Tobias

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.