Porting from GLES 1.0 to GLES 2.0

Hello everybody!

Recently I have begun porting my little Android game from Java + GLES 1.0 to C++ + GLES 2.0. My device is Samsung Galaxy S (GT-I9000 with  PowerVR SGX540).

Everything was going smoothly until I run into some blending performance issues. I believe that it’s a blending related problem because my drawing algorithms haven’t changed and my shaders are pretty simple. Also when I disable blending my performance jumps sky high (though graphics look terrible).

I didn’t have such problem when I was using GLES 1.0, I was able to push much, much, MUCH more blended geometry to GPU without much performance penalty. So my question is: are there any GLES 2.0 specific conditions under which blending can cause such performance loss? Some GLES states, some rendering surface parameters maybe? I’ve tried many things but with no success.

If it helps - those slowdowns occur in my particle engine and particles are rendered with following shaders:

Vertex shader:
attribute vec3 attrPosition;
attribute vec2 attrUV;
attribute float attrAlpha;

uniform mat4 uniModelViewProjectionMatrix;

varying vec2 varUV;
varying float varAlpha;

void main()
{
  gl_Position = uniModelViewProjectionMatrix * vec4(attrPosition, 1);
  varUV = attrUV;
  varAlpha = attrAlpha;
}[/CODE]
Fragment shader:
precision mediump float;<br><br>uniform sampler2D uniTexture;<br><br>varying vec2 varUV;<br>varying float varAlpha;<br><br>void main()<br>{<br>&nbsp; gl_FragColor = texture2D(uniTexture, varUV) * vec4(1, 1, 1, varAlpha);<br>}

But like I said - I don’t think that it is a shader related problem because when I turn off blending everything runs great. I use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); but changing it doesn’t help anything.

I would appreciate any ideas because I am running out of options here. Thanks. Smile

attribute vec3 attrPosition;<br>attribute vec2 attrUV;<br>attribute float attrAlpha;<br><br>uniform mat4 uniModelViewProjectionMatrix;<br><br>varying vec2 varUV;<br>varying float varAlpha;<br><br>void main()<br>{<br>&nbsp; gl_Position = uniModelViewProjectionMatrix * vec4(attrPosition, 1);<br>&nbsp; varUV = attrUV;<br>&nbsp; varAlpha = attrAlpha;<br>}
Fragment shader:
precision mediump float;

uniform sampler2D uniTexture;

varying vec2 varUV;
varying float varAlpha;

void main()
{
  gl_FragColor = texture2D(uniTexture, varUV) * vec4(1, 1, 1, varAlpha);
}[/CODE]

But like I said - I don’t think that it is a shader related problem because when I turn off blending everything runs great. I use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); but changing it doesn’t help anything.

I would appreciate any ideas because I am running out of options here. Thanks. Smile

precision mediump float;<br><br>uniform sampler2D uniTexture;<br><br>varying vec2 varUV;<br>varying float varAlpha;<br><br>void main()<br>{<br>&nbsp; gl_FragColor = texture2D(uniTexture, varUV) * vec4(1, 1, 1, varAlpha);<br>}

But like I said - I don’t think that it is a shader related problem because when I turn off blending everything runs great. I use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); but changing it doesn’t help anything.

I would appreciate any ideas because I am running out of options here. Thanks. Smile



Hi,

If the scene you are rendering is identical to your OpenGL ES 1.x scene, it sounds very strange that OpenGL ES 2.0 would incur a cost like this when blending is enabled. Are you drawing the same number of particles in both cases? Can you send .apks to devtech@imgtec.com with and without blending enabled so we can look into this for you?

Thanks,
Joe