Commit 2e238583 by Chris Forbes

Remove dead parts of ShaderCore

Change-Id: I966632cdd1cfd7077d0595d8987d15351e43b6a6 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30248Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 6f1b765a
......@@ -22,7 +22,7 @@ namespace sw
class PixelShader;
class SamplerCore;
class PixelRoutine : public sw::QuadRasterizer, public ShaderCore
class PixelRoutine : public sw::QuadRasterizer
{
public:
PixelRoutine(const PixelProcessor::State &state,
......
......@@ -559,1448 +559,4 @@ namespace sw
case 4: transpose4x4(row0, row1, row2, row3); break;
}
}
const Vector4f RegisterFile::operator[](RValue<Int4> index)
{
ASSERT(indirectAddressable);
Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1);
Int index2 = Extract(index, 2);
Int index3 = Extract(index, 3);
Vector4f r;
r.x.x = Extract(x[0][index0], 0);
r.x.y = Extract(x[0][index1], 1);
r.x.z = Extract(x[0][index2], 2);
r.x.w = Extract(x[0][index3], 3);
r.y.x = Extract(y[0][index0], 0);
r.y.y = Extract(y[0][index1], 1);
r.y.z = Extract(y[0][index2], 2);
r.y.w = Extract(y[0][index3], 3);
r.z.x = Extract(z[0][index0], 0);
r.z.y = Extract(z[0][index1], 1);
r.z.z = Extract(z[0][index2], 2);
r.z.w = Extract(z[0][index3], 3);
r.w.x = Extract(w[0][index0], 0);
r.w.y = Extract(w[0][index1], 1);
r.w.z = Extract(w[0][index2], 2);
r.w.w = Extract(w[0][index3], 3);
return r;
}
void RegisterFile::scatter_x(Int4 index, RValue<Float4> r)
{
ASSERT(indirectAddressable);
Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1);
Int index2 = Extract(index, 2);
Int index3 = Extract(index, 3);
x[0][index0] = Insert(x[0][index0], Extract(r, 0), 0);
x[0][index1] = Insert(x[0][index1], Extract(r, 1), 1);
x[0][index2] = Insert(x[0][index2], Extract(r, 2), 2);
x[0][index3] = Insert(x[0][index3], Extract(r, 3), 3);
}
void RegisterFile::scatter_y(Int4 index, RValue<Float4> r)
{
ASSERT(indirectAddressable);
Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1);
Int index2 = Extract(index, 2);
Int index3 = Extract(index, 3);
y[0][index0] = Insert(y[0][index0], Extract(r, 0), 0);
y[0][index1] = Insert(y[0][index1], Extract(r, 1), 1);
y[0][index2] = Insert(y[0][index2], Extract(r, 2), 2);
y[0][index3] = Insert(y[0][index3], Extract(r, 3), 3);
}
void RegisterFile::scatter_z(Int4 index, RValue<Float4> r)
{
ASSERT(indirectAddressable);
Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1);
Int index2 = Extract(index, 2);
Int index3 = Extract(index, 3);
z[0][index0] = Insert(z[0][index0], Extract(r, 0), 0);
z[0][index1] = Insert(z[0][index1], Extract(r, 1), 1);
z[0][index2] = Insert(z[0][index2], Extract(r, 2), 2);
z[0][index3] = Insert(z[0][index3], Extract(r, 3), 3);
}
void RegisterFile::scatter_w(Int4 index, RValue<Float4> r)
{
ASSERT(indirectAddressable);
Int index0 = Extract(index, 0);
Int index1 = Extract(index, 1);
Int index2 = Extract(index, 2);
Int index3 = Extract(index, 3);
w[0][index0] = Insert(w[0][index0], Extract(r, 0), 0);
w[0][index1] = Insert(w[0][index1], Extract(r, 1), 1);
w[0][index2] = Insert(w[0][index2], Extract(r, 2), 2);
w[0][index3] = Insert(w[0][index3], Extract(r, 3), 3);
}
void ShaderCore::mov(Vector4f &dst, const Vector4f &src, bool integerDestination)
{
if(integerDestination)
{
dst.x = As<Float4>(RoundInt(src.x));
dst.y = As<Float4>(RoundInt(src.y));
dst.z = As<Float4>(RoundInt(src.z));
dst.w = As<Float4>(RoundInt(src.w));
}
else
{
dst = src;
}
}
void ShaderCore::neg(Vector4f &dst, const Vector4f &src)
{
dst.x = -src.x;
dst.y = -src.y;
dst.z = -src.z;
dst.w = -src.w;
}
void ShaderCore::ineg(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(-As<Int4>(src.x));
dst.y = As<Float4>(-As<Int4>(src.y));
dst.z = As<Float4>(-As<Int4>(src.z));
dst.w = As<Float4>(-As<Int4>(src.w));
}
void ShaderCore::f2b(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(CmpNEQ(src.x, Float4(0.0f)));
dst.y = As<Float4>(CmpNEQ(src.y, Float4(0.0f)));
dst.z = As<Float4>(CmpNEQ(src.z, Float4(0.0f)));
dst.w = As<Float4>(CmpNEQ(src.w, Float4(0.0f)));
}
void ShaderCore::b2f(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(As<Int4>(src.x) & As<Int4>(Float4(1.0f)));
dst.y = As<Float4>(As<Int4>(src.y) & As<Int4>(Float4(1.0f)));
dst.z = As<Float4>(As<Int4>(src.z) & As<Int4>(Float4(1.0f)));
dst.w = As<Float4>(As<Int4>(src.w) & As<Int4>(Float4(1.0f)));
}
void ShaderCore::f2i(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(Int4(src.x));
dst.y = As<Float4>(Int4(src.y));
dst.z = As<Float4>(Int4(src.z));
dst.w = As<Float4>(Int4(src.w));
}
void ShaderCore::i2f(Vector4f &dst, const Vector4f &src)
{
dst.x = Float4(As<Int4>(src.x));
dst.y = Float4(As<Int4>(src.y));
dst.z = Float4(As<Int4>(src.z));
dst.w = Float4(As<Int4>(src.w));
}
void ShaderCore::f2u(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(UInt4(src.x));
dst.y = As<Float4>(UInt4(src.y));
dst.z = As<Float4>(UInt4(src.z));
dst.w = As<Float4>(UInt4(src.w));
}
void ShaderCore::u2f(Vector4f &dst, const Vector4f &src)
{
dst.x = Float4(As<UInt4>(src.x));
dst.y = Float4(As<UInt4>(src.y));
dst.z = Float4(As<UInt4>(src.z));
dst.w = Float4(As<UInt4>(src.w));
}
void ShaderCore::i2b(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(CmpNEQ(As<Int4>(src.x), Int4(0)));
dst.y = As<Float4>(CmpNEQ(As<Int4>(src.y), Int4(0)));
dst.z = As<Float4>(CmpNEQ(As<Int4>(src.z), Int4(0)));
dst.w = As<Float4>(CmpNEQ(As<Int4>(src.w), Int4(0)));
}
void ShaderCore::b2i(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(As<Int4>(src.x) & Int4(1));
dst.y = As<Float4>(As<Int4>(src.y) & Int4(1));
dst.z = As<Float4>(As<Int4>(src.z) & Int4(1));
dst.w = As<Float4>(As<Int4>(src.w) & Int4(1));
}
void ShaderCore::add(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.x + src1.x;
dst.y = src0.y + src1.y;
dst.z = src0.z + src1.z;
dst.w = src0.w + src1.w;
}
void ShaderCore::iadd(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) + As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) + As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) + As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) + As<Int4>(src1.w));
}
void ShaderCore::sub(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.x - src1.x;
dst.y = src0.y - src1.y;
dst.z = src0.z - src1.z;
dst.w = src0.w - src1.w;
}
void ShaderCore::isub(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) - As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) - As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) - As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) - As<Int4>(src1.w));
}
void ShaderCore::mad(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
dst.x = src0.x * src1.x + src2.x;
dst.y = src0.y * src1.y + src2.y;
dst.z = src0.z * src1.z + src2.z;
dst.w = src0.w * src1.w + src2.w;
}
void ShaderCore::imad(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
dst.x = As<Float4>(As<Int4>(src0.x) * As<Int4>(src1.x) + As<Int4>(src2.x));
dst.y = As<Float4>(As<Int4>(src0.y) * As<Int4>(src1.y) + As<Int4>(src2.y));
dst.z = As<Float4>(As<Int4>(src0.z) * As<Int4>(src1.z) + As<Int4>(src2.z));
dst.w = As<Float4>(As<Int4>(src0.w) * As<Int4>(src1.w) + As<Int4>(src2.w));
}
void ShaderCore::mul(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.x * src1.x;
dst.y = src0.y * src1.y;
dst.z = src0.z * src1.z;
dst.w = src0.w * src1.w;
}
void ShaderCore::imul(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) * As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) * As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) * As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) * As<Int4>(src1.w));
}
void ShaderCore::rcpx(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 rcp = reciprocal(src.x, pp, true, true);
dst.x = rcp;
dst.y = rcp;
dst.z = rcp;
dst.w = rcp;
}
void ShaderCore::div(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.x / src1.x;
dst.y = src0.y / src1.y;
dst.z = src0.z / src1.z;
dst.w = src0.w / src1.w;
}
void ShaderCore::idiv(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 intMax(As<Float4>(Int4(INT_MAX)));
cmp0i(dst.x, src1.x, intMax, src1.x);
dst.x = As<Float4>(As<Int4>(src0.x) / As<Int4>(dst.x));
cmp0i(dst.y, src1.y, intMax, src1.y);
dst.y = As<Float4>(As<Int4>(src0.y) / As<Int4>(dst.y));
cmp0i(dst.z, src1.z, intMax, src1.z);
dst.z = As<Float4>(As<Int4>(src0.z) / As<Int4>(dst.z));
cmp0i(dst.w, src1.w, intMax, src1.w);
dst.w = As<Float4>(As<Int4>(src0.w) / As<Int4>(dst.w));
}
void ShaderCore::udiv(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 uintMax(As<Float4>(UInt4(UINT_MAX)));
cmp0i(dst.x, src1.x, uintMax, src1.x);
dst.x = As<Float4>(As<UInt4>(src0.x) / As<UInt4>(dst.x));
cmp0i(dst.y, src1.y, uintMax, src1.y);
dst.y = As<Float4>(As<UInt4>(src0.y) / As<UInt4>(dst.y));
cmp0i(dst.z, src1.z, uintMax, src1.z);
dst.z = As<Float4>(As<UInt4>(src0.z) / As<UInt4>(dst.z));
cmp0i(dst.w, src1.w, uintMax, src1.w);
dst.w = As<Float4>(As<UInt4>(src0.w) / As<UInt4>(dst.w));
}
void ShaderCore::mod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = modulo(src0.x, src1.x);
dst.y = modulo(src0.y, src1.y);
dst.z = modulo(src0.z, src1.z);
dst.w = modulo(src0.w, src1.w);
}
void ShaderCore::imod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 intMax(As<Float4>(Int4(INT_MAX)));
cmp0i(dst.x, src1.x, intMax, src1.x);
dst.x = As<Float4>(As<Int4>(src0.x) % As<Int4>(dst.x));
cmp0i(dst.y, src1.y, intMax, src1.y);
dst.y = As<Float4>(As<Int4>(src0.y) % As<Int4>(dst.y));
cmp0i(dst.z, src1.z, intMax, src1.z);
dst.z = As<Float4>(As<Int4>(src0.z) % As<Int4>(dst.z));
cmp0i(dst.w, src1.w, intMax, src1.w);
dst.w = As<Float4>(As<Int4>(src0.w) % As<Int4>(dst.w));
}
void ShaderCore::umod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 uintMax(As<Float4>(UInt4(UINT_MAX)));
cmp0i(dst.x, src1.x, uintMax, src1.x);
dst.x = As<Float4>(As<UInt4>(src0.x) % As<UInt4>(dst.x));
cmp0i(dst.y, src1.y, uintMax, src1.y);
dst.y = As<Float4>(As<UInt4>(src0.y) % As<UInt4>(dst.y));
cmp0i(dst.z, src1.z, uintMax, src1.z);
dst.z = As<Float4>(As<UInt4>(src0.z) % As<UInt4>(dst.z));
cmp0i(dst.w, src1.w, uintMax, src1.w);
dst.w = As<Float4>(As<UInt4>(src0.w) % As<UInt4>(dst.w));
}
void ShaderCore::shl(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) << As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) << As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) << As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) << As<Int4>(src1.w));
}
void ShaderCore::ishr(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) >> As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) >> As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) >> As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) >> As<Int4>(src1.w));
}
void ShaderCore::ushr(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<UInt4>(src0.x) >> As<UInt4>(src1.x));
dst.y = As<Float4>(As<UInt4>(src0.y) >> As<UInt4>(src1.y));
dst.z = As<Float4>(As<UInt4>(src0.z) >> As<UInt4>(src1.z));
dst.w = As<Float4>(As<UInt4>(src0.w) >> As<UInt4>(src1.w));
}
void ShaderCore::rsqx(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 rsq = reciprocalSquareRoot(src.x, true, pp);
dst.x = rsq;
dst.y = rsq;
dst.z = rsq;
dst.w = rsq;
}
void ShaderCore::sqrt(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = Sqrt(src.x);
dst.y = Sqrt(src.y);
dst.z = Sqrt(src.z);
dst.w = Sqrt(src.w);
}
void ShaderCore::rsq(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = reciprocalSquareRoot(src.x, false, pp);
dst.y = reciprocalSquareRoot(src.y, false, pp);
dst.z = reciprocalSquareRoot(src.z, false, pp);
dst.w = reciprocalSquareRoot(src.w, false, pp);
}
void ShaderCore::len2(Float4 &dst, const Vector4f &src, bool pp)
{
dst = Sqrt(dot2(src, src));
}
void ShaderCore::len3(Float4 &dst, const Vector4f &src, bool pp)
{
dst = Sqrt(dot3(src, src));
}
void ShaderCore::len4(Float4 &dst, const Vector4f &src, bool pp)
{
dst = Sqrt(dot4(src, src));
}
void ShaderCore::dist1(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
dst = Abs(src0.x - src1.x);
}
void ShaderCore::dist2(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
Float4 dx = src0.x - src1.x;
Float4 dy = src0.y - src1.y;
Float4 dot2 = dx * dx + dy * dy;
dst = Sqrt(dot2);
}
void ShaderCore::dist3(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
Float4 dx = src0.x - src1.x;
Float4 dy = src0.y - src1.y;
Float4 dz = src0.z - src1.z;
Float4 dot3 = dx * dx + dy * dy + dz * dz;
dst = Sqrt(dot3);
}
void ShaderCore::dist4(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
Float4 dx = src0.x - src1.x;
Float4 dy = src0.y - src1.y;
Float4 dz = src0.z - src1.z;
Float4 dw = src0.w - src1.w;
Float4 dot4 = dx * dx + dy * dy + dz * dz + dw * dw;
dst = Sqrt(dot4);
}
void ShaderCore::dp1(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 t = src0.x * src1.x;
dst.x = t;
dst.y = t;
dst.z = t;
dst.w = t;
}
void ShaderCore::dp2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 t = dot2(src0, src1);
dst.x = t;
dst.y = t;
dst.z = t;
dst.w = t;
}
void ShaderCore::dp2add(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
Float4 t = dot2(src0, src1) + src2.x;
dst.x = t;
dst.y = t;
dst.z = t;
dst.w = t;
}
void ShaderCore::dp3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 dot = dot3(src0, src1);
dst.x = dot;
dst.y = dot;
dst.z = dot;
dst.w = dot;
}
void ShaderCore::dp4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
Float4 dot = dot4(src0, src1);
dst.x = dot;
dst.y = dot;
dst.z = dot;
dst.w = dot;
}
void ShaderCore::min(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = Min(src0.x, src1.x);
dst.y = Min(src0.y, src1.y);
dst.z = Min(src0.z, src1.z);
dst.w = Min(src0.w, src1.w);
}
void ShaderCore::imin(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(Min(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(Min(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(Min(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(Min(As<Int4>(src0.w), As<Int4>(src1.w)));
}
void ShaderCore::umin(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(Min(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(Min(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(Min(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(Min(As<UInt4>(src0.w), As<UInt4>(src1.w)));
}
void ShaderCore::max(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = Max(src0.x, src1.x);
dst.y = Max(src0.y, src1.y);
dst.z = Max(src0.z, src1.z);
dst.w = Max(src0.w, src1.w);
}
void ShaderCore::imax(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(Max(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(Max(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(Max(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(Max(As<Int4>(src0.w), As<Int4>(src1.w)));
}
void ShaderCore::umax(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(Max(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(Max(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(Max(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(Max(As<Int4>(src0.w), As<Int4>(src1.w)));
}
void ShaderCore::slt(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(CmpLT(src0.x, src1.x)) & As<Int4>(Float4(1.0f)));
dst.y = As<Float4>(As<Int4>(CmpLT(src0.y, src1.y)) & As<Int4>(Float4(1.0f)));
dst.z = As<Float4>(As<Int4>(CmpLT(src0.z, src1.z)) & As<Int4>(Float4(1.0f)));
dst.w = As<Float4>(As<Int4>(CmpLT(src0.w, src1.w)) & As<Int4>(Float4(1.0f)));
}
void ShaderCore::step(Vector4f &dst, const Vector4f &edge, const Vector4f &x)
{
dst.x = As<Float4>(CmpNLT(x.x, edge.x) & As<Int4>(Float4(1.0f)));
dst.y = As<Float4>(CmpNLT(x.y, edge.y) & As<Int4>(Float4(1.0f)));
dst.z = As<Float4>(CmpNLT(x.z, edge.z) & As<Int4>(Float4(1.0f)));
dst.w = As<Float4>(CmpNLT(x.w, edge.w) & As<Int4>(Float4(1.0f)));
}
void ShaderCore::exp2x(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 exp = exponential2(src.x, pp);
dst.x = exp;
dst.y = exp;
dst.z = exp;
dst.w = exp;
}
void ShaderCore::exp2(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = exponential2(src.x, pp);
dst.y = exponential2(src.y, pp);
dst.z = exponential2(src.z, pp);
dst.w = exponential2(src.w, pp);
}
void ShaderCore::exp(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = exponential(src.x, pp);
dst.y = exponential(src.y, pp);
dst.z = exponential(src.z, pp);
dst.w = exponential(src.w, pp);
}
void ShaderCore::log2x(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 log = logarithm2(src.x, true, pp);
dst.x = log;
dst.y = log;
dst.z = log;
dst.w = log;
}
void ShaderCore::log2(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = logarithm2(src.x, false, pp);
dst.y = logarithm2(src.y, false, pp);
dst.z = logarithm2(src.z, false, pp);
dst.w = logarithm2(src.w, false, pp);
}
void ShaderCore::log(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = logarithm(src.x, false, pp);
dst.y = logarithm(src.y, false, pp);
dst.z = logarithm(src.z, false, pp);
dst.w = logarithm(src.w, false, pp);
}
void ShaderCore::lit(Vector4f &dst, const Vector4f &src)
{
dst.x = Float4(1.0f);
dst.y = Max(src.x, Float4(0.0f));
Float4 pow;
pow = src.w;
pow = Min(pow, Float4(127.9961f));
pow = Max(pow, Float4(-127.9961f));
dst.z = power(src.y, pow);
dst.z = As<Float4>(As<Int4>(dst.z) & CmpNLT(src.x, Float4(0.0f)));
dst.z = As<Float4>(As<Int4>(dst.z) & CmpNLT(src.y, Float4(0.0f)));
dst.w = Float4(1.0f);
}
void ShaderCore::att(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
// Computes attenuation factors (1, d, d^2, 1/d) assuming src0 = d^2, src1 = 1/d
dst.x = 1;
dst.y = src0.y * src1.y;
dst.z = src0.z;
dst.w = src1.w;
}
void ShaderCore::lrp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
dst.x = src0.x * (src1.x - src2.x) + src2.x;
dst.y = src0.y * (src1.y - src2.y) + src2.y;
dst.z = src0.z * (src1.z - src2.z) + src2.z;
dst.w = src0.w * (src1.w - src2.w) + src2.w;
}
void ShaderCore::isinf(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(IsInf(src.x));
dst.y = As<Float4>(IsInf(src.y));
dst.z = As<Float4>(IsInf(src.z));
dst.w = As<Float4>(IsInf(src.w));
}
void ShaderCore::isnan(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(IsNan(src.x));
dst.y = As<Float4>(IsNan(src.y));
dst.z = As<Float4>(IsNan(src.z));
dst.w = As<Float4>(IsNan(src.w));
}
void ShaderCore::smooth(Vector4f &dst, const Vector4f &edge0, const Vector4f &edge1, const Vector4f &x)
{
Float4 tx = Min(Max((x.x - edge0.x) / (edge1.x - edge0.x), Float4(0.0f)), Float4(1.0f)); dst.x = tx * tx * (Float4(3.0f) - Float4(2.0f) * tx);
Float4 ty = Min(Max((x.y - edge0.y) / (edge1.y - edge0.y), Float4(0.0f)), Float4(1.0f)); dst.y = ty * ty * (Float4(3.0f) - Float4(2.0f) * ty);
Float4 tz = Min(Max((x.z - edge0.z) / (edge1.z - edge0.z), Float4(0.0f)), Float4(1.0f)); dst.z = tz * tz * (Float4(3.0f) - Float4(2.0f) * tz);
Float4 tw = Min(Max((x.w - edge0.w) / (edge1.w - edge0.w), Float4(0.0f)), Float4(1.0f)); dst.w = tw * tw * (Float4(3.0f) - Float4(2.0f) * tw);
}
void ShaderCore::floatToHalfBits(Float4& dst, const Float4& floatBits, bool storeInUpperBits)
{
static const uint32_t mask_sign = 0x80000000u;
static const uint32_t mask_round = ~0xfffu;
static const uint32_t c_f32infty = 255 << 23;
static const uint32_t c_magic = 15 << 23;
static const uint32_t c_nanbit = 0x200;
static const uint32_t c_infty_as_fp16 = 0x7c00;
static const uint32_t c_clamp = (31 << 23) - 0x1000;
UInt4 justsign = UInt4(mask_sign) & As<UInt4>(floatBits);
UInt4 absf = As<UInt4>(floatBits) ^ justsign;
UInt4 b_isnormal = CmpNLE(UInt4(c_f32infty), absf);
// Note: this version doesn't round to the nearest even in case of a tie as defined by IEEE 754-2008, it rounds to +inf
// instead of nearest even, since that's fine for GLSL ES 3.0's needs (see section 2.1.1 Floating-Point Computation)
UInt4 joined = ((((As<UInt4>(Min(As<Float4>(absf & UInt4(mask_round)) * As<Float4>(UInt4(c_magic)),
As<Float4>(UInt4(c_clamp))))) - UInt4(mask_round)) >> 13) & b_isnormal) |
((b_isnormal ^ UInt4(0xFFFFFFFF)) & ((CmpNLE(absf, UInt4(c_f32infty)) & UInt4(c_nanbit)) |
UInt4(c_infty_as_fp16)));
dst = As<Float4>(storeInUpperBits ? As<UInt4>(dst) | ((joined << 16) | justsign) : joined | (justsign >> 16));
}
void ShaderCore::halfToFloatBits(Float4& dst, const Float4& halfBits)
{
static const uint32_t mask_nosign = 0x7FFF;
static const uint32_t magic = (254 - 15) << 23;
static const uint32_t was_infnan = 0x7BFF;
static const uint32_t exp_infnan = 255 << 23;
UInt4 expmant = As<UInt4>(halfBits) & UInt4(mask_nosign);
dst = As<Float4>(As<UInt4>(As<Float4>(expmant << 13) * As<Float4>(UInt4(magic))) |
((As<UInt4>(halfBits) ^ UInt4(expmant)) << 16) |
(CmpNLE(As<UInt4>(expmant), UInt4(was_infnan)) & UInt4(exp_infnan)));
}
void ShaderCore::packHalf2x16(Vector4f &d, const Vector4f &s0)
{
// half2 | half1
floatToHalfBits(d.x, s0.x, false);
floatToHalfBits(d.x, s0.y, true);
}
void ShaderCore::unpackHalf2x16(Vector4f &dst, const Vector4f &s0)
{
// half2 | half1
halfToFloatBits(dst.x, As<Float4>(As<UInt4>(s0.x) & UInt4(0x0000FFFF)));
halfToFloatBits(dst.y, As<Float4>((As<UInt4>(s0.x) & UInt4(0xFFFF0000)) >> 16));
}
void ShaderCore::packSnorm2x16(Vector4f &d, const Vector4f &s0)
{
// round(clamp(c, -1.0, 1.0) * 32767.0)
d.x = As<Float4>((Int4(Round(Min(Max(s0.x, Float4(-1.0f)), Float4(1.0f)) * Float4(32767.0f))) & Int4(0xFFFF)) |
((Int4(Round(Min(Max(s0.y, Float4(-1.0f)), Float4(1.0f)) * Float4(32767.0f))) & Int4(0xFFFF)) << 16));
}
void ShaderCore::packUnorm2x16(Vector4f &d, const Vector4f &s0)
{
// round(clamp(c, 0.0, 1.0) * 65535.0)
d.x = As<Float4>((Int4(Round(Min(Max(s0.x, Float4(0.0f)), Float4(1.0f)) * Float4(65535.0f))) & Int4(0xFFFF)) |
((Int4(Round(Min(Max(s0.y, Float4(0.0f)), Float4(1.0f)) * Float4(65535.0f))) & Int4(0xFFFF)) << 16));
}
void ShaderCore::unpackSnorm2x16(Vector4f &dst, const Vector4f &s0)
{
// clamp(f / 32727.0, -1.0, 1.0)
dst.x = Min(Max(Float4(As<Int4>((As<UInt4>(s0.x) & UInt4(0x0000FFFF)) << 16)) * Float4(1.0f / float(0x7FFF0000)), Float4(-1.0f)), Float4(1.0f));
dst.y = Min(Max(Float4(As<Int4>(As<UInt4>(s0.x) & UInt4(0xFFFF0000))) * Float4(1.0f / float(0x7FFF0000)), Float4(-1.0f)), Float4(1.0f));
}
void ShaderCore::unpackUnorm2x16(Vector4f &dst, const Vector4f &s0)
{
// f / 65535.0
dst.x = Float4((As<UInt4>(s0.x) & UInt4(0x0000FFFF)) << 16) * Float4(1.0f / float(0xFFFF0000));
dst.y = Float4(As<UInt4>(s0.x) & UInt4(0xFFFF0000)) * Float4(1.0f / float(0xFFFF0000));
}
void ShaderCore::det2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.x * src1.y - src0.y * src1.x;
dst.y = dst.z = dst.w = dst.x;
}
void ShaderCore::det3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
crs(dst, src1, src2);
dp3(dst, dst, src0);
}
void ShaderCore::det4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2, const Vector4f &src3)
{
dst.x = src2.z * src3.w - src2.w * src3.z;
dst.y = src1.w * src3.z - src1.z * src3.w;
dst.z = src1.z * src2.w - src1.w * src2.z;
dst.x = src0.x * (src1.y * dst.x + src2.y * dst.y + src3.y * dst.z) -
src0.y * (src1.x * dst.x + src2.x * dst.y + src3.x * dst.z) +
src0.z * (src1.x * (src2.y * src3.w - src2.w * src3.y) +
src2.x * (src1.w * src3.y - src1.y * src3.w) +
src3.x * (src1.y * src2.w - src1.w * src2.y)) +
src0.w * (src1.x * (src2.z * src3.y - src2.y * src3.z) +
src2.x * (src1.y * src3.z - src1.z * src3.y) +
src3.x * (src1.z * src2.y - src1.y * src2.z));
dst.y = dst.z = dst.w = dst.x;
}
void ShaderCore::frc(Vector4f &dst, const Vector4f &src)
{
dst.x = Frac(src.x);
dst.y = Frac(src.y);
dst.z = Frac(src.z);
dst.w = Frac(src.w);
}
void ShaderCore::trunc(Vector4f &dst, const Vector4f &src)
{
dst.x = Trunc(src.x);
dst.y = Trunc(src.y);
dst.z = Trunc(src.z);
dst.w = Trunc(src.w);
}
void ShaderCore::floor(Vector4f &dst, const Vector4f &src)
{
dst.x = Floor(src.x);
dst.y = Floor(src.y);
dst.z = Floor(src.z);
dst.w = Floor(src.w);
}
void ShaderCore::round(Vector4f &dst, const Vector4f &src)
{
dst.x = Round(src.x);
dst.y = Round(src.y);
dst.z = Round(src.z);
dst.w = Round(src.w);
}
void ShaderCore::roundEven(Vector4f &dst, const Vector4f &src)
{
// dst = round(src) + ((round(src) < src) * 2 - 1) * (fract(src) == 0.5) * isOdd(round(src));
// ex.: 1.5: 2 + (0 * 2 - 1) * 1 * 0 = 2
// 2.5: 3 + (0 * 2 - 1) * 1 * 1 = 2
// -1.5: -2 + (1 * 2 - 1) * 1 * 0 = -2
// -2.5: -3 + (1 * 2 - 1) * 1 * 1 = -2
// Even if the round implementation rounds the other way:
// 1.5: 1 + (1 * 2 - 1) * 1 * 1 = 2
// 2.5: 2 + (1 * 2 - 1) * 1 * 0 = 2
// -1.5: -1 + (0 * 2 - 1) * 1 * 1 = -2
// -2.5: -2 + (0 * 2 - 1) * 1 * 0 = -2
round(dst, src);
dst.x += ((Float4(CmpLT(dst.x, src.x) & Int4(1)) * Float4(2.0f)) - Float4(1.0f)) * Float4(CmpEQ(Frac(src.x), Float4(0.5f)) & Int4(1)) * Float4(Int4(dst.x) & Int4(1));
dst.y += ((Float4(CmpLT(dst.y, src.y) & Int4(1)) * Float4(2.0f)) - Float4(1.0f)) * Float4(CmpEQ(Frac(src.y), Float4(0.5f)) & Int4(1)) * Float4(Int4(dst.y) & Int4(1));
dst.z += ((Float4(CmpLT(dst.z, src.z) & Int4(1)) * Float4(2.0f)) - Float4(1.0f)) * Float4(CmpEQ(Frac(src.z), Float4(0.5f)) & Int4(1)) * Float4(Int4(dst.z) & Int4(1));
dst.w += ((Float4(CmpLT(dst.w, src.w) & Int4(1)) * Float4(2.0f)) - Float4(1.0f)) * Float4(CmpEQ(Frac(src.w), Float4(0.5f)) & Int4(1)) * Float4(Int4(dst.w) & Int4(1));
}
void ShaderCore::ceil(Vector4f &dst, const Vector4f &src)
{
dst.x = Ceil(src.x);
dst.y = Ceil(src.y);
dst.z = Ceil(src.z);
dst.w = Ceil(src.w);
}
void ShaderCore::powx(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
Float4 pow = power(src0.x, src1.x, pp);
dst.x = pow;
dst.y = pow;
dst.z = pow;
dst.w = pow;
}
void ShaderCore::pow(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
dst.x = power(src0.x, src1.x, pp);
dst.y = power(src0.y, src1.y, pp);
dst.z = power(src0.z, src1.z, pp);
dst.w = power(src0.w, src1.w, pp);
}
void ShaderCore::crs(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = src0.y * src1.z - src0.z * src1.y;
dst.y = src0.z * src1.x - src0.x * src1.z;
dst.z = src0.x * src1.y - src0.y * src1.x;
}
void ShaderCore::forward1(Vector4f &dst, const Vector4f &N, const Vector4f &I, const Vector4f &Nref)
{
Int4 flip = CmpNLT(Nref.x * I.x, Float4(0.0f)) & Int4(0x80000000);
dst.x = As<Float4>(flip ^ As<Int4>(N.x));
}
void ShaderCore::forward2(Vector4f &dst, const Vector4f &N, const Vector4f &I, const Vector4f &Nref)
{
Int4 flip = CmpNLT(dot2(Nref, I), Float4(0.0f)) & Int4(0x80000000);
dst.x = As<Float4>(flip ^ As<Int4>(N.x));
dst.y = As<Float4>(flip ^ As<Int4>(N.y));
}
void ShaderCore::forward3(Vector4f &dst, const Vector4f &N, const Vector4f &I, const Vector4f &Nref)
{
Int4 flip = CmpNLT(dot3(Nref, I), Float4(0.0f)) & Int4(0x80000000);
dst.x = As<Float4>(flip ^ As<Int4>(N.x));
dst.y = As<Float4>(flip ^ As<Int4>(N.y));
dst.z = As<Float4>(flip ^ As<Int4>(N.z));
}
void ShaderCore::forward4(Vector4f &dst, const Vector4f &N, const Vector4f &I, const Vector4f &Nref)
{
Int4 flip = CmpNLT(dot4(Nref, I), Float4(0.0f)) & Int4(0x80000000);
dst.x = As<Float4>(flip ^ As<Int4>(N.x));
dst.y = As<Float4>(flip ^ As<Int4>(N.y));
dst.z = As<Float4>(flip ^ As<Int4>(N.z));
dst.w = As<Float4>(flip ^ As<Int4>(N.w));
}
void ShaderCore::reflect1(Vector4f &dst, const Vector4f &I, const Vector4f &N)
{
Float4 d = N.x * I.x;
dst.x = I.x - Float4(2.0f) * d * N.x;
}
void ShaderCore::reflect2(Vector4f &dst, const Vector4f &I, const Vector4f &N)
{
Float4 d = dot2(N, I);
dst.x = I.x - Float4(2.0f) * d * N.x;
dst.y = I.y - Float4(2.0f) * d * N.y;
}
void ShaderCore::reflect3(Vector4f &dst, const Vector4f &I, const Vector4f &N)
{
Float4 d = dot3(N, I);
dst.x = I.x - Float4(2.0f) * d * N.x;
dst.y = I.y - Float4(2.0f) * d * N.y;
dst.z = I.z - Float4(2.0f) * d * N.z;
}
void ShaderCore::reflect4(Vector4f &dst, const Vector4f &I, const Vector4f &N)
{
Float4 d = dot4(N, I);
dst.x = I.x - Float4(2.0f) * d * N.x;
dst.y = I.y - Float4(2.0f) * d * N.y;
dst.z = I.z - Float4(2.0f) * d * N.z;
dst.w = I.w - Float4(2.0f) * d * N.w;
}
void ShaderCore::refract1(Vector4f &dst, const Vector4f &I, const Vector4f &N, const Float4 &eta)
{
Float4 d = N.x * I.x;
Float4 k = Float4(1.0f) - eta * eta * (Float4(1.0f) - d * d);
Int4 pos = CmpNLT(k, Float4(0.0f));
Float4 t = (eta * d + Sqrt(k));
dst.x = As<Float4>(pos & As<Int4>(eta * I.x - t * N.x));
}
void ShaderCore::refract2(Vector4f &dst, const Vector4f &I, const Vector4f &N, const Float4 &eta)
{
Float4 d = dot2(N, I);
Float4 k = Float4(1.0f) - eta * eta * (Float4(1.0f) - d * d);
Int4 pos = CmpNLT(k, Float4(0.0f));
Float4 t = (eta * d + Sqrt(k));
dst.x = As<Float4>(pos & As<Int4>(eta * I.x - t * N.x));
dst.y = As<Float4>(pos & As<Int4>(eta * I.y - t * N.y));
}
void ShaderCore::refract3(Vector4f &dst, const Vector4f &I, const Vector4f &N, const Float4 &eta)
{
Float4 d = dot3(N, I);
Float4 k = Float4(1.0f) - eta * eta * (Float4(1.0f) - d * d);
Int4 pos = CmpNLT(k, Float4(0.0f));
Float4 t = (eta * d + Sqrt(k));
dst.x = As<Float4>(pos & As<Int4>(eta * I.x - t * N.x));
dst.y = As<Float4>(pos & As<Int4>(eta * I.y - t * N.y));
dst.z = As<Float4>(pos & As<Int4>(eta * I.z - t * N.z));
}
void ShaderCore::refract4(Vector4f &dst, const Vector4f &I, const Vector4f &N, const Float4 &eta)
{
Float4 d = dot4(N, I);
Float4 k = Float4(1.0f) - eta * eta * (Float4(1.0f) - d * d);
Int4 pos = CmpNLT(k, Float4(0.0f));
Float4 t = (eta * d + Sqrt(k));
dst.x = As<Float4>(pos & As<Int4>(eta * I.x - t * N.x));
dst.y = As<Float4>(pos & As<Int4>(eta * I.y - t * N.y));
dst.z = As<Float4>(pos & As<Int4>(eta * I.z - t * N.z));
dst.w = As<Float4>(pos & As<Int4>(eta * I.w - t * N.w));
}
void ShaderCore::sgn(Vector4f &dst, const Vector4f &src)
{
sgn(dst.x, src.x);
sgn(dst.y, src.y);
sgn(dst.z, src.z);
sgn(dst.w, src.w);
}
void ShaderCore::isgn(Vector4f &dst, const Vector4f &src)
{
isgn(dst.x, src.x);
isgn(dst.y, src.y);
isgn(dst.z, src.z);
isgn(dst.w, src.w);
}
void ShaderCore::abs(Vector4f &dst, const Vector4f &src)
{
dst.x = Abs(src.x);
dst.y = Abs(src.y);
dst.z = Abs(src.z);
dst.w = Abs(src.w);
}
void ShaderCore::iabs(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(Abs(As<Int4>(src.x)));
dst.y = As<Float4>(Abs(As<Int4>(src.y)));
dst.z = As<Float4>(Abs(As<Int4>(src.z)));
dst.w = As<Float4>(Abs(As<Int4>(src.w)));
}
void ShaderCore::nrm2(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 dot = dot2(src, src);
Float4 rsq = reciprocalSquareRoot(dot, false, pp);
dst.x = src.x * rsq;
dst.y = src.y * rsq;
dst.z = src.z * rsq;
dst.w = src.w * rsq;
}
void ShaderCore::nrm3(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 dot = dot3(src, src);
Float4 rsq = reciprocalSquareRoot(dot, false, pp);
dst.x = src.x * rsq;
dst.y = src.y * rsq;
dst.z = src.z * rsq;
dst.w = src.w * rsq;
}
void ShaderCore::nrm4(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 dot = dot4(src, src);
Float4 rsq = reciprocalSquareRoot(dot, false, pp);
dst.x = src.x * rsq;
dst.y = src.y * rsq;
dst.z = src.z * rsq;
dst.w = src.w * rsq;
}
void ShaderCore::sincos(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = cosine_pi(src.x, pp);
dst.y = sine_pi(src.x, pp);
}
void ShaderCore::cos(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = cosine(src.x, pp);
dst.y = cosine(src.y, pp);
dst.z = cosine(src.z, pp);
dst.w = cosine(src.w, pp);
}
void ShaderCore::sin(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = sine(src.x, pp);
dst.y = sine(src.y, pp);
dst.z = sine(src.z, pp);
dst.w = sine(src.w, pp);
}
void ShaderCore::tan(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = tangent(src.x, pp);
dst.y = tangent(src.y, pp);
dst.z = tangent(src.z, pp);
dst.w = tangent(src.w, pp);
}
void ShaderCore::acos(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arccos(src.x, pp);
dst.y = arccos(src.y, pp);
dst.z = arccos(src.z, pp);
dst.w = arccos(src.w, pp);
}
void ShaderCore::asin(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arcsin(src.x, pp);
dst.y = arcsin(src.y, pp);
dst.z = arcsin(src.z, pp);
dst.w = arcsin(src.w, pp);
}
void ShaderCore::atan(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arctan(src.x, pp);
dst.y = arctan(src.y, pp);
dst.z = arctan(src.z, pp);
dst.w = arctan(src.w, pp);
}
void ShaderCore::atan2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp)
{
dst.x = arctan(src0.x, src1.x, pp);
dst.y = arctan(src0.y, src1.y, pp);
dst.z = arctan(src0.z, src1.z, pp);
dst.w = arctan(src0.w, src1.w, pp);
}
void ShaderCore::cosh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = cosineh(src.x, pp);
dst.y = cosineh(src.y, pp);
dst.z = cosineh(src.z, pp);
dst.w = cosineh(src.w, pp);
}
void ShaderCore::sinh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = sineh(src.x, pp);
dst.y = sineh(src.y, pp);
dst.z = sineh(src.z, pp);
dst.w = sineh(src.w, pp);
}
void ShaderCore::tanh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = tangenth(src.x, pp);
dst.y = tangenth(src.y, pp);
dst.z = tangenth(src.z, pp);
dst.w = tangenth(src.w, pp);
}
void ShaderCore::acosh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arccosh(src.x, pp);
dst.y = arccosh(src.y, pp);
dst.z = arccosh(src.z, pp);
dst.w = arccosh(src.w, pp);
}
void ShaderCore::asinh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arcsinh(src.x, pp);
dst.y = arcsinh(src.y, pp);
dst.z = arcsinh(src.z, pp);
dst.w = arcsinh(src.w, pp);
}
void ShaderCore::atanh(Vector4f &dst, const Vector4f &src, bool pp)
{
dst.x = arctanh(src.x, pp);
dst.y = arctanh(src.y, pp);
dst.z = arctanh(src.z, pp);
dst.w = arctanh(src.w, pp);
}
void ShaderCore::expp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel)
{
if(shaderModel < 0x0200)
{
Float4 frc = Frac(src.x);
Float4 floor = src.x - frc;
dst.x = exponential2(floor, true);
dst.y = frc;
dst.z = exponential2(src.x, true);
dst.w = Float4(1.0f);
}
else // Version >= 2.0
{
exp2x(dst, src, true); // FIXME: 10-bit precision suffices
}
}
void ShaderCore::logp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel)
{
if(shaderModel < 0x0200)
{
Float4 tmp0;
Float4 tmp1;
Float4 t;
Int4 r;
tmp0 = Abs(src.x);
tmp1 = tmp0;
// X component
r = As<Int4>(As<UInt4>(tmp0) >> 23) - Int4(127);
dst.x = Float4(r);
// Y component
dst.y = As<Float4>((As<Int4>(tmp1) & Int4(0x007FFFFF)) | As<Int4>(Float4(1.0f)));
// Z component
dst.z = logarithm2(src.x, true, true);
// W component
dst.w = 1.0f;
}
else
{
log2x(dst, src, true);
}
}
void ShaderCore::cmp0(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
cmp0(dst.x, src0.x, src1.x, src2.x);
cmp0(dst.y, src0.y, src1.y, src2.y);
cmp0(dst.z, src0.z, src1.z, src2.z);
cmp0(dst.w, src0.w, src1.w, src2.w);
}
void ShaderCore::select(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2)
{
select(dst.x, As<Int4>(src0.x), src1.x, src2.x);
select(dst.y, As<Int4>(src0.y), src1.y, src2.y);
select(dst.z, As<Int4>(src0.z), src1.z, src2.z);
select(dst.w, As<Int4>(src0.w), src1.w, src2.w);
}
void ShaderCore::extract(Float4 &dst, const Vector4f &src0, const Float4 &src1)
{
select(dst, CmpEQ(As<Int4>(src1), Int4(1)), src0.y, src0.x);
select(dst, CmpEQ(As<Int4>(src1), Int4(2)), src0.z, dst);
select(dst, CmpEQ(As<Int4>(src1), Int4(3)), src0.w, dst);
}
void ShaderCore::insert(Vector4f &dst, const Vector4f &src, const Float4 &element, const Float4 &index)
{
select(dst.x, CmpEQ(As<Int4>(index), Int4(0)), element, src.x);
select(dst.y, CmpEQ(As<Int4>(index), Int4(1)), element, src.y);
select(dst.z, CmpEQ(As<Int4>(index), Int4(2)), element, src.z);
select(dst.w, CmpEQ(As<Int4>(index), Int4(3)), element, src.w);
}
void ShaderCore::sgn(Float4 &dst, const Float4 &src)
{
Int4 neg = As<Int4>(CmpLT(src, Float4(-0.0f))) & As<Int4>(Float4(-1.0f));
Int4 pos = As<Int4>(CmpNLE(src, Float4(+0.0f))) & As<Int4>(Float4(1.0f));
dst = As<Float4>(neg | pos);
}
void ShaderCore::isgn(Float4 &dst, const Float4 &src)
{
Int4 neg = CmpLT(As<Int4>(src), Int4(0)) & Int4(-1);
Int4 pos = CmpNLE(As<Int4>(src), Int4(0)) & Int4(1);
dst = As<Float4>(neg | pos);
}
void ShaderCore::cmp0(Float4 &dst, const Float4 &src0, const Float4 &src1, const Float4 &src2)
{
Int4 pos = CmpLE(Float4(0.0f), src0);
select(dst, pos, src1, src2);
}
void ShaderCore::cmp0i(Float4 &dst, const Float4 &src0, const Float4 &src1, const Float4 &src2)
{
Int4 pos = CmpEQ(Int4(0), As<Int4>(src0));
select(dst, pos, src1, src2);
}
void ShaderCore::select(Float4 &dst, RValue<Int4> src0, const Float4 &src1, const Float4 &src2)
{
// FIXME: LLVM vector select
dst = As<Float4>((src0 & As<Int4>(src1)) | (~src0 & As<Int4>(src2)));
}
void ShaderCore::cmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control)
{
switch(control)
{
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(src0.x, src1.x));
dst.y = As<Float4>(CmpNLE(src0.y, src1.y));
dst.z = As<Float4>(CmpNLE(src0.z, src1.z));
dst.w = As<Float4>(CmpNLE(src0.w, src1.w));
break;
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(src0.x, src1.x));
dst.y = As<Float4>(CmpEQ(src0.y, src1.y));
dst.z = As<Float4>(CmpEQ(src0.z, src1.z));
dst.w = As<Float4>(CmpEQ(src0.w, src1.w));
break;
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(src0.x, src1.x));
dst.y = As<Float4>(CmpNLT(src0.y, src1.y));
dst.z = As<Float4>(CmpNLT(src0.z, src1.z));
dst.w = As<Float4>(CmpNLT(src0.w, src1.w));
break;
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(src0.x, src1.x));
dst.y = As<Float4>(CmpLT(src0.y, src1.y));
dst.z = As<Float4>(CmpLT(src0.z, src1.z));
dst.w = As<Float4>(CmpLT(src0.w, src1.w));
break;
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(src0.x, src1.x));
dst.y = As<Float4>(CmpNEQ(src0.y, src1.y));
dst.z = As<Float4>(CmpNEQ(src0.z, src1.z));
dst.w = As<Float4>(CmpNEQ(src0.w, src1.w));
break;
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(src0.x, src1.x));
dst.y = As<Float4>(CmpLE(src0.y, src1.y));
dst.z = As<Float4>(CmpLE(src0.z, src1.z));
dst.w = As<Float4>(CmpLE(src0.w, src1.w));
break;
default:
ASSERT(false);
}
}
void ShaderCore::icmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control)
{
switch(control)
{
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNLE(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNLE(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNLE(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpEQ(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpEQ(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpEQ(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNLT(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNLT(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNLT(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpLT(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpLT(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpLT(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpNEQ(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpNEQ(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpNEQ(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(As<Int4>(src0.x), As<Int4>(src1.x)));
dst.y = As<Float4>(CmpLE(As<Int4>(src0.y), As<Int4>(src1.y)));
dst.z = As<Float4>(CmpLE(As<Int4>(src0.z), As<Int4>(src1.z)));
dst.w = As<Float4>(CmpLE(As<Int4>(src0.w), As<Int4>(src1.w)));
break;
default:
ASSERT(false);
}
}
void ShaderCore::ucmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control)
{
switch(control)
{
case CONTROL_GT:
dst.x = As<Float4>(CmpNLE(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNLE(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNLE(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNLE(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case CONTROL_EQ:
dst.x = As<Float4>(CmpEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case CONTROL_GE:
dst.x = As<Float4>(CmpNLT(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNLT(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNLT(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNLT(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case CONTROL_LT:
dst.x = As<Float4>(CmpLT(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpLT(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpLT(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpLT(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case CONTROL_NE:
dst.x = As<Float4>(CmpNEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpNEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpNEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpNEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
case CONTROL_LE:
dst.x = As<Float4>(CmpLE(As<UInt4>(src0.x), As<UInt4>(src1.x)));
dst.y = As<Float4>(CmpLE(As<UInt4>(src0.y), As<UInt4>(src1.y)));
dst.z = As<Float4>(CmpLE(As<UInt4>(src0.z), As<UInt4>(src1.z)));
dst.w = As<Float4>(CmpLE(As<UInt4>(src0.w), As<UInt4>(src1.w)));
break;
default:
ASSERT(false);
}
}
void ShaderCore::all(Float4 &dst, const Vector4f &src)
{
dst = As<Float4>(As<Int4>(src.x) & As<Int4>(src.y) & As<Int4>(src.z) & As<Int4>(src.w));
}
void ShaderCore::any(Float4 &dst, const Vector4f &src)
{
dst = As<Float4>(As<Int4>(src.x) | As<Int4>(src.y) | As<Int4>(src.z) | As<Int4>(src.w));
}
void ShaderCore::bitwise_not(Vector4f &dst, const Vector4f &src)
{
dst.x = As<Float4>(As<Int4>(src.x) ^ Int4(0xFFFFFFFF));
dst.y = As<Float4>(As<Int4>(src.y) ^ Int4(0xFFFFFFFF));
dst.z = As<Float4>(As<Int4>(src.z) ^ Int4(0xFFFFFFFF));
dst.w = As<Float4>(As<Int4>(src.w) ^ Int4(0xFFFFFFFF));
}
void ShaderCore::bitwise_or(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) | As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) | As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) | As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) | As<Int4>(src1.w));
}
void ShaderCore::bitwise_xor(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) ^ As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) ^ As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) ^ As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) ^ As<Int4>(src1.w));
}
void ShaderCore::bitwise_and(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(As<Int4>(src0.x) & As<Int4>(src1.x));
dst.y = As<Float4>(As<Int4>(src0.y) & As<Int4>(src1.y));
dst.z = As<Float4>(As<Int4>(src0.z) & As<Int4>(src1.z));
dst.w = As<Float4>(As<Int4>(src0.w) & As<Int4>(src1.w));
}
void ShaderCore::equal(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(CmpEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)) &
CmpEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)) &
CmpEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)) &
CmpEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
dst.y = dst.x;
dst.z = dst.x;
dst.w = dst.x;
}
void ShaderCore::notEqual(Vector4f &dst, const Vector4f &src0, const Vector4f &src1)
{
dst.x = As<Float4>(CmpNEQ(As<UInt4>(src0.x), As<UInt4>(src1.x)) |
CmpNEQ(As<UInt4>(src0.y), As<UInt4>(src1.y)) |
CmpNEQ(As<UInt4>(src0.z), As<UInt4>(src1.z)) |
CmpNEQ(As<UInt4>(src0.w), As<UInt4>(src1.w)));
dst.y = dst.x;
dst.z = dst.x;
dst.w = dst.x;
}
}
......@@ -90,305 +90,6 @@ namespace sw
void transpose4x1(Float4 &row0, Float4 &row1, Float4 &row2, Float4 &row3);
void transpose2x4(Float4 &row0, Float4 &row1, Float4 &row2, Float4 &row3);
void transpose4xN(Float4 &row0, Float4 &row1, Float4 &row2, Float4 &row3, int N);
class Register
{
public:
Register(const Reference<Float4> &x, const Reference<Float4> &y, const Reference<Float4> &z, const Reference<Float4> &w) : x(x), y(y), z(z), w(w)
{
}
Reference<Float4> &operator[](int i)
{
switch(i)
{
default:
case 0: return x;
case 1: return y;
case 2: return z;
case 3: return w;
}
}
Register &operator=(const Register &rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
w = rhs.w;
return *this;
}
Register &operator=(const Vector4f &rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
w = rhs.w;
return *this;
}
operator Vector4f()
{
Vector4f v;
v.x = x;
v.y = y;
v.z = z;
v.w = w;
return v;
}
Reference<Float4> x;
Reference<Float4> y;
Reference<Float4> z;
Reference<Float4> w;
};
class RegisterFile
{
public:
RegisterFile(int size, bool indirectAddressable) : size(size), indirectAddressable(indirectAddressable)
{
if(indirectAddressable)
{
x = new Array<Float4>(size);
y = new Array<Float4>(size);
z = new Array<Float4>(size);
w = new Array<Float4>(size);
}
else
{
x = new Array<Float4>[size];
y = new Array<Float4>[size];
z = new Array<Float4>[size];
w = new Array<Float4>[size];
}
}
~RegisterFile()
{
if(indirectAddressable)
{
delete x;
delete y;
delete z;
delete w;
}
else
{
delete[] x;
delete[] y;
delete[] z;
delete[] w;
}
}
Register operator[](int i)
{
if(indirectAddressable)
{
return Register(x[0][i], y[0][i], z[0][i], w[0][i]);
}
else
{
return Register(x[i][0], y[i][0], z[i][0], w[i][0]);
}
}
Register operator[](RValue<Int> i)
{
ASSERT(indirectAddressable);
return Register(x[0][i], y[0][i], z[0][i], w[0][i]);
}
const Vector4f operator[](RValue<Int4> i); // Gather operation (read only).
void scatter_x(Int4 i, RValue<Float4> r);
void scatter_y(Int4 i, RValue<Float4> r);
void scatter_z(Int4 i, RValue<Float4> r);
void scatter_w(Int4 i, RValue<Float4> r);
protected:
const int size;
const bool indirectAddressable;
Array<Float4> *x;
Array<Float4> *y;
Array<Float4> *z;
Array<Float4> *w;
};
template<int S, bool I = false>
class RegisterArray : public RegisterFile
{
public:
RegisterArray(bool indirectAddressable = I) : RegisterFile(S, indirectAddressable)
{
}
};
class ShaderCore
{
enum Control
{
CONTROL_RESERVED0,
CONTROL_GT,
CONTROL_EQ,
CONTROL_GE,
CONTROL_LT,
CONTROL_NE,
CONTROL_LE,
CONTROL_RESERVED1
};
public:
void mov(Vector4f &dst, const Vector4f &src, bool integerDestination = false);
void neg(Vector4f &dst, const Vector4f &src);
void ineg(Vector4f &dst, const Vector4f &src);
void f2b(Vector4f &dst, const Vector4f &src);
void b2f(Vector4f &dst, const Vector4f &src);
void f2i(Vector4f &dst, const Vector4f &src);
void i2f(Vector4f &dst, const Vector4f &src);
void f2u(Vector4f &dst, const Vector4f &src);
void u2f(Vector4f &dst, const Vector4f &src);
void i2b(Vector4f &dst, const Vector4f &src);
void b2i(Vector4f &dst, const Vector4f &src);
void add(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void iadd(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void sub(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void isub(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void mad(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void imad(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void mul(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void imul(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void rcpx(Vector4f &dst, const Vector4f &src, bool pp = false);
void div(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void idiv(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void udiv(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void mod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void imod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void umod(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void shl(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void ishr(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void ushr(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void rsqx(Vector4f &dst, const Vector4f &src, bool pp = false);
void sqrt(Vector4f &dst, const Vector4f &src, bool pp = false);
void rsq(Vector4f &dst, const Vector4f &src, bool pp = false);
void len2(Float4 &dst, const Vector4f &src, bool pp = false);
void len3(Float4 &dst, const Vector4f &src, bool pp = false);
void len4(Float4 &dst, const Vector4f &src, bool pp = false);
void dist1(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void dist2(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void dist3(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void dist4(Float4 &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void dp1(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void dp2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void dp2add(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void dp3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void dp4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void det2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void det3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void det4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2, const Vector4f &src3);
void min(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void imin(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void umin(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void max(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void imax(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void umax(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void slt(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void step(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void exp2x(Vector4f &dst, const Vector4f &src, bool pp = false);
void exp2(Vector4f &dst, const Vector4f &src, bool pp = false);
void exp(Vector4f &dst, const Vector4f &src, bool pp = false);
void log2x(Vector4f &dst, const Vector4f &src, bool pp = false);
void log2(Vector4f &dst, const Vector4f &src, bool pp = false);
void log(Vector4f &dst, const Vector4f &src, bool pp = false);
void lit(Vector4f &dst, const Vector4f &src);
void att(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void lrp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void isinf(Vector4f &dst, const Vector4f &src);
void isnan(Vector4f &dst, const Vector4f &src);
void smooth(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void packHalf2x16(Vector4f &dst, const Vector4f &src);
void unpackHalf2x16(Vector4f &dst, const Vector4f &src);
void packSnorm2x16(Vector4f &dst, const Vector4f &src);
void packUnorm2x16(Vector4f &dst, const Vector4f &src);
void unpackSnorm2x16(Vector4f &dst, const Vector4f &src);
void unpackUnorm2x16(Vector4f &dst, const Vector4f &src);
void frc(Vector4f &dst, const Vector4f &src);
void trunc(Vector4f &dst, const Vector4f &src);
void floor(Vector4f &dst, const Vector4f &src);
void round(Vector4f &dst, const Vector4f &src);
void roundEven(Vector4f &dst, const Vector4f &src);
void ceil(Vector4f &dst, const Vector4f &src);
void powx(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void pow(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void crs(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void forward1(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void forward2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void forward3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void forward4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void reflect1(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void reflect2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void reflect3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void reflect4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void refract1(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Float4 &src2);
void refract2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Float4 &src2);
void refract3(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Float4 &src2);
void refract4(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Float4 &src2);
void sgn(Vector4f &dst, const Vector4f &src);
void isgn(Vector4f &dst, const Vector4f &src);
void abs(Vector4f &dst, const Vector4f &src);
void iabs(Vector4f &dst, const Vector4f &src);
void nrm2(Vector4f &dst, const Vector4f &src, bool pp = false);
void nrm3(Vector4f &dst, const Vector4f &src, bool pp = false);
void nrm4(Vector4f &dst, const Vector4f &src, bool pp = false);
void sincos(Vector4f &dst, const Vector4f &src, bool pp = false);
void cos(Vector4f &dst, const Vector4f &src, bool pp = false);
void sin(Vector4f &dst, const Vector4f &src, bool pp = false);
void tan(Vector4f &dst, const Vector4f &src, bool pp = false);
void acos(Vector4f &dst, const Vector4f &src, bool pp = false);
void asin(Vector4f &dst, const Vector4f &src, bool pp = false);
void atan(Vector4f &dst, const Vector4f &src, bool pp = false);
void atan2(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, bool pp = false);
void cosh(Vector4f &dst, const Vector4f &src, bool pp = false);
void sinh(Vector4f &dst, const Vector4f &src, bool pp = false);
void tanh(Vector4f &dst, const Vector4f &src, bool pp = false);
void acosh(Vector4f &dst, const Vector4f &src, bool pp = false);
void asinh(Vector4f &dst, const Vector4f &src, bool pp = false);
void atanh(Vector4f &dst, const Vector4f &src, bool pp = false);
void expp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel);
void logp(Vector4f &dst, const Vector4f &src, unsigned short shaderModel);
void cmp0(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void cmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control);
void icmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control);
void ucmp(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, Control control);
void select(Vector4f &dst, const Vector4f &src0, const Vector4f &src1, const Vector4f &src2);
void extract(Float4 &dst, const Vector4f &src0, const Float4 &src1);
void insert(Vector4f &dst, const Vector4f &src, const Float4 &element, const Float4 &index);
void all(Float4 &dst, const Vector4f &src);
void any(Float4 &dst, const Vector4f &src);
void bitwise_not(Vector4f &dst, const Vector4f &src);
void bitwise_or(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void bitwise_xor(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void bitwise_and(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void equal(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
void notEqual(Vector4f &dst, const Vector4f &src0, const Vector4f &src1);
private:
void sgn(Float4 &dst, const Float4 &src);
void isgn(Float4 &dst, const Float4 &src);
void cmp0(Float4 &dst, const Float4 &src0, const Float4 &src1, const Float4 &src2);
void cmp0i(Float4 &dst, const Float4 &src0, const Float4 &src1, const Float4 &src2);
void select(Float4 &dst, RValue<Int4> src0, const Float4 &src1, const Float4 &src2);
void floatToHalfBits(Float4& dst, const Float4& floatBits, bool storeInUpperBits);
void halfToFloatBits(Float4& dst, const Float4& halfBits);
};
}
#endif // sw_ShaderCore_hpp
......@@ -22,7 +22,7 @@ namespace sw
{
struct Stream;
class VertexProgram : public VertexRoutine, public ShaderCore
class VertexProgram : public VertexRoutine
{
public:
VertexProgram(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment