Stephane Hockenhull
Member
- Joined
- Sep 12, 2010
- Messages
- 282
Using vec3 instead of vec4, the scale2x code reach 125-130ms. Not usable (far from it) but interesting
current Fragment shader :
Code:precision mediump float; varying vec2 v_texCoord[5]; varying vec2 pos; uniform sampler2D s_texture0; uniform vec4 u_param; void main() { vec3 E = texture2D(s_texture0, v_texCoord[0]).xyz; vec3 D = texture2D(s_texture0, v_texCoord[1]).xyz; vec3 F = texture2D(s_texture0, v_texCoord[2]).xyz; vec3 H = texture2D(s_texture0, v_texCoord[3]).xyz; vec3 B = texture2D(s_texture0, v_texCoord[4]).xyz; vec2 p = fract(pos); vec3 tmp1 = p.x < 0.5 ? D : F; vec3 tmp2 = p.y < 0.5 ? H : B; vec3 tmp3 = D == F || H == B ? E : tmp1; gl_FragColor.xyz = tmp1 == tmp2 ? tmp3 : E; }
have you tried with
lowp vec3 E = ....
?
also, try moving p=fract(pos); to the top away from its first use
vec3 E = ...
could be at the bottom of the texture lookups to put more stuff between D,F,H,B first use
this may reduce data dependency stalls if the shader compiler doesn't reorder thing properly.
Code:
precision mediump float;
varying vec2 v_texCoord[5];
varying vec2 pos;
uniform sampler2D s_texture0;
uniform vec4 u_param;
void main()
{
lowp vec2 p = fract(pos); // away from its first use
lowp vec3 D = texture2D(s_texture0, v_texCoord[1]).xyz;
lowp vec3 F = texture2D(s_texture0, v_texCoord[2]).xyz;
lowp vec3 H = texture2D(s_texture0, v_texCoord[3]).xyz;
lowp vec3 B = texture2D(s_texture0, v_texCoord[4]).xyz;
lowp vec3 E = texture2D(s_texture0, v_texCoord[0]).xyz; // put H,B further away
lowp vec3 tmp1 = p.x < lowp 0.5 ? D : F;
lowp vec3 tmp2 = p.y < lowp 0.5 ? H : B;
lowp vec3 tmp3 = D == F || H == B ? E : tmp1;
gl_FragColor.xyz = tmp1 == tmp2 ? tmp3 : E;
}
Last edited by a moderator: