Created
July 14, 2013 16:44
-
-
Save auroranockert/5994890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io; | |
| simd!(u32x4: u32 * 4) | |
| simd!(f32x2: f32 * 2) | |
| simd!(f32x4: f32 * 4) | |
| fn vcopy(a:f32x4) -> f32x4 { | |
| a | |
| } | |
| fn vsplat(a:f32) -> f32x4 { | |
| a as f32x4 | |
| } | |
| fn as_uint4(a:f32x4) -> u32x4 { | |
| a as u32x4 | |
| } | |
| fn vfirst(a:f32x4) -> f32 { | |
| a.s0 | |
| } | |
| fn veven(a:f32x4) -> f32x2 { | |
| a.even | |
| } | |
| fn main() { | |
| let a = 1.0f32 as f32x4; | |
| let b = [1.0f32, 2.0f32, 3.0f32, 4.0f32] as f32x4; | |
| let c = vsplat(4.0f32); | |
| let x = a.s01; | |
| let y = b.bgra; | |
| let z = c as u32x4; | |
| io::println(fmt!("a = <%f, %f, %f, %f>", a.x as float, a.y as float, a.z as float, a.w as float)); | |
| io::println(fmt!("b = <%f, %f, %f, %f>", b.x as float, b.y as float, b.z as float, b.w as float)); | |
| io::println(fmt!("c = <%f, %f, %f, %f>", c.x as float, c.y as float, c.z as float, c.w as float)); | |
| io::println(fmt!("x = <%f, %f>", x.x as float, x.y as float)); | |
| io::println(fmt!("y = <%f, %f, %f, %f>", y.x as float, y.y as float, y.z as float, y.w as float)); | |
| io::println(fmt!("z = <%u, %u, %u, %u>", z.x as uint, z.y as uint, z.z as uint, z.w as uint)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment