Forums - shader compilation crash

5 posts / 0 new
Last post
shader compilation crash
johan1
Join Date: 15 Jul 15
Location: Belgium
Posts: 2
Posted: Wed, 2015-07-15 01:57

Android phones with an Adreno 420/430 generate crashes when trying to compile a shader that works fine on other phones.

Investigating the crashing fragment shader shows that using gl_FragCoord causes the issue. If we remove gl_FragCoord occurences, compilation goes fine.

A demo APK that works on e.g. Nexus 5 and fails on e.g. Nexus 6 is here: http://download.gluonhq.com/tmp/HelloGluon.apk

This is also reported on the JavaFX-Android issue tracker at  https://bitbucket.org/javafxports/javafxmobile-plugin/issues/28/lollipop-51-and-error-with-gradient and discussed on the OpenJFX mailing list at http://mail.openjdk.java.net/pipermail/openjfx-dev/2015-July/017578.html

I saw similar reports on this forum, but I didn't see a link to the usage of gl_FragCoord yet.

The relevant log info:

F/libc    (28382): Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc in tid 28406 (QuantumRenderer)^M
I/DEBUG   (  354): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***^M
I/DEBUG   (  354): Build fingerprint: 'google/shamu/shamu:5.1.1/LMY47Z/1860966:user/release-keys'^M
I/DEBUG   (  354): Revision: '33696'^M
I/DEBUG   (  354): ABI: 'arm'^M
I/DEBUG   (  354): pid: 28382, tid: 28406, name: QuantumRenderer  >>> com.hellogluon <<<^M
I/DEBUG   (  354): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xc^M
I/DEBUG   (  354):     r0 00000000  r1 aa9ba96b  r2 00000000  r3 ffffffff^M
I/DEBUG   (  354):     r4 9e3fdabc  r5 aec99cf0  r6 9e3f77f8  r7 00000014^M
I/DEBUG   (  354):     r8 aec99d04  r9 aaaf4b8b  sl ffffffde  fp 9e3f7a10^M
I/DEBUG   (  354):     ip aab235a8  sp 9e3f77e0  lr aaa09205  pc aaa09218  cpsr 60070030^M
I/DEBUG   (  354): ^M
I/DEBUG   (  354): backtrace:^M
I/DEBUG   (  354):     #00 pc 005bb218  /system/vendor/lib/libllvm-glnext.so (TParseContext::handleIdentifier(TSymbol*, llvm::StringRef const&, int)+275)^M
I/DEBUG   (  354):     #01 pc 005d727d  /system/vendor/lib/libllvm-glnext.so (yy2parse(TParseContext&)+972)^M
I/DEBUG   (  354):     #02 pc 005dcd3d  /system/vendor/lib/libllvm-glnext.so (yy2PaYYParse(TParseContext&)+16)^M
I/DEBUG   (  354):     #03 pc 005e481d  /system/vendor/lib/libllvm-glnext.so (YYParser::ParseStrings(char**, long*, int, TParseContext&, int)+276)^M
I/DEBUG   (  354):     #04 pc 005b305b  /system/vendor/lib/libllvm-glnext.so (ShCompile+1326)^M
I/DEBUG   (  354):     #05 pc 00552399  /system/vendor/lib/libllvm-glnext.so (LLVMCompiler::parse(QGLC_SRCSHADER*)+1188)^M
I/DEBUG   (  354):     #06 pc 005557ed  /system/vendor/lib/libllvm-glnext.so (CompilerContext::CompileToIRShader(QGLC_SRCSHADER*, QGLC_COMPILETOIR_RESULT*)+168)^M
I/DEBUG   (  354):     #07 pc 00105903  /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShaderCompiler::CompileShader(EsxContext const*, EsxShader const*, EsxInfoLog*)+526)^M
I/DEBUG   (  354):     #08 pc 00103ced  /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShader::Compile(EsxContext*)+72)^M
I/DEBUG   (  354):     #09 pc 000b2201  /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::GlCompileShader(unsigned int)+60)^M
I/DEBUG   (  354):     #10 pc 000e4ef9  /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlCompileShader(EsxDispatch*, unsigned int)+40)^M
I/DEBUG   (  354):     #11 pc 000a947d  /system/vendor/lib/egl/libGLESv2_adreno.so (glCompileShader+44)^M
I/DEBUG   (  354):     #12 pc 00005729  /data/app/com.hellogluon-1/lib/arm/libprism_es2_monocle.so (Java_com_sun_prism_es2_GLContext_nCompileShader+112)^M
I/DEBUG   (  354):     #13 pc 005192dd  /data/dalvik-cache/arm/data@app@[email protected]@classes.dex^M
W/ActivityManager(  804):   Force finishing activity 1 com.hellogluon/javafxports.android.FXActivity^M
 

 

  • Up0
  • Down0
anchor
Join Date: 11 Jun 15
Posts: 3
Posted: Wed, 2015-07-22 08:35

i can confirm this bug is exist with snapdragon 805&810 (adreno 420&430). certain shader compilation causes crash, but on all other gpu's works fine.


06-08 16:41:07.327 353 353 I DEBUG : backtrace: 06-08 16:41:07.327 353 353 I DEBUG : #00 pc 005955a8 /system/vendor/lib/libllvm-glnext.so (LLVMIRGen::checkBinaryOperands(Operand*, Operand*, llvm::OwningPtr<QInstruction>&, llvm::OwningPtr<QInstruction>&, bool&, llvm::BasicBlock*, llvm::BasicBlock*)+283) 06-08 16:41:07.327 353 353 I DEBUG : #01 pc 0059586d /system/vendor/lib/libllvm-glnext.so (LLVMIRGen::generateBinary(Operand*, Operand*, TOperator, bool, int)+344) 06-08 16:41:07.327 353 353 I DEBUG : #02 pc 0057f0cd /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseBinaryNode(TIntermBinary*)+568) 06-08 16:41:07.327 353 353 I DEBUG : #03 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.327 353 353 I DEBUG : #04 pc 0057ef97 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseBinaryNode(TIntermBinary*)+258) 06-08 16:41:07.328 353 353 I DEBUG : #05 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #06 pc 0057ef97 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseBinaryNode(TIntermBinary*)+258) 06-08 16:41:07.328 353 353 I DEBUG : #07 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #08 pc 0057ac5d /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseBranchNode(TIntermBranch*)+32) 06-08 16:41:07.328 353 353 I DEBUG : #09 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #10 pc 0057ae7f /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseSequence(TIntermAggregate*)+90) 06-08 16:41:07.328 353 353 I DEBUG : #11 pc 0058519d /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseAggregateNode(TIntermAggregate*)+1016) 06-08 16:41:07.328 353 353 I DEBUG : #12 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #13 pc 00584a11 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseFunction(TIntermAggregate*)+672) 06-08 16:41:07.328 353 353 I DEBUG : #14 pc 005851a7 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseAggregateNode(TIntermAggregate*)+1026) 06-08 16:41:07.328 353 353 I DEBUG : #15 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #16 pc 0057ae7f /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseSequence(TIntermAggregate*)+90) 06-08 16:41:07.328 353 353 I DEBUG : #17 pc 0058519d /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseAggregateNode(TIntermAggregate*)+1016) 06-08 16:41:07.328 353 353 I DEBUG : #18 pc 00579977 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::TraverseNode(TIntermNode*)+154) 06-08 16:41:07.328 353 353 I DEBUG : #19 pc 0057c145 /system/vendor/lib/libllvm-glnext.so (TQCOM_Codegen::compile(TIntermNode*)+16) 06-08 16:41:07.329 353 353 I DEBUG : #20 pc 005b32bf /system/vendor/lib/libllvm-glnext.so (ShCompile+1938) 06-08 16:41:07.329 353 353 I DEBUG : #21 pc 00552399 /system/vendor/lib/libllvm-glnext.so (LLVMCompiler::parse(QGLC_SRCSHADER*)+1188) 06-08 16:41:07.329 353 353 I DEBUG : #22 pc 005557ed /system/vendor/lib/libllvm-glnext.so (CompilerContext::CompileToIRShader(QGLC_SRCSHADER*, QGLC_COMPILETOIR_RESULT*)+168) 06-08 16:41:07.329 353 353 I DEBUG : #23 pc 00105903 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShaderCompiler::CompileShader(EsxContext const*, EsxShader const*, EsxInfoLog*)+526) 06-08 16:41:07.329 353 353 I DEBUG : #24 pc 00103ced /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShader::Compile(EsxContext*)+72) 06-08 16:41:07.329 353 353 I DEBUG : #25 pc 000b2201 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::GlCompileShader(unsigned int)+60) 06-08 16:41:07.329 353 353 I DEBUG : #26 pc 000e4ef9 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlCompileShader(EsxDispatch*, unsigned int)+40) 06-08 16:41:07.329 353 353 I DEBUG : #27 pc 000a947d /system/vendor/lib/egl/libGLESv2_adreno.so (glCompileShader+44) 
  • Up0
  • Down0
Ayo Moderator
Profile picture
Join Date: 23 Jan 15
Posts: 31
Posted: Wed, 2015-07-22 17:41

Hello Johan.

Thanks for the report and submitting the APK

Unfortunately, APKs are not terribly useful for us. What is useful is the actual fragment shader causing the problem.

By exploring your links, I was able to track down this message:

http://comments.gmane.org/gmane.comp.java.openjdk.openjfx.devel/9796

This mentions a fragment shader named "FillRoundRect_LinearGradient_PAD.frag" and the following line from that shader:

vec2 pixcoord = vec2(
    gl_FragCoord.x-jsl_pixCoordOffset.x,

((jsl_pixCoordOffset.z-gl_FragCoord.y)*jsl_pixCoordOffset.w)-jsl_pixCoordOffset.y);

Now this looks like you are initialising "pixcoord" using a "non-constant expression", so you should take a look at my post here:

https://developer.qualcomm.com/comment/9100#comment-9100

If this is the problem then you should be able to fix the fragment shader as explained in the OpenGL Specifications referenced in that above post.

You are correct that the compiler shouldn't crash, and that crash will be fixed at a future time, however the fragment shader should not be using non-constant initializers to initialize "pixcoord".

Hope this helps, and if it does please report back to let us know.

  • Up0
  • Down0
anchor
Join Date: 11 Jun 15
Posts: 3
Posted: Wed, 2015-07-22 18:49
extension for my previous post. our shader looks like:
 
uniform vec4 skinMatRows[75*3];
attribute vec4 joints, weights;
 
 
mat4 getJointMat( const int jointIndex )
{
// Note: This matrix is transposed so vec/mat multiplications need to be done in reversed order
return mat4( skinMatRows[jointIndex * 3],
skinMatRows[jointIndex * 3 + 1],
skinMatRows[jointIndex * 3 + 2],
vec4( 0, 0, 0, 1 ) );
}
 
mat4 calcSkinningMat()
{
return weights.x * getJointMat( int( joints.x ) ) +
  weights.y * getJointMat( int( joints.y ) ) +
  weights.z * getJointMat( int( joints.z ) ) +
  weights.w * getJointMat( int( joints.w ) );
}
 
mat3 getSkinningMatVec( const mat4 skinningMat )
{
return mat3( skinningMat[0].xyz, skinningMat[1].xyz, skinningMat[2].xyz );
}
 
vec4 skinPos( const vec4 pos )
{
return pos * getJointMat( int( joints.x ) ) * weights.x +
  pos * getJointMat( int( joints.y ) ) * weights.y +
  pos * getJointMat( int( joints.z ) ) * weights.z +
  pos * getJointMat( int( joints.w ) ) * weights.w;
}
 
vec4 skinPos( const vec4 pos, const mat4 skinningMat )
{
return pos * skinningMat;
}
 
vec3 skinVec( const vec3 vec, const mat3 skinningMatTSB )
{
return vec * skinningMatTSB;
}
 
  • Up0
  • Down0
johan1
Join Date: 15 Jul 15
Location: Belgium
Posts: 2
Posted: Fri, 2015-07-31 05:17

Thanks, that helped indeed.

Moving the pixcoord initialisation into the main function fixed the problem.

A nice warning instead of a crash would be much appreciated, so I'm looking forward to future releases.

Meanwhile, on behalf of many JavaFX developers, thanks a lot for your help, much appreciated.

- Johan

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.