# compile error

**URL:** <https://forums.imgtec.com/t/compile-error/1299>\
**Category:** PowerVR Insider\
**Tags:** pvrtrace\
**Created:** [February 2, 2012, 9:21am UTC](https://forums.imgtec.com/t/compile-error/1299 "2012-02-02T09:21:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 2, 2012, 9:21am UTC](https://forums.imgtec.com/t/compile-error/1299/1 "2012-02-02T09:21:18Z")

</div>

Hello.  
  
  
I got a compile error on Galaxy S.  
  
  
This shader works fine on Tegra2, Adreno200,205,220,Mali-400M.  
  
  
Why doesn’t it work on PowerVR SGX540?  
  
  
  
  
  
However, I removed this line:  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#define USE\_HWSKINNING 1  
  
  
It works fine on Galaxy S.  
  
  
  
  
  
Sample APK(This apk doesn’t work on Galaxy S)  
  
  
[http://chototsumoushinp.dip.jp/miku/download/AndroidSample\_tinyar-112beta1.apk](http://chototsumoushinp.dip.jp/miku/download/AndroidSample_tinyar-112beta1.apk)  
  
  
  
  
  
Release version(This apk works on Galaxy S, but it’s slow because GLSL skinning is disabled).  
  
  
[https://market.android.com/details?id=jp.co.pscnet.mms.tinyar](https://market.android.com/details?id=jp.co.pscnet.mms.tinyar)  
  
  
  
  
  
Thanks.

* * *
  
#define COLORRAMP 1  
  
#define DIFFUSEMAP 1  
  
#define MATERIAL\_COLORS 1  
  
#define NUM\_BONES 20  
  
#define USE\_HWSKINNING 1  
  
#define VERTEX\_LIGHTING 1  
  
// #import "MatDefs/pmd/Skinning.glsllib"  
  
#ifdef USE\_HWSKINNING  
  
uniform mat4 m\_BoneMatrices[NUM\_BONES];  
  
#endif  
  
#define ATTENUATION  
  
// #define HQ\_ATTENUATION  
  
  
  
uniform mat4 g\_WorldViewProjectionMatrix;  
  
uniform mat4 g\_WorldViewMatrix;  
  
uniform mat3 g\_NormalMatrix;  
  
uniform mat4 g\_ViewMatrix;  
  
  
  
uniform vec4 m\_Ambient;  
  
uniform vec4 m\_Diffuse;  
  
uniform vec4 m\_Specular;  
  
uniform float m\_Shininess;  
  
  
  
uniform vec4 g\_LightColor;  
  
uniform vec4 g\_LightPosition;  
  
uniform vec4 g\_AmbientLightColor;  
  
  
  
varying vec2 texCoord;  
  
  
  
varying vec4 AmbientSum;  
  
varying vec4 DiffuseSum;  
  
varying vec4 SpecularSum;  
  
  
  
attribute vec3 inPosition;  
  
attribute vec2 inTexCoord;  
  
attribute vec3 inNormal;  
  
  
  
// uniform Sampler2D m\_BoneParameter;  
  
// uniform sampler2D m\_BoneParameter;  
  
  
  
#ifdef HQ\_ATTENUATION  
  
 varying vec3 lightVec;  
  
#endif  
  
  
  
#ifdef VERTEX\_COLOR  
  
 attribute vec4 inColor;  
  
#endif  
  
  
  
#ifndef VERTEX\_LIGHTING  
  
 attribute vec4 inTangent;  
  
  
  
 #ifndef NORMALMAP  
  
&nbsp;&nbsp;&nbsp;&nbsp;varying vec3 vNormal;  
  
 #endif  
  
 varying vec3 vPosition;  
  
 varying vec3 vViewDir;  
  
 varying vec4 vLightDir;  
  
#endif  
  
  
  
// #ifdef USE\_REFLECTION  
  
&nbsp;&nbsp;&nbsp;&nbsp;uniform vec3 g\_CameraPosition;  
  
&nbsp;&nbsp;&nbsp;&nbsp;uniform mat4 g\_WorldMatrix;  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;uniform vec3 m\_FresnelParams;  
  
&nbsp;&nbsp;&nbsp;&nbsp;varying vec4 refVec;  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;/\*\*  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Input:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* attribute inPosition  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* attribute inNormal  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* uniform g\_WorldMatrix  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* uniform g\_CameraPosition  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\*  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* Output:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\* varying refVec  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\*/  
  
&nbsp;&nbsp;&nbsp;&nbsp;void computeRef(in vec4 position, in vec4 normal){  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vec3 worldPos = (g\_WorldMatrix \* vec4(normalize(position.xyz),1.0)).xyz;  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vec3 I = normalize( g\_CameraPosition - worldPos ).xyz;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vec3 N = normalize( (g\_WorldMatrix \* vec4(normalize(normal.xyz), 0.0)).xyz );  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; refVec.xyz = reflect(I, N);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; refVec.w&nbsp;&nbsp;&nbsp;= 1.0;//m\_FresnelParams.x + m\_FresnelParams.y \* pow(1.0 + dot(I, N), m\_FresnelParams.z);  
  
&nbsp;&nbsp;&nbsp;&nbsp;}  
  
// #endif  
  
  
  
// JME3 lights in world space  
  
void lightComputeDir(in vec3 worldPos, in vec4 color, in vec4 position, out vec4 lightDir){  
  
&nbsp;&nbsp;&nbsp;&nbsp;float posLight = step(0.5, color.w);  
  
&nbsp;&nbsp;&nbsp;&nbsp;vec3 tempVec = position.xyz \* sign(posLight - 0.5) - (worldPos \* posLight);  
  
&nbsp;&nbsp;&nbsp;&nbsp;#ifdef ATTENUATION  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float dist = length(tempVec);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightDir.w = clamp(1.0 - position.w \* dist \* posLight, 0.0, 1.0);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightDir.xyz = tempVec / vec3(dist);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#ifdef HQ\_ATTENUATION  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightVec = tempVec;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
&nbsp;&nbsp;&nbsp;&nbsp;#else  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightDir = vec4(normalize(tempVec), 1.0);  
  
&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
}  
  
  
  
#ifdef VERTEX\_LIGHTING  
  
 float lightComputeDiffuse(in vec3 norm, in vec3 lightdir){  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return max(0.0, dot(norm, lightdir));  
  
 }  
  
  
  
 float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#ifndef LOW\_QUALITY  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vec3 H = (viewdir + lightdir) \* vec3(0.5);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return pow(max(dot(H, norm), 0.0), shiny);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#else  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0.0;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
 }  
  
  
  
vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec4 wvLightPos){  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vec4 lightDir;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightComputeDir(wvPos, g\_LightColor, wvLightPos, lightDir);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float diffuseFactor = lightComputeDiffuse(wvNorm, lightDir.xyz);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, lightDir.xyz, m\_Shininess);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//specularFactor \*= step(0.01, diffuseFactor);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return vec2(diffuseFactor, specularFactor) \* vec2(lightDir.w);  
  
 }  
  
