Replace $$shufflevector with $$swizzle and $$swizzle2. Add builtin swizzle accessors.

This commit is contained in:
Christoffer Lerno
2023-01-21 23:46:54 +01:00
committed by Christoffer Lerno
parent 1e18e576c7
commit c9e1e2d763
9 changed files with 85 additions and 90 deletions

View File

@@ -144,6 +144,16 @@ macro prefetch(void* ptr, PrefetchLocality $locality = VERY_NEAR, bool $write =
$$prefetch(ptr, $write ? 1 : 0, $locality.ordinal);
}
macro swizzle(v, ...) @builtin
{
return $$swizzle(v, $vasplat());
}
macro swizzle2(v, v2, ...) @builtin
{
return $$swizzle2(v, v2, $vasplat());
}
macro bool @castable(#expr, $To) @builtin
{
return $checks(($To)#expr);

View File

@@ -131,8 +131,8 @@ private macro perpendicular3(v)
private macro cross3(v1, v2)
{
var a = $$shufflevector(v1, v1, { 1, 2, 0 }) * $$shufflevector(v2, v2, { 2, 0, 1 });
var b = $$shufflevector(v1, v1, { 2, 0, 1 }) * $$shufflevector(v2, v2, { 1, 2, 0 });
var a = v1.yzx * v2.zxy;
var b = v1.zxy * v2.yzx;
return a - b;
}