Forums - fragment shader: texture2D in a function causes glLinkProgram to crash

5 posts / 0 new
Last post
fragment shader: texture2D in a function causes glLinkProgram to crash
realBohd
Join Date: 12 Nov 12
Posts: 4
Posted: Tue, 2012-11-27 00:34

Hi,

we have a weird problem. A 'texture2D' call is working 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.

This code is working on Tegra, PowerVR, Mali, etc.. But not on the  Adrenos..

 

Example code:

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 accessors of our node based shader system. That's also the reason why we make this call in a function.

 

The problem is, this code does not show any error in the Shader Analyzer of the Adreno Profiler and glCompileShader return no errors too.

But we have a crash in glLinkProgram when using this shader.

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 . [email protected]
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 /...d.H...d./...
11-27 09:10:11.050: I/DEBUG(24198): 5d148a28 9a0dfb3d 5853991d 4218681b 982fd00c =.....SX.h.B../.
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

..... and so on

Now for the weird part.

When replacing the function 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. It works!

 

 

Can someone explain this? We tried different precisions, storing the parameters etc.. Nothing helped.

We are out of ideas what to do here. It seems this is a driver problem.

 

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Thu, 2012-11-29 12:58

Thanks for reporting this issue with calling shader functions. It indeed might be a problem in our drivers, but we'll need some time to research it.

  • Up0
  • Down0
realBohd
Join Date: 12 Nov 12
Posts: 4
Posted: Fri, 2012-11-30 01:56

Thanks for the reply.

Meanwhile we got a workaround by replacing the subfunction that do the texture2D by using macros:

#define myTex2D(_sampler, _uv) texture2D(_sampler, _uv)

 

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Fri, 2012-12-07 07:59

second request for the full orginal shaders so that we can see everything that the shader compilers are working on..

 

thanks...

  • Up0
  • Down0
pontomedon
Join Date: 26 Jul 13
Posts: 5
Posted: Wed, 2013-07-31 06:15

I think i'm experiencing the same crash for a different reason:

https://developer.qualcomm.com/forum/qdevnet-forums/mobile-technologies/...

please have a look, i'll send you the shaders if you need them.

  • 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.