Droid can't load fragment shader with discard




Hello,
 
Trying to load this shader:
 
Code:
#ifndef GL_ES
#define GL_ES
#endif
//GLSL
#extension GL_ARB_shader_texture_lod:enable
#extension GL_EXT_shader_texture_lod:enable
#ifdef GL_ES
precision lowp float;
precision lowp int;
#define texture2DLod texture2DLodEXT
#endif
#define COLOR 0
#define alpha_test 1
#ifdef GL_ES
#define HP highp
#define MP mediump
#define LP lowp
#else
#define HP
#define MP
#define LP
#endif
#define PAR uniform
#define VAR varying
#define EPS 0.0001
#define EPSL 0.01
#define PI 3.14159265
#define PI2 6.28318531
#define SBUMP_ZERO 0
#define SBUMP_FLAT 1
#define SBUMP_NORMAL 2
#define FX_NONE 0
#define FX_GRASS 1
#define FX_LEAF 2
#define FX_LEAFS 3
#define FX_BONE 4
#define Sat(x) clamp(x,0.0,1.0)
MP float Sum(MP vec2 v){return v.x+v.y;}
MP float Sum(MP vec3 v){return v.x+v.y+v.z;}
MP float Sum(MP vec4 v){return v.x+v.y+v.z+v.w;}
MP float Sqr(MP float x){return x*x;}
MP vec2 Sqr(MP vec2 x){return x*x;}
MP float Cube(MP float x){return x*x*x;}
MP float Length2(MP vec2 v){return dot(v,v);}
MP float Length2(MP vec3 v){return dot(v,v);}
MP float Length2(MP vec4 v){return dot(v,v);}
MP vec2 Rotate(MP vec2 vec,MP vec2 cos_sin)
{
return vec2(vec.x*cos_sin.x-vec.y*cos_sin.y,
vec.x*cos_sin.y+vec.y*cos_sin.x);
}
MP float LerpR(MP float from,MP float to,MP float v){return(v-from)/(to-from);}
MP float LerpRS(MP float from,MP float to,MP float v){return Sat((v-from)/(to-from));}
VAR HP vec2 IO_tex;
#if COLOR!=0
VAR LP vec4 IO_col;
#endif
#define AlphaTest(alpha) if(alpha+MaterialColor().a<1.0)discard
PAR sampler2D Col,Col1,Col2,Col3,
Nrm,Nrm1,Nrm2,Nrm3;
PAR samplerCube Rfl;
PAR MP float AllowBackFlip;
#define BackFlip(dir) {if(!gl_FrontFacing)dir*=AllowBackFlip;}
void main()
{
LP vec4 col=texture2D(Col,IO_tex);
#if alpha_test!=0
if(col.a<0.5)discard;
#endif
#if COLOR!=0
col*=IO_col;
#endif
gl_FragColor=col;
}
 
on Motorola Droid Bionic/Razr/Razr Maxx
results in following error
Quote:
Compile failed.
WARNING: 0:5: Extension GL_ARB_shader_texture_lod not supported
WARNING: 1 compilation warnings.
Problem is with 'discard', if I comment it out or set 'alpha_test' to 0 then it compiles fine.
 
The shader compiles fine though on PVRUniSCoEditor

Esenthel2012-07-12 23:46:09


After the issue with the discard not working on my customer's Motorola device, I asked him to run the
OGLES2AlphaTest.apk from SDK_OGLES2_ANDROID_ARMV7_REL_2.10@863987.tar.gz
Just now I received email from him, that the application starts loading, and then it's just black screen
Quote:
I am getting a spinning white thing(as most apps start) and all I see is black it doesnt close just black
 
I don't have motorola so I can't test it by myself, I'm just forwarding the log output generated from the customer, and his reply from the email.
 
Any help would be appreciated, thanks

Hi,

We’ve tested the .apk on a number of Android devices before we released but, unfortunately, the Droid RAZR was not one of these devices. Can you ask your customer for the Android version number and the GPU driver version number (can be retrieved with “adb shell cat /proc/pvr/version”)? This will make it easier for us to investigate the issue.

Thanks,
Joe



Hi,

I’ve been able to get my hands on a Droid RAZR running ICS. The SGX driver version is: 1.8@796887

On this device, the OGLES2AlphaTest.apk ran without any problems. I believe the ICS update for this device is quite recent though, so you customer may be running Gingerbread with older SGX drivers.

Thanks,
Joe





Hi,
 
Thanks a lot for the reply.
 
I am selling my game through Google Android Store ( https://play.google.com/store/apps/details?id=com.esenthel.rts ), so people who buy it usually have small or no knowledge about running the ADB shell commands or even access to it, which makes it difficult to solve the problem - when I email them asking for the information, they don't reply back.
 
But in the meantime, another person with Motorola contacted me about the same problem, he has "Motorola Droid Bionic", Android Version 2.3.4. I've googled and I learned that Droid Bionic has no software update for ICS available.
The person has the same problem of running the OGLES2AlphaTest.apk
and shader compilation from my first post with the "discard" keyword.
 
If it would help then I can send you free version (APK) of my game to your PM.


Another user contacted me with the problem.
Motorola Droid Bionic again, after asking to run the OGLES2AlphaTest.apk, I received his reply:
"It shows nothing. Just a black screen. But it stays on"

You can also query the driver version number on most platforms in GL with glGetString(GL_VERSION). You could add this to your own game or the OGLES2AlphaTest.apk to make it easier for users to retrieve the driver version number.

I’ve still not been able to find a device where I can replicate the issue on my end. If you can find out the driver version number, it will be easier for our driver team to investigate the issue.

Thanks,
Joe





Hello,
 
Thank you for the reply, I did send the test application to the person with the issue, but he has not replied since then.