# Question regarding lowp and swizzling

**URL:** <https://forums.imgtec.com/t/question-regarding-lowp-and-swizzling/706>\
**Category:** PowerVR Insider\
**Created:** [May 26, 2010, 10:01am UTC](https://forums.imgtec.com/t/question-regarding-lowp-and-swizzling/706 "2010-05-26T10:01:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![polarpeder](https://avatars.discourse-cdn.com/v4/letter/p/839c29/32.png) [@polarpeder](https://forums.imgtec.com/u/polarpeder)\
**Post date:** [May 26, 2010, 10:01am UTC](https://forums.imgtec.com/t/question-regarding-lowp-and-swizzling/706/1 "2010-05-26T10:01:55Z")

</div>

Hi. I have a performance question about low precision variables and swizzling.  
  
  
I read that you should avoid swizzling lowp variables since it’s expensive, but what exactly counts as bad swizzling?  
  
  
  
  
  
for example, is this considered swizzling?

Code:

  
lowp vec4 texture = texture2D(tex0, uv0);  
lowp vec3 color\_rgb = texture.rgb;  
lowp float color\_alpha = texture.a;  

  
  
  
Or is the "bad" swizzling only like this:  
  

Code:

  
lowp vec4 texture = texture2D(tex0, uv0);  
lowp vec3 color\_bgr = texture.bgr; // most likely bad  
lowp vec3 color\_alpha = texture.aaa; // bad?, would lowp vec color\_alpha = vec3(texture.a); be to prefer in this case?

---

<div class="post-metadata">

**Author:** ![GordonMaclachlan](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@GordonMaclachlan](https://forums.imgtec.com/u/GordonMaclachlan)\
**Post date:** [June 1, 2010, 4:09pm UTC](https://forums.imgtec.com/t/question-regarding-lowp-and-swizzling/706/2 "2010-06-01T16:09:25Z")

</div>

The second example may prove more expensive in shader cycles, but without a bit more context it’s difficult to know exactly how much difference it will make. This is why we recommend you make use of tools like PVRUniSCoEditor to gain some actual cycle count information from a real compiler.  
  
  
  
  
  
Using a line with your first example like this:

Code:

  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gl\_FragColor = vec4(vec3(color\_rgb\* color\_alpha),color\_alpha);  

  
  
  
Costs only a single cycle above directly outputting the texture read (probably the multiplication).  
  
  
  
Whereas:  
  
  
  

Code:

  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gl\_FragColor = vec4(color\_rgb\* color\_alpha,color\_alpha);  

  
  
  
Costs 5 extra cycles with the compiler I'm using.  
  
  
  
In short, in this example you're correct, but it might not always be that way - use tools and benchmark.  
  
  
  
(Without some actual use of the variables here, the compiler will ignore both instances of swizzling)
