本文整理汇总了C#中Mono.Simd.Vector4f.Shuffle方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4f.Shuffle方法的具体用法?C# Vector4f.Shuffle怎么用?C# Vector4f.Shuffle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Simd.Vector4f
的用法示例。
在下文中一共展示了Vector4f.Shuffle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: test_0_shuffle_with_two_args_ps
public static int test_0_shuffle_with_two_args_ps () {
Vector4f a = new Vector4f (1, 2, 3, 4);
Vector4f b = new Vector4f (5, 6, 7, 8);
Vector4f c = a.Shuffle (b, ShuffleSel.ExpandY);
if (c.X != 2)
return 1;
if (c.Y != 2)
return 2;
if (c.Z != 6)
return 3;
if (c.W != 6)
return 4;
return 0;
}
示例2: test_0_packed_shuffle_with_reg_pressure
public static int test_0_packed_shuffle_with_reg_pressure () {
Vector4f v = new Vector4f (1, 2, 3, 4);
Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
if (ff) v = v + v -v ;
Vector4f r0 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
Vector4f r1 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
Vector4f x = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
Vector4f r2 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
Vector4f r3 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
Vector4f a = x;
r0 = r0 * m0 + x;
r1 = r1 * m1 + x;
x = x - v + v;
r2 = r2 * m2 + x;
r3 = r3 * m3 + x;
Vector4f result = r0 + r1 + r2 + r3;
if (a.X != 2f)
return 1;
if (a.Y != 4f)
return 2;
if (a.Z != 1f)
return 3;
if (a.W != 3f)
return 4;
if (result.Y != result.Y)
return 0;
return 0;
}
示例3: test_0_simple_packed_shuffle
public static int test_0_simple_packed_shuffle () {
Vector4f a = new Vector4f (1, 2, 3, 4);
a = a.Shuffle(ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
if (a.X != 2f)
return 1;
if (a.Y != 4f)
return 2;
if (a.Z != 1f)
return 3;
if (a.W != 3f)
return 4;
return 0;
}
示例4: Cross
public static void Cross (ref Vector4f a, ref Vector4f b, out Vector4f result)
{
result = (a * b.Shuffle ((ShuffleSel)0xc9) - b * a.Shuffle ((ShuffleSel)0xc9)).Shuffle ((ShuffleSel)0xc9);
}
示例5: Visit
public void Visit(TernaryOp ins)
{
Vector4f a = ctx.ReadValue (ins.Source1);
Vector4f b = ctx.ReadValue (ins.Source2);
Vector4f c = ctx.ReadValue (ins.Source3);
Vector4f res = new Vector4f ();
switch (ins.Operation) {
case TernaryOpKind.Cmp: {// a >= 0 ? b : c
//m = a < [0,0,0,0]
Vector4f mask = a.CompareLessThan (new Vector4f ()); //we change to a <b
//res = (m & C) | (~m & B) -- this could be replaced by a blendps
res = (mask & c) | mask.AndNot (b);
break;
}
case TernaryOpKind.Mad: {// a * b + c
res = (a * b) + c;
break;
}
case TernaryOpKind.SinCos: { // sin(a) , cos(a)
//XXX maybe we should use the macro expansion provided in the driver docs for HLSL
res.X = (float)Math.Cos (a.X);
res.Y = (float)Math.Sin (a.X);
break;
}
case TernaryOpKind.Lrp: //c + a * (b - c)
//res = c + (a * (b - c));
res = a * b + (Vector4f.One - a) * c;
break;
case TernaryOpKind.Dp2Add: //res = a.r * b.r + a.g * b.g + c.swizzle
res = a * b;
//XX we could use Hadd here
res = res + res.Shuffle (ShuffleSel.XFromY) + c;
res = res.Shuffle (ShuffleSel.ExpandX);
break;
default:
throw new Exception ("Cant handle " + ins.Operation);
}
if (Tracing.Enabled) Console.WriteLine ("{0} {1} {2} {3} => {4}/{5}/{6} == {7}", ins.Source1, ins.Operation, ins.Source2, ins.Source3, a, b, c, res);
ctx.StoreValue (ins.Dest, res);
}