Anton Petrov
Anton Petrov

Reputation: 973

OpenGL ES performance 2.0 vs 1.1 (iPad)

In my simple 2D game I have 2x framerate drop when using ES 2.0 implementation for drawing. Is it OK or 2.0 should be faster if used properly?

P.S. If you are interested in details. I use very simple shaders:

vertex program:

uniform   vec2  u_xyscale;
uniform   vec2  u_st_to_uv;

attribute vec2  a_vertex;
attribute vec2  a_texcoord; 
attribute vec4  a_diffuse;

varying   vec4  v_diffuse;
varying   vec2  v_texcoord;

void main(void)
{
    v_diffuse  = a_diffuse;

    // convert texture coordinates from ST space to UV.
    v_texcoord = a_texcoord * u_st_to_uv;

    // transform XY coordinates from screen space to clip space.
    gl_Position.xy = a_vertex * u_xyscale + vec2( -1.0, 1.0 );
    gl_Position.zw = vec2( 0.0, 1.0 );
}

fragment program:

precision mediump float;

uniform sampler2D   t_bitmap;

varying lowp vec4   v_diffuse;
varying vec2        v_texcoord;

void main(void)
{
    vec4 color = texture2D( t_bitmap, v_texcoord );

    gl_FragColor = v_diffuse * color;
}

Upvotes: 2

Views: 782

Answers (1)

Frogblast
Frogblast

Reputation: 1681

"color" is a mediump variable, due to the default precision that you specified. This forces the implementation to convert the lowp sampled result to mediump. It also requires that diffuse be converted to mediump to perform the multiplication.

You can fix this by declaring "color" as lowp.

Upvotes: 1

Related Questions