Forums - Problem with discard statement in fragment shader on Adreno205(Android 2.3.4)

5 posts / 0 new
Last post
Problem with discard statement in fragment shader on Adreno205(Android 2.3.4)
Kazuhiko_Kobayashi
Join Date: 14 Feb 12
Posts: 9
Posted: Tue, 2012-02-14 11:59
Hi,
My application works fine on Adreno200, but It doesn't work on Adreno205.Android OS freezes.
I investigated the cause and I discovered it.
My shader source:
   161     if(alpha < 0.1 /*m_AlphaDiscardThreshold*/){
   162         discard;
   163     }
I commented out line 161-163, it works fine on Adreno205.
Question:
Why discard doesn't work on Adreno205?
Test phone SHARP IS05(Android 2.3.4)
My application(free):
Thanks.
  • Up0
  • Down0
Kazuhiko_Kobayashi
Join Date: 14 Feb 12
Posts: 9
Posted: Tue, 2012-02-14 17:01

This is a sample which works on Adreno200, but it doesn't work on Adreno205.

http://chototsumoushinp.dip.jp/miku/download/AndroidSample_tinyar-116-ad...

I removed discard statement in the fragment shader, it works on Adreno205.

  • Up0
  • Down0
Kazuhiko_Kobayashi
Join Date: 14 Feb 12
Posts: 9
Posted: Sun, 2012-02-19 17:37

Hi,

This shader freezes on Adreno205.

precision mediump float;
varying vec2 vTexcoord;
uniform lowp sampler2D ColorMap;
void main()
{
    gl_FragColor= texture2D( ColorMap, vTexcoord );
    discard;
}

However, this shader doesn't freeze.

precision mediump float;
varying vec2 vTexcoord;
uniform lowp sampler2D ColorMap;
void main()
{
    lowp vec4  color= texture2D( ColorMap, vTexcoord );
    if( color.w < 0.7 ){
        discard;
    }
    gl_FragColor= color;
}

Thanks.

 

  • Up0
  • Down0
Mark_Feldman Moderator
Join Date: 4 Jan 12
Posts: 58
Posted: Wed, 2012-02-22 16:00

In general we discourage the use of the discard statement as it is a very expensive operation.  You will have much better performing code by eliminating its use and rewriting the shader (for example setting alpha to 0 with alpha blending enabled).

 

(e.g.) http://stackoverflow.com/questions/8509051/is-discard-bad-for-program-pe...

  • Up0
  • Down0
Kazuhiko_Kobayashi
Join Date: 14 Feb 12
Posts: 9
Posted: Thu, 2012-03-01 13:39

Hi,

I know that.

However, I need it because some models can't draw without it.

Thanks.

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