#endif  
  
attribute vec4 inBoneWeight;  
  
attribute vec4 inBoneIndices;  
  
attribute vec4 inBoneIndex;  
  
#ifdef USE\_HWSKINNING  
  
void Skinning\_Compute(inout vec4 position, inout vec4 normal){  
  
//&nbsp;&nbsp;&nbsp;&nbsp;vec4 index = inBoneIndices;  
  
&nbsp;&nbsp;&nbsp;&nbsp;vec4 index = inBoneIndex;  
  
&nbsp;&nbsp;&nbsp;&nbsp;vec4 weight = inBoneWeight;  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;vec4 newPos&nbsp;&nbsp;&nbsp;&nbsp;= vec4(0.0,0.0,0.0,0.0);  
  
&nbsp;&nbsp;&nbsp;&nbsp;vec4 newNormal = vec4(0.0,0.0,0.0,0.0);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;//for (float i = 1.0; i \< 2.0; i += 1.0){  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mat4 skinMat = m\_BoneMatrices[int(index.x)];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPos&nbsp;&nbsp;&nbsp;&nbsp;= weight.x \* (skinMat \* position);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newNormal = weight.x \* (skinMat \* normal);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //index = index.yzwx;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //weight = weight.yzwx;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; skinMat = m\_BoneMatrices[int(index.y)];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newPos&nbsp;&nbsp;&nbsp;&nbsp;= newPos + weight.y \* (skinMat \* position);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newNormal = newNormal + weight.y \* (skinMat \* normal);  
  
&nbsp;&nbsp;&nbsp;&nbsp;//}  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;position = newPos;  
  
&nbsp;&nbsp;&nbsp;&nbsp;normal = newNormal;  
  
}  
  
