DrawElements failed in Mali400

Started by
8 comments, last by Katie 11 years ago

Hi, All

I am writing a simple application to draw some rectangle on the screen.

But it failed on Mali400 GPU. It works on our other phones, such as Adreno225, SGX540.

Can someone tell me what's wrong? Is the Mali400's issue??

Thanks.

Advertisement

It's unlikely to be the Mali 400 itself -- because it's definitely possible to draw things on the screen. I mean, really... what are the chances that someone's shipped a whole series of phones that can't render anything to the screen? Wouldn't someone else have noticed? Isn't a chip that used in a billion phones likely to have been a little bit tested?

Isn't it more likely that it's your application?

If you post the source, we could have a look at it for you.

It's unlikely to be the Mali 400 itself -- because it's definitely possible to draw things on the screen. I mean, really... what are the chances that someone's shipped a whole series of phones that can't render anything to the screen? Wouldn't someone else have noticed? Isn't a chip that used in a billion phones likely to have been a little bit tested?

Isn't it more likely that it's your application?

If you post the source, we could have a look at it for you.

Hi, Katie,

Thank you for your reply.

Here are my code snippet:


int nrow = 10;
int ncol = 10;
int nNum = (nrow+1)*(ncol+1);

GLfloat* pVert = (GLfloat*)malloc(nNum*4*sizeof(GLfloat));
if( NULL==pVert )
    return;

memset(pVert, 0, nNum*4*sizeof(GLfloat));

float fw = 2.0f/nrow;
float fh = 2.0f/ncol;
int step = 0;

for( int i=0; i<col+1; i++ )
{
    for( int j=0; j<row+1; j++ )
    {
        pVert[step]=-1.0f+fw*j; pVert[step+1]=-1.0f+fh*i; pVert[step+2]=0.5f, pVert[step+3]=1.0f;
        step += 4;
    }
}

GLuint* pIndex = (GLuint*)malloc(nrow*ncol*6*sizeof(GLuint));
if( NULL == pIndex )
{
    free(pVert);
    return;
}
memset( pIndex, 0, nrow*ncol*6*sizeof(GLuint) );

step = 0;
for( int i=0; i<ncol; i++ )
{
    for( int j=0; j<row; j++ )
    {
        pIndex[step] = (row+1)*i+j;
        pIndex[step+1] = (row+1)*i+j+(row+1);
        pIndex[step+2] = (row+1)*i+j+1;
        pIndex[step+3] = (row+1)*i+j+(row+1);
        pIndex[step+4] = (row+1)*i+j+1;
        pIndex[step+5] = (row+1)*i+j+1+(row+1);

        step+=6;
    }
}

and here are the render function:


