SIGSEGV in OpenGL fragment shader on Android device -


i have fragment shader in android app using gles 2.0 works fine on emulator crashes "fatal signal 11 (sigsegv) @ 0x00000004 (code=1)" on nexus 4 when try link shader program.

i started google's tutorial (http://developer.android.com/training/graphics/opengl/draw.html) , took there.

this vertex shader:

uniform mat4 umvpmatrix; varying vec2 vtexcoord; attribute vec4 vposition; void main() {   gl_position = umvpmatrix * vposition;   vtexcoord = vposition.xy * vec2(0.5) + vec2(0.5); } 

this fragment shader:

precision mediump float; uniform sampler2d utexture1; uniform sampler2d utexture2; uniform float pointx; uniform float pointy; uniform float opening; uniform float openingbufferzone; uniform vec4 acolor; varying vec2 vtexcoord; float sizex = 2048.0; float sizey = 512.0; void main() {   float x = (vtexcoord.x * sizex) - pointx;   float y = (vtexcoord.y * sizey) - pointy;   float distance = x * x + y * y;   if (distance < opening) {     gl_fragcolor = texture2d(utexture2, vtexcoord) * acolor;   } else {     if (distance >= opening && distance < opening + openingbufferzone) {       float inner = (distance-opening)/openingbufferzone;       vec4 c1 = (vec4(inner,inner,inner,1.0) * texture2d(utexture1, vtexcoord) * acolor);       vec4 c2 = (vec4(inner,inner,inner,1.0) * texture2d(utexture2, vtexcoord) * acolor);       gl_fragcolor = c1 + c2;     } else {       gl_fragcolor = texture2d(utexture1, vtexcoord) * acolor;     }   } } 

this how load shaders:

int vertexshader = glactivity.loadshader(gles20.gl_vertex_shader,                                                    vertexshadercode); int fragmentshader = glactivity.loadshader(gles20.gl_fragment_shader,                                                      fragmentshadercode); mprogram = gles20.glcreateprogram();              gles20.glattachshader(mprogram, vertexshader);    gles20.glattachshader(mprogram, fragmentshader);  gles20.gllinkprogram(mprogram);                   

the error occurs when trying execute last line gles20.gllinkprogram(mprogram);.

for reason these 2 lines in vertex shader seem cause trouble:

vec4 c1 = (vec4(inner,inner,inner,1.0) * texture2d(utexture1, vtexcoord) * acolor); vec4 c2 = (vec4(inner,inner,inner,1.0) * texture2d(utexture2, vtexcoord) * acolor); 

if change them

vec4 c1 = (vec4(inner,inner,inner,1.0) * texture2d(utexture1, vtexcoord) * acolor); vec4 c2 = (vec4(inner,inner,inner,1.0) * texture2d(utexture1, vtexcoord) * acolor); 

or

vec4 c1 = (vec4(inner,inner,inner,1.0) * texture2d(utexture2, vtexcoord) * acolor); vec4 c2 = (vec4(inner,inner,inner,1.0) * texture2d(utexture2, vtexcoord) * acolor); 

and leave else is, program runs fine (though not intended).

seems problem in nexus 4, facing. no solution yet. here links

https://developer.qualcomm.com/forum/qdevnet-forums/mobile-technologies/mobile-gaming-graphics-optimization-adreno/26868

https://developer.qualcomm.com/forum/qdevnet-forums/mobile-gaming-graphics-optimization-adreno/8791

https://developer.qualcomm.com/forum/qdevnet-forums/mobile-technologies/mobile-gaming-graphics-optimization-adreno/26868

https://developer.qualcomm.com/forum/qdevnet-forums/mobile-gaming-graphics-optimization-adreno/23990


Comments