# Shader doesn't compile, but there's no log

**URL:** <https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843>\
**Category:** PowerVR Insider\
**Created:** [September 27, 2010, 1:41pm UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843 "2010-09-27T13:41:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 27, 2010, 1:41pm UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/1 "2010-09-27T13:41:33Z")

</div>

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 = (((tmpvar\_13.xyz \* 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)) {_  
  
   
_&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;original.xyz = vec3(0.0, 0.0, 0.0);_  
  
   
 _};_  
  
   
 _gl\_FragData[0] = original.xyzw;_  
  
   
_}_

---

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 27, 2010, 1:48pm UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/2 "2010-09-27T13:48:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GordonMaclachlan](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@GordonMaclachlan](https://forums.imgtec.com/u/GordonMaclachlan)\
**Post date:** [September 28, 2010, 8:33am UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/3 "2010-09-28T08:33:50Z")

</div>

I compiled your shader using PVRUniSCo in our most recent SDK (2.07.27.0484) 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?

---

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 29, 2010, 12:45pm UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/4 "2010-09-29T12:45:30Z")

</div>

I was trying to compile it with Windows XP - OpenGL ES 2.0 (Build: 2.07.27.0484)  
  
  
  
  
  
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

---

<div class="post-metadata">

**Author:** ![GordonMaclachlan](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@GordonMaclachlan](https://forums.imgtec.com/u/GordonMaclachlan)\
**Post date:** [September 30, 2010, 11:13am UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/5 "2010-09-30T11:13:28Z")

</div>

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.

Code:

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'&nbsp; ![Smile]()

---

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 30, 2010, 12:18pm UTC](https://forums.imgtec.com/t/shader-doesnt-compile-but-theres-no-log/843/6 "2010-09-30T12:18:57Z")

</div>

Thank you very much
