Results 1 to 3 of 3

Thread: Non-power of 2 vector types

  1. #1

    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.
    Code :
    float4 color; = colour.w *;
    Here, 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:
    Code : *= ((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.

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Northern Europe

    Re: Non-power of 2 vector types

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

  3. #3

    Re: Non-power of 2 vector types

    Add my vote too!

Similar Threads

  1. Replies: 1
    Last Post: 08-30-2011, 04:40 AM
  2. Replies: 1
    Last Post: 10-01-2009, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean