Imagination PowerVR SDK Blog

Android shader compiler problem (GLSL, OGL2.0 ES)


#1

hello,



i have a shader that doesn’t compile on Android PVR devices. It’s relatively simple, and does compile without problems on iOS and non-PVR devices. It also works in the PVR SDK shader tool. The strange thing is, if i rearrange the source a little, it DOES compile on the device. Am i allowed to post the shader here?



thank you,

Balazs Vasvari



#2

Edit: the error message from the compiler is “compile failed”, nothing more. I’m using an Acer Iconia A1-810 (JB 4.2.2), but it does seem to affect all our users with PVR gpus. It also fails in the PVR SDK shader editor, if i change the compiler to SGX543 rev 2111. It also seems to be related to precision qualifiers, because if i change one of the “lowp” uniforms to “highp”, it works again.


#3

Hi,



Can you share the shader source with us?



Regards,

Joe


#4

Hi Joe,



thank you (try chaning uniform lowp vec4 material_modifier to mediump, and it compiles):



//


#define SG3D_ANDROID 1
#define SG3D_VARIATION0 1
//
// uniforms
uniform highp mat4 sg3d_world_matrix;
uniform highp mat4 sg3d_camera_matrix;
uniform highp mat4 sg3d_view_matrix;
uniform highp mat4 sg3d_viewproj_matrix;
uniform highp mat4 sg3d_proj_matrix;

// varyings
varying highp vec2 var_uv;
varying mediump vec4 var_color;
varying lowp vec4 var_fog;
//varying mediump vec3 var_normal;
//
uniform lowp vec4 object_marker;
uniform lowp vec4 material_modifier;
uniform lowp sampler2D SG3D_TEXTURE_DIFFUSE;
uniform lowp sampler2D SG3D_TEXTURE_OPACITY;
uniform lowp samplerCube SEP_TEXTURE_REFCUBE;



//
void main()
{
lowp vec3 mask=texture2D(SG3D_TEXTURE_OPACITY, var_uv).xyz;
lowp vec4 albedo_specular=texture2D(SG3D_TEXTURE_DIFFUSE, var_uv);
gl_FragColor.xyz = albedo_specular.xyz*var_color.xyz;
gl_FragColor.xyz = gl_FragColor.xyz*var_fog.w+var_fog.xyz;
gl_FragColor.xyz +=albedo_specular.rgb*clamp(mask.r+material_modifier.x, 0.0, 1.0);
gl_FragColor.xyz = mix(gl_FragColor.xyz, vec3(0.75, 0.75, 0.75), object_marker.w);
gl_FragColor.w = mask.g*var_color.w;
}

#5

Hi,



I’ve reproduced the error in our 3.1 SDK’s compiler. However, our latest reference driver’s compiler compiles it successfully.



Unfortunately, you’ll have to stick with the mediump workaround.



Regards,

Joe