Forums - Does Adreno (650) prefetch textures for conditional texture reads?

2 posts / 0 new
Last post
Does Adreno (650) prefetch textures for conditional texture reads?
matthias.buehlmann
Join Date: 25 Jan 21
Posts: 3
Posted: Thu, 2021-09-02 02:41

Let's say I have the following fragment shader:


main() {
  if(gl_LastFragData[0].w > 0.95)
    discard;
  gl_FragColor = texture2D(myTexture, vTexCoord);
}

can this effectively safe on texture bandwidth, or will the adreno gpu prefetch the texture data anyway for the sampled location?

  • Up0
  • Down0
jleger
Join Date: 23 Aug 16
Posts: 9
Posted: Wed, 2021-10-20 18:09

In the compiled HW shader, the texture2D() will only be executed if the fragment is not discarded, so yes there is some theoretical BW savings. That said, gl_LastFragData[0] is implemented as a texture fetch itself (generally the fetch is from tile memory which is better than fetching from a texture in system memory) and the presence of  'discard' in a shader makes it run much slower than a shader that does not contain discard.   So it's unlikely you'll see observable gains.

https://developer.qualcomm.com/sites/default/files/docs/adreno-gpu/devel...

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