Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


DrawElements failed in Mali400


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 lj_archer   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 April 2013 - 02:47 AM

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.



Sponsor:

#2 Katie   Members   -  Reputation: 1375

Like
1Likes
Like

Posted 17 April 2013 - 03:02 AM

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.



#3 lj_archer   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 April 2013 - 03:59 AM

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~



#4 Katie   Members   -  Reputation: 1375

Like
1Likes
Like

Posted 17 April 2013 - 08:22 AM

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).


#5 adampetrone   Members   -  Reputation: 193

Like
1Likes
Like

Posted 17 April 2013 - 10:38 AM

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.



#6 L. Spiro   Crossbones+   -  Reputation: 14395

Like
1Likes
Like

Posted 17 April 2013 - 06:15 PM

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


Edited by L. Spiro, 17 April 2013 - 08:59 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#7 lj_archer   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 April 2013 - 08:01 PM

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~~



#8 lj_archer   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 April 2013 - 08:03 PM

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 !!!



#9 lj_archer   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 April 2013 - 08:09 PM

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!!



#10 Katie   Members   -  Reputation: 1375

Like
0Likes
Like

Posted 19 April 2013 - 06:24 AM

" 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).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS