Adreno GPU - Fragment shader: texture2D in function causes glLinkProgram to crash

we have a strange problem. The texture2D call works when used directly, but not when used in a function with a return value.

The device is a Samsung S3, SPH-L710, Android 4.0.4, Adreno 225.

The code we use works on Tegra, PowerVR, Mali, etc. But not on Adrenos.

Code example:

 vec4 myTex2D(sampler2D s, vec2 uv) { return texture2D(s, uv); } void ShaderRun() { IShaderNode_SetOutputColor0(myTex2D(s, IShaderNode_GetInputTexcoord0().xy)); } void main(void) { glFragColor = IShaderNode_GetOutputColor0(); } 

Nothing special here. The IShaderNode_* functions are accessories of our node-based shader system. This is also the reason why we call this call in a function.

The problem is that this code does not detect errors in the Adreno Profiler shader analyzer and glCompileShader does not return errors either.

But when using this shader, we have a glitch in glLinkProgram :

 11-27 09:10:10.599: I/faktum(24249): Check: Clockspeed: 1512 11-27 09:10:10.599: I/faktum(24249): Check: Manufactor: 0 11-27 09:10:10.599: I/faktum(24249): Check: Sys Code To File: 1512 11-27 09:10:10.599: I/faktum(24249): SV: Save: Calculated CRC: 114273795 11-27 09:10:10.599: I/faktum(24249): SV: Save: Size: 7917 11-27 09:10:10.760: I/DEBUG(24198): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 11-27 09:10:10.760: I/DEBUG(24198): Build fingerprint: 'samsung/d2spr/d2spr:4.0.4/IMM76D/L710VPALI3:user/release-keys' 11-27 09:10:10.760: I/DEBUG(24198): pid: 24249, tid: 24279 >>> com.vivamedia.cmGGTHD <<< 11-27 09:10:10.760: I/DEBUG(24198): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000018 11-27 09:10:10.760: I/DEBUG(24198): r0 00000000 r1 00000001 r2 00000000 r3 015f39d8 11-27 09:10:10.760: I/DEBUG(24198): r4 015ed4c0 r5 014c6510 r6 60961e50 r7 015f3528 11-27 09:10:10.760: I/DEBUG(24198): r8 0000000a r9 00000000 10 015f3618 fp 60961e54 11-27 09:10:10.760: I/DEBUG(24198): ip 00000004 sp 60961d98 lr 5d148a2b pc 5d14b0a4 cpsr 08000030 11-27 09:10:10.760: I/DEBUG(24198): d0 0084001200000047 d1 0084000000000055 11-27 09:10:10.760: I/DEBUG(24198): d2 0000004700003210 d3 000000550084000e 11-27 09:10:10.760: I/DEBUG(24198): d4 0000321000840012 d5 0000003200000053 11-27 09:10:10.760: I/DEBUG(24198): d6 0000004700000003 d7 0000005500840013 11-27 09:10:10.760: I/DEBUG(24198): d8 0000000000000000 d9 0000000000000000 11-27 09:10:10.760: I/DEBUG(24198): d10 0000000000000000 d11 0000000000000000 11-27 09:10:10.760: I/DEBUG(24198): d12 0000000000000000 d13 0000000000000000 11-27 09:10:10.760: I/DEBUG(24198): d14 0000000000000000 d15 0000000000000000 11-27 09:10:10.760: I/DEBUG(24198): d16 3feffead00000000 d17 3dbebd9ffead0000 11-27 09:10:10.760: I/DEBUG(24198): d18 3fe0000000000000 d19 3fe000000003d7b4 11-27 09:10:10.760: I/DEBUG(24198): d20 3fa55553e1053a42 d21 3f6941845904b7dd 11-27 09:10:10.760: I/DEBUG(24198): d22 3ff0000000000000 d23 3ef99342e0ee5069 11-27 09:10:10.760: I/DEBUG(24198): d24 3ef99342e0ee5069 d25 3fdbeaaaa0000000 11-27 09:10:10.760: I/DEBUG(24198): d26 4068200000000000 d27 3ef99342e0ee5069 11-27 09:10:10.760: I/DEBUG(24198): d28 c00005c02b53cb8a d29 bf66fdec79316df6 11-27 09:10:10.760: I/DEBUG(24198): d30 bc0a42cc192d5632 d31 be23e4f5df600000 11-27 09:10:10.760: I/DEBUG(24198): scr 60000010 11-27 09:10:11.040: I/DEBUG(24198): #00 pc 000690a4 /system/lib/libsc-a2xx.so (_ZN6Symbol7SetILIDEj) 11-27 09:10:11.040: I/DEBUG(24198): #01 pc 00066a26 /system/lib/libsc-a2xx.so (_Z9PatchCodeRSt6vectorIP11ATIFunctionSaIS1_EERKS3_RS_IjSaIjEERS_IiSaIiEESC_SC_S9_iiRSt3mapISsP6SymbolSt4lessISsESaISt4pairIKSsSF_EEERS_I9ConstDeclSaISO_EERS_I8ConstUseSaISS_EE10ShaderTypeb) 11-27 09:10:11.040: I/DEBUG(24198): #02 pc 00067304 /system/lib/libsc-a2xx.so (_ZN10TATILinker17generateFinalCodeERSt6vectorIjSaIjEERKS0_IP11ATIFunctionSaIS5_EEiRS0_IiSaIiEESC_SC_10ShaderTypeS3_S3_RSt3mapISsP6SymbolSt4lessISsESaISt4pairIKSsSG_EEEbSO_SO_RSE_IiSG_SH_IiESaISJ_IKiSG_EEESO_SO_PSN_SG_Pc) 11-27 09:10:11.040: I/DEBUG(24198): #03 pc 00068d8a /system/lib/libsc-a2xx.so (_ZN10TATILinker4linkER7TVectorIP9TCompilerER13LinkerOptions) 11-27 09:10:11.040: I/DEBUG(24198): #04 pc 0008bd02 /system/lib/libsc-a2xx.so (ShLink) 11-27 09:10:11.040: I/DEBUG(24198): #05 pc 0009e7d6 /system/lib/libsc-a2xx.so (_ZN8sclState4linkEPK18sclInputShaderPairRK17sclCompilerParams) 11-27 09:10:11.040: I/DEBUG(24198): #06 pc 0009ecca /system/lib/libsc-a2xx.so (_Z7sclLinkP16sclHandleTypeRecPK18sclInputShaderPairRK17sclCompilerParams) 11-27 09:10:11.040: I/DEBUG(24198): #07 pc 0009d7ce /system/lib/libsc-a2xx.so (__link_shaders) 11-27 09:10:11.040: I/DEBUG(24198): #08 pc 0002dd3a /system/lib/egl/libGLESv2_adreno200.so (qgl2DrvAPI_glLinkProgram) 11-27 09:10:11.040: I/DEBUG(24198): #09 pc 0001cbe6 /system/lib/egl/libGLESv2_adreno200.so (glLinkProgram) 11-27 09:10:11.040: I/DEBUG(24198): code around pc: 11-27 09:10:11.040: I/DEBUG(24198): 5d14b084 4770b280 47706001 28036800 2000bf8c ..pG.`pG.h.(... 11-27 09:10:11.040: I/DEBUG(24198): 5d14b094 47702001 4770301c 47706b40 47706181 . pG.0pG@kpG.apG 11-27 09:10:11.040: I/DEBUG(24198): 5d14b0a4 47706980 477063c1 47706bc0 0040f890 .ipG.cpG.kpG..@. 11-27 09:10:11.050: I/DEBUG(24198): 5d14b0b4 bf004770 64826441 477064c3 47706441 pG..Ad.d.dpGAdpG 11-27 09:10:11.050: I/DEBUG(24198): 5d14b0c4 47706c40 47706cc0 47706c80 41f0e92d @lpG.lpG.lpG-..A 11-27 09:10:11.050: I/DEBUG(24198): code around lr: 11-27 09:10:11.050: I/DEBUG(24198): 5d148a08 9b35e06a 1164f8d3 00e4f8d3 2021f850 j.5...d.....P.! 11-27 09:10:11.050: I/DEBUG(24198): 5d148a18 f8d3922f 1c481164 0164f8c3 f002982f /...dH..d./... 11-27 09:10:11.050: I/DEBUG(24198): 5d148a28 9a0dfb3d 5853991d 4218681b 982fd00c =.....SX.hB./. 11-27 09:10:11.050: I/DEBUG(24198): 5d148a38 f002930a 990afb33 0c01ea20 f8d09835 ....3... ...5... 11-27 09:10:11.050: I/DEBUG(24198): 5d148a48 f85220f0 932f302c 46594650 fd4cf7ea . R.,0/.PFYF..L. 11-27 09:10:11.050: I/DEBUG(24198): stack: 11-27 09:10:11.050: I/DEBUG(24198): 60961d58 60961f54 11-27 09:10:11.050: I/DEBUG(24198): 60961d5c 5d132e21 /system/lib/libsc-a2xx.so 11-27 09:10:11.050: I/DEBUG(24198): 60961d60 60961f54 11-27 09:10:11.050: I/DEBUG(24198): 60961d64 5d147b05 /system/lib/libsc-a2xx.so 11-27 09:10:11.050: I/DEBUG(24198): 60961d68 60961f54 11-27 09:10:11.050: I/DEBUG(24198): 60961d6c 00000008 11-27 09:10:11.050: I/DEBUG(24198): 60961d70 60961e6c 11-27 09:10:11.050: I/DEBUG(24198): 60961d74 015ed480 [heap] 11-27 09:10:11.050: I/DEBUG(24198): 60961d78 014c6510 [heap] 11-27 09:10:11.050: I/DEBUG(24198): 60961d7c 015ed4b4 [heap] 11-27 09:10:11.050: I/DEBUG(24198): 60961d80 015ed4b8 [heap] 11-27 09:10:11.050: I/DEBUG(24198): 60961d84 014c6510 [heap] 11-27 09:10:11.050: I/DEBUG(24198): 60961d88 60961e50 

..... etc.

Now for the weird part.

When replacing myTex2D call this way ...

 vec4 myTex2D(sampler2D s, vec2 uv) { return texture2D(s, uv); } void ShaderRun() { IShaderNode_SetOutputColor0(texture2D(s, IShaderNode_GetInputTexcoord0().xy)); } void main(void) { glFragColor = IShaderNode_GetOutputColor0(); } 

... by directly calling texture2D . He works!

Can someone explain this? We tried various refinements, saved the parameters, etc. Nothing helped.

Is there any special question when using functions with a return value in a shader on an Adreno GPU?

We have no idea what to do here. This seems to be a driver issue.

EDIT November 30, 2012:
We got a workaround using definitions instead of subfunctions for texture-containing functions.

+4
source share

All Articles