Remove remaining usages of skvx::mad
This CL attempts to remove the remaining subset of skvx::mad usages. https://skia-review.googlesource.com/c/skia/+/304853 removes all usages of skvx::mad but causes small differences in rendering, so it is not suitable for landing. https://skia-review.googlesource.com/c/skia/+/306702/ removes all non-nested usages of skvx::mad Change-Id: Iab5d4cfd0feb856c38b3ebbfe3bf3ed5aad20fe6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306722 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Commit-Queue: Elliot Evans <elliotevans@google.com>
This commit is contained in:
parent
73a8cc5712
commit
6b2602ed2d
@ -307,9 +307,6 @@ SIT Vec<1,int> lrint(const Vec<1,T>& x) { return (int)std::lrint(x.val); }
|
||||
|
||||
SIT Vec<1,T> rcp(const Vec<1,T>& x) { return 1 / x.val; }
|
||||
SIT Vec<1,T> rsqrt(const Vec<1,T>& x) { return rcp(sqrt(x)); }
|
||||
SIT Vec<1,T> mad(const Vec<1,T>& f,
|
||||
const Vec<1,T>& m,
|
||||
const Vec<1,T>& a) { return f*m+a; }
|
||||
|
||||
// All default N != 1 implementations just recurse on lo and hi halves.
|
||||
SINT Vec<N,T> if_then_else(const Vec<N,M<T>>& cond, const Vec<N,T>& t, const Vec<N,T>& e) {
|
||||
@ -371,9 +368,6 @@ SINT Vec<N,int> lrint(const Vec<N,T>& x) { return join(lrint(x.lo), lrint(x.hi))
|
||||
|
||||
SINT Vec<N,T> rcp(const Vec<N,T>& x) { return join( rcp(x.lo), rcp(x.hi)); }
|
||||
SINT Vec<N,T> rsqrt(const Vec<N,T>& x) { return join(rsqrt(x.lo), rsqrt(x.hi)); }
|
||||
SINT Vec<N,T> mad(const Vec<N,T>& f,
|
||||
const Vec<N,T>& m,
|
||||
const Vec<N,T>& a) { return join(mad(f.lo, m.lo, a.lo), mad(f.hi, m.hi, a.hi)); }
|
||||
|
||||
|
||||
// Scalar/vector operations just splat the scalar to a vector...
|
||||
@ -412,14 +406,6 @@ SINTU Vec<N,T> min(const Vec<N,T>& x, U y) { return min(x, Vec<N,T>(y)
|
||||
SINTU Vec<N,T> max(const Vec<N,T>& x, U y) { return max(x, Vec<N,T>(y)); }
|
||||
SINTU Vec<N,T> pow(const Vec<N,T>& x, U y) { return pow(x, Vec<N,T>(y)); }
|
||||
|
||||
// All vector/scalar combinations for mad() with at least one vector.
|
||||
SINTU Vec<N,T> mad(U f, const Vec<N,T>& m, const Vec<N,T>& a) { return Vec<N,T>(f)*m + a; }
|
||||
SINTU Vec<N,T> mad(const Vec<N,T>& f, U m, const Vec<N,T>& a) { return f*Vec<N,T>(m) + a; }
|
||||
SINTU Vec<N,T> mad(const Vec<N,T>& f, const Vec<N,T>& m, U a) { return f*m + Vec<N,T>(a); }
|
||||
SINTU Vec<N,T> mad(const Vec<N,T>& f, U m, U a) { return f*Vec<N,T>(m) + Vec<N,T>(a); }
|
||||
SINTU Vec<N,T> mad(U f, const Vec<N,T>& m, U a) { return Vec<N,T>(f)*m + Vec<N,T>(a); }
|
||||
SINTU Vec<N,T> mad(U f, U m, const Vec<N,T>& a) { return Vec<N,T>(f)*Vec<N,T>(m) + a; }
|
||||
|
||||
// The various op= operators, for vectors...
|
||||
SINT Vec<N,T>& operator+=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x + y); }
|
||||
SINT Vec<N,T>& operator-=(Vec<N,T>& x, const Vec<N,T>& y) { return (x = x - y); }
|
||||
@ -706,11 +692,6 @@ static inline Vec<N,uint8_t> approx_scale(const Vec<N,uint8_t>& x, const Vec<N,u
|
||||
static inline Vec<4,float> rsqrt(const Vec<4,float>& x) {
|
||||
return 1.0f / sqrt(x);
|
||||
}
|
||||
static inline Vec<4,float> mad(const Vec<4,float>& f,
|
||||
const Vec<4,float>& m,
|
||||
const Vec<4,float>& a) {
|
||||
return f*m+a;
|
||||
}
|
||||
|
||||
static inline Vec<2,double> min(const Vec<2,double>& x, const Vec<2,double>& y) {
|
||||
return to_vec<2,double>(wasm_f64x2_min(to_vext(x), to_vext(y)));
|
||||
@ -730,14 +711,6 @@ static inline Vec<N,uint8_t> approx_scale(const Vec<N,uint8_t>& x, const Vec<N,u
|
||||
static inline Vec<2,double> rsqrt(const Vec<2,double>& x) {
|
||||
return 1.0f / sqrt(x);
|
||||
}
|
||||
static inline Vec<2,double> mad(const Vec<2,double>& f,
|
||||
const Vec<2,double>& m,
|
||||
const Vec<2,double>& a) {
|
||||
return to_vec<2,double>(wasm_f64x2_add(
|
||||
wasm_f64x2_mul(to_vext(f), to_vext(m)),
|
||||
to_vext(a)
|
||||
));
|
||||
}
|
||||
|
||||
static inline bool any(const Vec<4,int32_t>& x) {
|
||||
return wasm_i32x4_any_true(to_vext(x));
|
||||
|
@ -85,7 +85,6 @@ int main() {
|
||||
|
||||
//vec1 = skvx::rcp(vec1); //GOOD (FIXED) previous: N/A-BAD, doesn't use SIMD div
|
||||
//vec1 = skvx::rsqrt(vec1); //GOOD (FIXED) previous: BAD, doesn't use SIMD sqrt or div
|
||||
//vec1 = skvx::mad(vec1, vec2, vec1); //GOOD (FIXED) previous: BAD doesn't used SIMD add or mul
|
||||
|
||||
//vec1 = skvx::if_then_else(vec1, vec1, vec2); //N/A
|
||||
|
||||
|
@ -82,8 +82,6 @@ int main() {
|
||||
|
||||
//vec1 = skvx::rcp(vec1); //N/A
|
||||
//vec1 = skvx::rsqrt(vec1); //N/A
|
||||
//vec1 = skvx::mad(vec1, vec2, vec1); //???
|
||||
// note: skvx::mad is probably not used in practice for integers
|
||||
|
||||
//vec1 = skvx::if_then_else(vec1, vec1, vec2); //???
|
||||
|
||||
|
@ -48,7 +48,7 @@ SkM44& SkM44::setConcat(const SkM44& a, const SkM44& b) {
|
||||
sk4f c3 = sk4f::Load(a.fMat + 12);
|
||||
|
||||
auto compute = [&](sk4f r) {
|
||||
return skvx::mad(c0, r[0], skvx::mad(c1, r[1], skvx::mad(c2, r[2], c3 * r[3])));
|
||||
return c0*r[0] + (c1*r[1] + (c2*r[2] + c3*r[3]));
|
||||
};
|
||||
|
||||
sk4f m0 = compute(sk4f::Load(b.fMat + 0));
|
||||
@ -69,7 +69,7 @@ SkM44& SkM44::preConcat(const SkMatrix& b) {
|
||||
sk4f c3 = sk4f::Load(fMat + 12);
|
||||
|
||||
auto compute = [&](float r0, float r1, float r3) {
|
||||
return skvx::mad(c0, r0, skvx::mad(c1, r1, c3 * r3));
|
||||
return (c0*r0 + (c1*r1 + c3*r3));
|
||||
};
|
||||
|
||||
sk4f m0 = compute(b[0], b[3], b[6]);
|
||||
@ -89,16 +89,16 @@ SkM44& SkM44::preTranslate(SkScalar x, SkScalar y, SkScalar z) {
|
||||
sk4f c3 = sk4f::Load(fMat + 12);
|
||||
|
||||
// only need to update the last column
|
||||
skvx::mad(c0, x, skvx::mad(c1, y, skvx::mad(c2, z, c3))).store(fMat + 12);
|
||||
(c0*x + (c1*y + (c2*z + c3))).store(fMat + 12);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkM44& SkM44::postTranslate(SkScalar x, SkScalar y, SkScalar z) {
|
||||
sk4f t = { x, y, z, 0 };
|
||||
(t*fMat[ 3] + sk4f::Load(fMat + 0)).store(fMat + 0);
|
||||
(t*fMat[ 7] + sk4f::Load(fMat + 4)).store(fMat + 4);
|
||||
(t*fMat[11] + sk4f::Load(fMat + 8)).store(fMat + 8);
|
||||
(t*fMat[15] + sk4f::Load(fMat + 12)).store(fMat + 12);
|
||||
(t * fMat[ 3] + sk4f::Load(fMat + 0)).store(fMat + 0);
|
||||
(t * fMat[ 7] + sk4f::Load(fMat + 4)).store(fMat + 4);
|
||||
(t * fMat[11] + sk4f::Load(fMat + 8)).store(fMat + 8);
|
||||
(t * fMat[15] + sk4f::Load(fMat + 12)).store(fMat + 12);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ SkV4 SkM44::map(float x, float y, float z, float w) const {
|
||||
sk4f c3 = sk4f::Load(fMat + 12);
|
||||
|
||||
SkV4 v;
|
||||
skvx::mad(c0, x, skvx::mad(c1, y, skvx::mad(c2, z, c3 * w))).store(&v.x);
|
||||
(c0*x + (c1*y + (c2*z + c3*w))).store(&v.x);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,10 @@ static void map_rect_translate_scale(const SkRect& rect, const SkMatrix& m,
|
||||
|
||||
static void map_quad_general(const V4f& qx, const V4f& qy, const SkMatrix& m,
|
||||
V4f* xs, V4f* ys, V4f* ws) {
|
||||
*xs = mad(m.getScaleX(), qx, mad(m.getSkewX(), qy, m.getTranslateX()));
|
||||
*ys = mad(m.getSkewY(), qx, mad(m.getScaleY(), qy, m.getTranslateY()));
|
||||
*xs = m.getScaleX() * qx + (m.getSkewX() * qy + m.getTranslateX());
|
||||
*ys = m.getSkewY() * qx + (m.getScaleY() * qy + m.getTranslateY());
|
||||
if (m.hasPerspective()) {
|
||||
V4f w = mad(m.getPerspX(), qx,
|
||||
mad(m.getPerspY(), qy, m.get(SkMatrix::kMPersp2)));
|
||||
V4f w = m.getPerspX() * qx + (m.getPerspY() * qy + m.get(SkMatrix::kMPersp2));
|
||||
if (ws) {
|
||||
// Output the calculated w coordinates
|
||||
*ws = w;
|
||||
|
@ -685,7 +685,7 @@ void TessellationHelper::EdgeEquations::reset(const EdgeVectors& edgeVectors) {
|
||||
|
||||
V4f c = dx*edgeVectors.fY2D - dy*edgeVectors.fX2D;
|
||||
// Make sure normals point into the shape
|
||||
V4f test = mad(dy, next_cw(edgeVectors.fX2D), mad(-dx, next_cw(edgeVectors.fY2D), c));
|
||||
V4f test = dy * next_cw(edgeVectors.fX2D) + (-dx * next_cw(edgeVectors.fY2D) + c);
|
||||
if (any(test < -kDistTolerance)) {
|
||||
fA = -dy;
|
||||
fB = dx;
|
||||
@ -699,10 +699,10 @@ void TessellationHelper::EdgeEquations::reset(const EdgeVectors& edgeVectors) {
|
||||
|
||||
V4f TessellationHelper::EdgeEquations::estimateCoverage(const V4f& x2d, const V4f& y2d) const {
|
||||
// Calculate distance of the 4 inset points (px, py) to the 4 edges
|
||||
V4f d0 = mad(fA[0], x2d, mad(fB[0], y2d, fC[0]));
|
||||
V4f d1 = mad(fA[1], x2d, mad(fB[1], y2d, fC[1]));
|
||||
V4f d2 = mad(fA[2], x2d, mad(fB[2], y2d, fC[2]));
|
||||
V4f d3 = mad(fA[3], x2d, mad(fB[3], y2d, fC[3]));
|
||||
V4f d0 = fA[0]*x2d + (fB[0]*y2d + fC[0]);
|
||||
V4f d1 = fA[1]*x2d + (fB[1]*y2d + fC[1]);
|
||||
V4f d2 = fA[2]*x2d + (fB[2]*y2d + fC[2]);
|
||||
V4f d3 = fA[3]*x2d + (fB[3]*y2d + fC[3]);
|
||||
|
||||
// For each point, pretend that there's a rectangle that touches e0 and e3 on the horizontal
|
||||
// axis, so its width is "approximately" d0 + d3, and it touches e1 and e2 on the vertical axis
|
||||
|
@ -127,8 +127,6 @@ DEF_TEST(SkVx, r) {
|
||||
REPORTER_ASSERT(r, all(float4::Load(buf+0) == float4{2,3,4,5}));
|
||||
REPORTER_ASSERT(r, all(float4::Load(buf+2) == float4{4,5,5,6}));
|
||||
|
||||
REPORTER_ASSERT(r, all(mad(float4{1,2,3,4}, 2.0f, 3.0f) == float4{5,7,9,11}));
|
||||
|
||||
REPORTER_ASSERT(r, all(skvx::shuffle<2,1,0,3> (float4{1,2,3,4}) == float4{3,2,1,4}));
|
||||
REPORTER_ASSERT(r, all(skvx::shuffle<2,1> (float4{1,2,3,4}) == float2{3,2}));
|
||||
REPORTER_ASSERT(r, all(skvx::shuffle<3,3,3,3> (float4{1,2,3,4}) == float4{4,4,4,4}));
|
||||
|
Loading…
Reference in New Issue
Block a user