This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The mathmatic computing result in Shader is not right for Mali 400mp

I'm using Mali 400mp for doing some mathmetic computing.But the result is not satisfying.

In my program, I put a float array A by using gluniforlfv() into the shader,and put a Image Texture B by using glTexImage2D() into the shader,use the values in A and values in B to do mathmatic computing.

I use Mali's parameter to se OpenGL ES2.0 environment:

    protected int redSize = 8;

    protected int greenSize = 8;

    protected int blueSize = 8;

    protected int alphaSize = 8;

    protected int depthSize = 16;

    protected int sampleSize = 4;

    protected int stencilSize = 0;

The txture parameter is:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

      ........

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,  texwidth, texheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);

The problem is :

Firstly, when I use gluniformlfv() to put a float array into the shader, the value in shader for computing is not the same as its real value.For example, if the value is 0.123456, however, in shader, the value is bigger or smaller in fact .So as other values.

Secondly, When I doing some computing in shader, it seems the result is not right for addition ,division etc. The result has some difference with the idealized mathmatic computing. I don't know why.  

Parents
  • Hi Autman,

    Are these calculations you are doing in a fragment shader?  If so you will need to bear in mind that the floating precision required by OpenGL ES fragment shaders is FP16.  This gives you roughly three decimal places of precision, so it may explain why you are not seeing as high a level of precision as the values you are putting into your float array.  The Mail400 GPU supports 16-bit float arithmetic in the fragment shaders - as required by the spec - and up to 24-bit float for texture lookups using values passed through unaltered from the vertex shader stage.

    Hope that helps,

    Tim

Reply
  • Hi Autman,

    Are these calculations you are doing in a fragment shader?  If so you will need to bear in mind that the floating precision required by OpenGL ES fragment shaders is FP16.  This gives you roughly three decimal places of precision, so it may explain why you are not seeing as high a level of precision as the values you are putting into your float array.  The Mail400 GPU supports 16-bit float arithmetic in the fragment shaders - as required by the spec - and up to 24-bit float for texture lookups using values passed through unaltered from the vertex shader stage.

    Hope that helps,

    Tim

Children