-
gentypen shuffle(gentypem x, ugentypen mask);
- gentypen shuffle2(gentypem x, gentypem y, ugentypen mask);
DESCRIPTION
The elements of the input vectors are numbered from left to right across one or both of the vectors. For this purpose, the number of elements in a vector is given by vec_step(3clc)(gentypem). The shuffle mask operand specifies, for each element of the result vector, which element of the one or two input vectors the result element gets.
We use the generic type name gentypen (or gentypem) to indicate the built-in data types char{2|4|8|16}, uchar{2|4|8|16}, short{2|4|8|16}, ushort{2|4|8|16}, int{2|4|8|16}, uint{2|4|8|16}, long{2|4|8|16}, ulong{2|4|8|16}, or float{2|4|8|16} as the type for the arguments unless otherwise stated. We use the generic name ugentypen to indicate the built-in unsigned integer data types. If the double is supported, then gentypen (or gentypem) also indicate the built-in data types double{2|4|8|16}.
The generic type name gentypen (or gentypem) may indicate the data type half{2|4|8|16} if the cl_khr_fp16(3clc) extension is supported.
Example
uint4 mask = (uint4)(3, 2, 1, 0);
float4 a;
float4 r = shuffle(a, mask);
// r.s0123 = a.wzyx
uint8 mask = (uint8)(0, 1, 2, 3, 4, 5, 6, 7); float4 a, b; float8 r = shuffle2(a, b, mask); // r.s0123 = a.xyzw // r.s4567 = b.xyzw
uint4 mask;
float8 a;
float4 b;
b = shuffle(a, mask);
|
Examples that are not valid are:
uint8 mask;
short16 a;
short8 b;
b = shuffle(a, mask);
|
SPECIFICATION
m[blue]OpenCL Specificationm[][1]
AUTHORS
The Khronos Group
COPYRIGHT
Copyright © 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
NOTES
- 1.
-
OpenCL Specification
- page 282, section 6.12.12 Miscellaneous Vector Functions