glslopengl-es-2.0swizzlingpowervr-sgx

What exactly constitutes swizzling in OpenGL ES 2.0? (PowerVR SGX specifically.)


PowerVR says

Swizzling the components of lowp vectors is expensive and should be avoided.

What exactly is swizzling?

color.brg  // This fits the definition I'm familiar with.

But what about vec3(color.b, color.r, color.g), or vec3(color), when color is a vec4?

Does accessing or modifying a single component constitute a swizzle? I really wouldn't think so, but if not, then you could work around swizzling by just doing a few more assignment operations manually. I don't have a problem doing that, but it seems like magic to me, if you could get the same effect at a faster speed just by writing the code without swizzle notation.


Solution

  • According to the GLSL specification, "swizzle masks" are defined as the component field selectors for vector types. .brg is a swizzle mask, as is .rgba or .b. All of those do swizzling.

    As for what PowerVR is talking about, that's up to them. Maybe .rgb is fine, since it selects the components in the same order. Or maybe it's not.