glClearColor( 0.2f, 0.2f, 0.2f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glUseProgram( nProgram );
glVertexAttribPointer( nVert, 4, GL_FLOAT, GL_FALSE, 0, pVert );

glDrawElements( GL_TRIANGLES, nNum*3, GL_UNSIGNED_INT, pIndex );

glFlush();
vdkSwapEGL(&egl);

The shaders do nothing just gl_Position = "input position", gl_FragColor=vec4(1.0, 0.0, 0.0, 1.0);

The Mali400 GPU cannot render anything, but Adreno225 and SGX540 rendering what I expected.

Thank you~

I can't see anything obvious in the host portion of the code -- certainly if that stuff works on the other phones I'd say there's no problem there.

Are you sure the shader compiles/links/uses? That's a pretty common cause of renders doing nothing. (And it's a step whose functionality differs between the different phone hardwares). Can you run the shader through the Mali offline compiler? (Available from Arm's developer site)

There's also a few example programs on their website which you could compile up and try out (they should defn render).

Take a look at the quick reference card (or spec):

DrawElements accepts for type: UNSIGNED_BYTE, UNSIGNED_SHORT

GL_UNSIGNED_INT is likely causing an error - do you see anything returned from glGetError?

Note, you will need to make sure you change the type of data you submit as well. So the GLuint * would be GLushort* etc.

It's unlikely to be the Mali 400 itself -- because it's definitely possible to draw things on the screen. I mean, really... what are the chances that someone's shipped a whole series of phones that can't render anything to the screen? Wouldn't someone else have noticed? Isn't a chip that used in a billion phones likely to have been a little bit tested?

Isn't it more likely that it's your application?

Actually, in this particular case, it is likely to be his use of GL_UNSIGNED_INT, but the frank fact is that Mali400 shader compilers do not adhere to the OpenGL ES 2.0 standard and many things that run on other devices simply will not on Mali400. This was a major problem for us when porting our in-house engine, compounded by the fact that you can’t set breakpoints in Native Activity apps.

Since I was not on that team I don’t remember the details, but it had to do with array access. Either array access was completely broken or buggy, or there were artificial restrictions on accessing arrays, such as that they could only be accessed with constants, not variables.

So, in fact, it quite likely could have been specifically the Mali400 that was actually causing the problems. The Mali400 is capable of rendering some things, but they really did ship millions of devices that can’t render most things that work fine on other devices.


This is why it just never pays to support Android.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I can't see anything obvious in the host portion of the code -- certainly if that stuff works on the other phones I'd say there's no problem there.

Are you sure the shader compiles/links/uses? That's a pretty common cause of renders doing nothing. (And it's a step whose functionality differs between the different phone hardwares). Can you run the shader through the Mali offline compiler? (Available from Arm's developer site)

There's also a few example programs on their website which you could compile up and try out (they should defn render).

Hi, Katie,

It was not the shader issue. Otherwise, it will be failed on other chip.

And it was failed because the wrong arguments of DrawElements. I should use UNSIGNED_SHORT instead of UNSIGNED_INT.

Thank you~~

Take a look at the quick reference card (or spec):

DrawElements accepts for type: UNSIGNED_BYTE, UNSIGNED_SHORT

GL_UNSIGNED_INT is likely causing an error - do you see anything returned from glGetError?

Note, you will need to make sure you change the type of data you submit as well. So the GLuint * would be GLushort* etc.

Hi, adampetrone, Thank you!

I can render it successfully now. Just using UNSIGNED_SHORT instead of UNSIGNED_INT.

This is a great help !!!

It's unlikely to be the Mali 400 itself -- because it's definitely possible to draw things on the screen. I mean, really... what are the chances that someone's shipped a whole series of phones that can't render anything to the screen? Wouldn't someone else have noticed? Isn't a chip that used in a billion phones likely to have been a little bit tested?

Isn't it more likely that it's your application?

Actually, in this particular case, it is like to be his use of GL_UNSIGNED_INT, but the frank fact is that Mali400 shader compilers do not adhere to the OpenGL ES 2.0 standard and many things that run on other devices simply will not on Mali400. This was a major problem for us when porting our in-house engine, compounded by the fact that you can’t set breakpoints in Native Activity apps.

Since I was not on that team I don’t remember the details, but it had to do with array access. Either array access was completely broken or buggy, or there were artificial restrictions on accessing arrays, such as that they could only be accessed with constants, not variables.

So, in fact, it quite likely could have been specifically the Mali400 that was actually causing the problems. The Mali400 is capable of rendering some things, but they really did ship millions of devices that can’t render most things that work fine on other devices.


This is why it just never pays to support Android.


L. Spiro

Hi, L. Spiro,

Your reply is very usful. The Adreno, SGX have a good compatibility but Mali. I should pay more attention.

But this time is my fault. I am not read the opengl es spec carefully. Using UNSIGNED_INT cause this issue.

Thank you!!

" Using UNSIGNED_INT cause this issue."

Ah. Yes. That would do it. I missed that one.

"Mali400 shader compilers do not adhere to the OpenGL ES 2.0 standard"

If you find examples of how it doesn't, then I'll happily see if I can pass them on to the guys there to see about getting them fixed; but certainly in most of the cases I looked at, the claimed non-conformance was actually down to the Mali 400 system conforming very, very closely to the letter of the spec -- and the result is that things which happen to work on other chipsets don't work on Mali 400 (like this).

This topic is closed to new replies.

Advertisement