OpenGl Fragment Shader Texture Speed
I have the following fragment shader.
varying highp vec2 tCoord;
void main() {
vec4 hc = texture2D(hair, tCoord);
gl_FragColor = hc;
}
In my program, I am drawing around 15 images on the screen (only 2D, no 3D manipulation). I allow the all the image to be moved with a finger. So when the images are on the screen, I get 40 fps, but when I move them offscreen (with my finger), I get 60 fps. (This eliminates any bottle-neck in the program or the vertex shader). I am running this on a Galaxy Tab 7".
Since this is a very 开发者_如何学Csimple shader, I would expect 60 fps all the time. Any reason why this is slow?
highp
probably is not accelerated on embedded hardware such as most android devices. Does it help at all to use default precision? Why do you think you need so much precision for texture coordinates on a low-res screen?
i worked on a tegra platfrom with android 3.2.1 and opengl es 2.0.
if you can live without the need of the variable in between, try assigning directly. i experienced variable creation and assignment to be costly as 3-5 fps. texture2d also costs something in that range in fps.
varying highp vec2 tCoord;
void main() {
gl_FragColor = texture2D(hair, tCoord);
}
精彩评论