#endif  
  
void main(){  
  
&nbsp;&nbsp;&nbsp;vec4 pos = vec4(inPosition, 1.0);  
  
&nbsp;&nbsp;&nbsp;vec4 normal = vec4(inNormal,0.0);  
  
#ifdef USE\_HWSKINNING  
  
&nbsp;&nbsp;&nbsp;Skinning\_Compute(pos, normal);  
  
#endif  
  
//&nbsp;&nbsp;&nbsp;&nbsp;pos = m\_BoneMatrices[0] \* pos;  
  
&nbsp;&nbsp;&nbsp;gl\_Position = g\_WorldViewProjectionMatrix \* pos;  
  
&nbsp;&nbsp;&nbsp;texCoord = inTexCoord;  
  
  
  
&nbsp;&nbsp;&nbsp;vec3 wvPosition = (g\_WorldViewMatrix \* pos).xyz;  
  
&nbsp;&nbsp;&nbsp;vec3 wvNormal = normalize(g\_NormalMatrix \* normal.xyz);  
  
  
  
//&nbsp;&nbsp;&nbsp;vec3 wvPosition = (g\_WorldViewMatrix \* pos).xyz;  
  
//&nbsp;&nbsp;&nbsp;vec3 wvNormal = normalize(g\_NormalMatrix \* inNormal);  
  
  
  
&nbsp;&nbsp;&nbsp;vec3 viewDir = normalize(-wvPosition);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//vec4 lightColor = g\_LightColor[gl\_InstanceID];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//vec4 lightPos&nbsp;&nbsp;&nbsp;= g\_LightPosition[gl\_InstanceID];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//vec4 wvLightPos = (g\_ViewMatrix \* vec4(lightPos.xyz, lightColor.w));  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//wvLightPos.w = lightPos.w;  
  
  
  
&nbsp;&nbsp;&nbsp;vec4 wvLightPos = (g\_ViewMatrix \* vec4(g\_LightPosition.xyz, g\_LightColor.w));  
  
&nbsp;&nbsp;&nbsp;wvLightPos.w = g\_LightPosition.w;  
  
&nbsp;&nbsp;&nbsp;vec4 lightColor = g\_LightColor;  
  
  
  
&nbsp;&nbsp;&nbsp;#if defined(NORMALMAP) && !defined(VERTEX\_LIGHTING)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vec3 wvTangent = normalize(g\_NormalMatrix \* inTangent.xyz);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vec3 wvBinormal = cross(wvNormal, wvTangent);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mat3 tbnMat = mat3(wvTangent, wvBinormal \* -inTangent.w,wvNormal);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vPosition = wvPosition \* tbnMat;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vViewDir = viewDir \* tbnMat;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vLightDir.xyz = (vLightDir.xyz \* tbnMat).xyz;  
  
&nbsp;&nbsp;&nbsp;#elif !defined(VERTEX\_LIGHTING)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vNormal = wvNormal;  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vPosition = wvPosition;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vViewDir = viewDir;  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#ifdef V\_TANGENT  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vNormal = normalize(g\_NormalMatrix \* inTangent.xyz);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vNormal = -cross(cross(vLightDir.xyz, vNormal), vNormal);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
&nbsp;&nbsp;&nbsp;#endif  
  
  
  
&nbsp;&nbsp;&nbsp;lightColor.w = 1.0;  
  
&nbsp;&nbsp;&nbsp;#ifdef MATERIAL\_COLORS  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AmbientSum = m\_Ambient \* g\_AmbientLightColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DiffuseSum = m\_Diffuse \* lightColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SpecularSum = m\_Specular \* lightColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;#else  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AmbientSum = vec4(0.2, 0.2, 0.2, 1.0) \* g\_AmbientLightColor; // Default: ambient color is dark gray  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DiffuseSum = lightColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SpecularSum = lightColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;#ifdef VERTEX\_COLOR  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AmbientSum \*= inColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DiffuseSum \*= inColor;  
  
&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;#ifdef VERTEX\_LIGHTING  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vec2 light = computeLighting(wvPosition, wvNormal, viewDir, wvLightPos);  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AmbientSum.a = light.x;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SpecularSum.a = light.y \* 0.3;  
  
&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;#if defined(USE\_REFLECTION) || defined(SPHERE\_MAP\_A) || defined(SPHERE\_MAP\_H)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; computeRef(pos,normal);  
  
&nbsp;&nbsp;&nbsp;&nbsp;#endif  
  
}  
  

