Non-power of 2 vector types

Currently vectors can only be declared to be a power of 2 in length, eg. float2, float4, char8, int16.

With that said, it is seems to be possible (i.e. I can’t find anything in the spec to disallow it, and it seems to work) to work on vectors that aren’t a power of 2 in length.

float4 color;
colour.xyz = colour.w * colour.xyz;

Here, colour.xyz is a vector of length 3. This is useful, but because there is no type to define this, it’s impossible to construct values, and I’m finding myself writing code like this:

 colour.xyz *= ((float4)(0.5, 1.0, 2.0, 0.0)).xyz;

i.e. constructing a four element vector, just to select three elements out of it.

As these types appear to exist in the language, they should be named, and be able to be constructed. At the moment I’m only finding myself wanting 3-element vectors (for pixels and geometry), but it should probably be generalised. I notice that the spec defines the names as already reserved, so I expect this has already been raised, but I wanted to add my vote for it.

You’re not the only one who would like to be able to store and use 3-length vectors. :slight_smile:

Add my vote too!