Shader doesn’t compile, but there’s no log

This topic contains 5 replies, has 2 voices, and was last updated by  todi1856 7 years ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #30290


    I have this fragment shader which doesn’t compile:

    I was trying to get compile log with glGetShaderInfoLog, but this only returns

    “Compile failed. ” and nothing more, so I can’t tell what is exactly wrong….

    #define FRAGMENT_P mediump

    #define IN_FRAGMENT_P mediump

    #define OUT_FRAGMENT_P mediump

    #define INOUT_FRAGMENT_P mediump

    #define SHADER_API_OGLES20 1

    #define tex2D texture2D

    #define highp_vec2 highp vec2

    #define mediump_vec2 mediump vec2

    #define lowp_vec2 lowp vec2

    #define highp_vec3 highp vec3

    #define mediump_vec3 mediump vec3

    #define lowp_vec3 lowp vec3

    #define highp_vec4 highp vec4

    #define mediump_vec4 mediump vec4

    #define lowp_vec4 lowp vec4

    #define highp_mat2 highp mat2

    #define mediump_mat2 mediump mat2

    #define lowp_mat2 lowp mat2

    #define highp_mat3 highp mat3

    #define mediump_mat3 mediump mat3

    #define lowp_mat3 lowp mat3

    #define highp_mat4 highp mat4

    #define mediump_mat4 mediump mat4

    #define lowp_mat4 lowp mat4

    #define highp_float highp float

    #define mediump_float mediump float

    #define lowp_float lowp float

    #define gl_TexCoord _glesTexCoord

    varying highp_vec4 _glesTexCoord[3];

    uniform highp_float _Treshold;

    uniform sampler2D _MainTex;

    void main ()


    FRAGMENT_P vec2 tmpvar_25[3];

    tmpvar_25[0] = gl_TexCoord[0].xy;

    tmpvar_25[1] = gl_TexCoord[1].xy;

    tmpvar_25[2] = gl_TexCoord[2].xy;

    FRAGMENT_P vec4 original;

    FRAGMENT_P vec4 tmpvar_13;

    tmpvar_13 = texture2D (_MainTex, tmpvar_25[0]);

    original = tmpvar_13;

    FRAGMENT_P vec3 tmpvar_20;

    tmpvar_20 = ((( * 2.0) – texture2D (_MainTex, tmpvar_25[1]).xyz) – texture2D (_MainTex, tmpvar_25[2]).xyz);

    FRAGMENT_P float tmpvar_21;

    tmpvar_21 = dot (tmpvar_20, tmpvar_20);

    if ((tmpvar_21 >= _Treshold)) {
 = vec3(0.0, 0.0, 0.0);


    gl_FragData[0] = original.xyzw;




    I’ve tried this shader with different OpenGL ES 2.0 GLSL compilator and it compiled fine, so this is something specific to IMGTEC OpenGL ES 2.0 GLSL compilator



    I compiled your shader using PVRUniSCo in our most recent SDK ( and it reported success so I’m not sure what’s going wrong with your compilation. What platform are you using and what version of drivers?

    It’s possible that the #defines that you have at the top of the file are causing the problem. We recommend that precision modifiers be applied per variable, if possible, as this can make a large difference to the performance of your shader. Have you tried compiling without the #defines?



    I was trying to compile it with Windows XP – OpenGL ES 2.0 (Build:

    What do you mean by ‘precision modifiers be applied per variable’, aren’t they applied that way in this shader, for ex., ‘FRAGMENT_P vec2 tmpvar_25[3];’

    Anyways… the shader is produced by a tool, and those defines are needed, because they’re a bit different depending for which platform they’re used, for ex., iPhone or Android, or something else



    We’ve managed to reproduce the problem in some of our shader validation code and the engineer responsible will have a look at it.

    In the shader above FRAGMENT_P is applied to every variable so they are all at the same precision (mediump in this case). Often cycles can be saved by setting variable precision on a case by case basis e.g.

    lowp vec4 color;
    mediump vec2 tex_coord;

    The same operations on variables with different precisions can often take different numbers of USSE cycles to process – an operation on a lowp vec4 variable may be achieved in a single cycle where the same operation on a highp vec4 could take more. When precisions are combined then any saving may be wiped out by the conversion overhead, however, so it can be tricky to take advantage of this.

    You can use PVRUniSCoEditor in the SDKPackage/Utilities folder to edit and debug shaders and get line-by-line cycle counts using an offline SGX compiler.

    Obviously, if you are generating these shaders by an automatic method, it will be difficult to fine-tune your shaders like this – but that’s what I meant by ‘precision modifiers be applied per variable’ Smile



    Thank you very much

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.