* * *
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 2, 2012, 11:07am UTC](https://forums.imgtec.com/t/compile-error/1299/2 "2012-02-02T11:07:59Z")

</div>

This shader works on Galaxy NEXUS.  
  
  
However it doesn’t work on Galaxy S, EPSON MOVERIO, FUJITSU ARROWS X.  
  
  
Why does the compile error happen?  
  
  
How should I fix it?  
  
  
  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 2, 2012, 4:09pm UTC](https://forums.imgtec.com/t/compile-error/1299/3 "2012-02-02T16:09:15Z")

</div>

Hi,  
  
  
Just to let you know that we are currently investigating this issue and we’ll keep you updated if we find anything out.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 2, 2012, 10:44pm UTC](https://forums.imgtec.com/t/compile-error/1299/4 "2012-02-02T22:44:22Z")

</div>

Hi, Arron.  
  
  
Thank you for your quick reply.  
  
  
I send all source code to you if you need.  
  
  
This is an open source product.  
  
  
  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 9:17am UTC](https://forums.imgtec.com/t/compile-error/1299/5 "2012-02-03T09:17:37Z")

</div>

Hi chototsu.  
  
  
If you could send the source that would be great. Please send a zipped package to [devtech@imgtec.com](mailto:devtech@imgtec.com).

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 10:03am UTC](https://forums.imgtec.com/t/compile-error/1299/6 "2012-02-03T10:03:47Z")

</div>

Hi chototsu.  
  
  
  
  
  
We may have found the problem. It seems that the statement “precision mediump float;” is being prepended to your vertex shader. This seems to have some issues on the Galaxy S & Nexus S.  
  
  
  
  
  
Although your vertex shader doesn’t actually contain this declaration, it seems as though your shader loading code is adding the line and causing the issue.  
  
  
  
  
  
If you can track this down and perhaps retest the application with this line removed it may work.  
  
  
  
  
  
Regards.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 2:42pm UTC](https://forums.imgtec.com/t/compile-error/1299/7 "2012-02-03T14:42:24Z")

</div>

Hi, Arron.  
  
  
\> your shader loading code is adding the line  
  
  
Sorry, I forgot it.  
  
  
I changed my renderer code and build my app.  
  
  
[http://chototsumoushinp.dip.jp/miku/download/AndroidSample\_tinyar-112beta3.apk](http://chototsumoushinp.dip.jp/miku/download/AndroidSample_tinyar-112beta3.apk)  
  
  
(However, I don’t yet test it because I don’t have Galaxy S.)  
  
  
  
  
  
Thank you very much.  
  
  
  
  
  
OGLESShaderRenderer.java:  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (source.getType().equals(ShaderType.Vertex)  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; && GLES20.glGetString(GLES20.GL\_RENDERER).indexOf(“PowerVR”)\>=0) {  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GLES20.glShaderSource(  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id,  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;source.getDefines()  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ source.getSource());  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GLES20.glShaderSource(  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id,  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“precision mediump float;n”  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ source.getDefines()  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ source.getSource());  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 3:25pm UTC](https://forums.imgtec.com/t/compile-error/1299/8 "2012-02-03T15:25:44Z")

</div>

Hi chototsu,  
  
  
This no longer fails to compile so that problem is solved :).  
  
  
  
  
  
However, on our Galaxy S the application runs very, very slow - around 4-5fps. This appears to be due to very high CPU load.Arron2012-02-03 16:26:15

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 3:36pm UTC](https://forums.imgtec.com/t/compile-error/1299/9 "2012-02-03T15:36:15Z")

</div>

Thank you for test my app.  
  
  
\> However, on our Galaxy S the application runs very, very slow  
  
  
Which of release version or 112beta3 is faster?  
  
  
  
  
  
On my test machine(ASUS TF101 Tegra2), it’s same frame rate as release version.  
  
  
  
  
  
(Don’t select Megurine Luka models because it’s too heavy for Galaxy S.  
  
  
 Please select Miku model.)  
  
  
  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 3:45pm UTC](https://forums.imgtec.com/t/compile-error/1299/10 "2012-02-03T15:45:27Z")

</div>

Old version of my app runs around 25fps on Galaxy S.  
  
  
It uses GLSL skinning.  
  
  
It works fine.  
  
  
However, I updated to new version, it didn’t work on Galaxy S.  
  
  
I didn’t change my shader.  
  
  
I am confused very much.  
  
  
It runs around 25fps on Galaxy S if GLSL skinning works.  
  
  
  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 4:07pm UTC](https://forums.imgtec.com/t/compile-error/1299/11 "2012-02-03T16:07:06Z")

</div>

Hi chototsu,  
  
  
  
  
  
I have downloaded your release app and can confirm that 112beta3 runs faster than the released version. I assume this is because you have now enabled HW skinning?  
  
  
  
  
  
I believe I was using the Miku model, but I cannot find a way to switch models.  
  
  
  
  
  
Regards.Arron2012-02-03 17:07:47

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 4:18pm UTC](https://forums.imgtec.com/t/compile-error/1299/12 "2012-02-03T16:18:02Z")

</div>

Thank you for test.  
  
  
\> I assume this is because you have now enabled HW skinning?  
  
  
Yes, 112beta3 uses GLSL skinning.  
  
  
However, I head that old version(uses GLSL skinning) runs around 25 fps on Galaxy S from users.  
  
  
My app runs around 40fps on TF101(Tegra2).  
  
  
4-5fps is too slow…  
  
  
I don’t understand the cause.  
  
  
  
  
  
\> I believe I was using the Miku model, but I cannot find a way to switch models.  
  
  
Please push menu button.  
  
  
(Default model is Miku, you don’t need to change model.)  
  
  
  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 4:45pm UTC](https://forums.imgtec.com/t/compile-error/1299/13 "2012-02-03T16:45:20Z")

</div>

Hi chototsu.  
  
  
I’m not really sure. I’ve profiled your app with our internal tools and can see that the GPU does very little work, while the CPU is fully loaded. There’s approximately a 200ms gap between a GPU calls.  
  
  
  
  
  
The app runs well (40-50fps+) on a Galaxy Nexus which is also an SGX540 although clocked higher, so I do not think that the issue is with the graphics hardware.  
  
  
  
  
  
Your other models vary with speed - some run around 17-20fps while as you say Megurine Luka runs very very slow.  
  
  
  
  
  
I’ll continue profiling your application next week and I’ll update this post if I find any more information which may be of use.  
  
  
  
  
  
Best regards.Arron2012-02-03 18:00:56

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 5:00pm UTC](https://forums.imgtec.com/t/compile-error/1299/14 "2012-02-03T17:00:22Z")

</div>

\> I do not think that the issue is with the graphics hardware.  
  
  
OK.  
  
  
I investigate My app code.  
  
  
  
  
  
Thank you for your kindness.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 3, 2012, 5:01pm UTC](https://forums.imgtec.com/t/compile-error/1299/15 "2012-02-03T17:01:17Z")

</div>

You’re welcome.  
  
  
  
  
  
One thing I have noticed is that you seem to call glGetError a lot (317 times per frame). This should be disabled in release code as that number of calls may affect performance.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 3, 2012, 5:08pm UTC](https://forums.imgtec.com/t/compile-error/1299/16 "2012-02-03T17:08:41Z")

</div>

I try it.  
  
  
Thanks.

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 6, 2012, 10:01am UTC](https://forums.imgtec.com/t/compile-error/1299/17 "2012-02-06T10:01:38Z")

</div>

Hi again chototsu,  
  
  
I’ve been looking at your application again and have a few recommendations which may improve performance:  
  
  
  
  
  
\* Your shaders use default high precision for every floating point type. This is not optimal and variables such as colour types could be stored as low precision instead. This should improve performance for vertex-heavy processing such as your application.  
  
  
  
  
  
\* You have lots of redundant GL calls to functions glTexParameteri and glVertexAttribPointer. glTexParameteri only needs to be called when a texture is first loaded and bound if it does not need to change parameters again in future frames which I believe yours don’t. Your calls to glVertexAttribPointer always seem to contain the same parameters so this could be set at the beginning of the first frame and used for each mesh sub-component.  
  
  
  
  
  
\* Your mesh data is not interleaved. Interleaving mesh data will reduce the number of required vertex buffer objects and allow the graphics hardware to read the data more efficiently.  
  
  
  
  
  
\* You have a large number of vertex buffer objects. If you could possibly reduce this amount by combining the mesh sub objects in to fewer, larger arrays and instead use offsets in to the buffers when you wish to draw individual components.  
  
  
  
  
  
\* You seem to pass a lot of redundant bone transformation data to the vertex shader. It looks like you pass 20 4x4 matrices for each mesh sub-component even if all the matrices are identical. It would be more optimal to control the amount of matrices that you pass using the _count_ parameter of glUniformMatrix4f such that you only pass the exact number of required matrices.  
  
  
  
  
  
By the way, have you tried your application with the glGetError’s removed? This should also provide a performance gain.  
  
  
I also recommend taking a look at our [performance recommendation guidelines](https://www.imgtec.com/powervr/insider/docs/PowerVR%20Series5%20Graphics.SGX%20architecture%20guide%20for%20developers.1.0.8.External.pdf).  
  
  
  
  
  
Best regards.  
  
  
Arron2012-02-06 11:03:59

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 9, 2012, 10:31pm UTC](https://forums.imgtec.com/t/compile-error/1299/18 "2012-02-09T22:31:59Z")

</div>

Hi, sorry for my late answer.  
  
  
I will try your advice this weekend.  
  
  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 12, 2012, 10:15am UTC](https://forums.imgtec.com/t/compile-error/1299/19 "2012-02-12T10:15:39Z")

</div>

Hi,  
  
  
I tried your advice.  
  
  
\> colour types could be stored as low precision instead.  
  
  
I changed color types into lowp.  
  
  
  
  
  
\> You have lots of redundant GL calls to functions glTexParameteri and glVertexAttribPointer.  
  
  
I removed glTexParameteri which was unnecessary.  
  
  
However glVertexAttribPointer are not same(offset, stride), I can’t remove them.  
  
  
  
  
  
\> Your mesh data is not interleaved.  
  
  
\> You have a large number of vertex buffer objects.  
  
  
I combined meshes and I changed them into interleaved.  
  
  
  
  
  
\> You seem to pass a lot of redundant bone transformation data to the vertex shader.  
  
  
I reduced matrix4 arrays.  
  
  
  
  
  
\> By the way, have you tried your application with the glGetError’s removed?  
  
  
Yes, I do.  
  
  
  
  
  
By these improvement, performance improved approximately 10%.  
  
  
  
  
  
[http://chototsumoushinp.dip.jp/miku/download/AndroidSample\_tinyar-114beta2.apk](http://chototsumoushinp.dip.jp/miku/download/AndroidSample_tinyar-114beta2.apk)  
  
  
  
  
  
Many thanks.

---

<div class="post-metadata">

**Author:** ![chototsu](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@chototsu](https://forums.imgtec.com/u/chototsu)\
**Post date:** [February 12, 2012, 8:55pm UTC](https://forums.imgtec.com/t/compile-error/1299/20 "2012-02-12T20:55:26Z")

</div>

I tested version 1.14 on Galaxy NEXUS, MOVERIO, Transformer TF101.  
  
  
It works, but it doesn’t work on GALAXY SII.  
  
  
I removed this version.

[Next page](https://forums.imgtec.com/t/compile-error/1299.md?page=2)
