2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2009-02-09 21:15:56 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* This Program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* This Program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GSVector.h"
|
|
|
|
|
2012-01-05 02:40:24 +00:00
|
|
|
__aligned(struct, 32) GSVertexSW
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2012-01-08 17:10:00 +00:00
|
|
|
GSVector4 p, t, c, _pad;
|
2011-02-07 01:59:05 +00:00
|
|
|
|
2011-03-09 11:52:53 +00:00
|
|
|
__forceinline GSVertexSW() {}
|
|
|
|
__forceinline GSVertexSW(const GSVertexSW& v) {*this = v;}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2011-03-12 22:10:58 +00:00
|
|
|
__forceinline static GSVertexSW zero()
|
|
|
|
{
|
|
|
|
GSVertexSW v;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2011-03-12 22:10:58 +00:00
|
|
|
v.p = GSVector4::zero();
|
|
|
|
v.t = GSVector4::zero();
|
|
|
|
v.c = GSVector4::zero();
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
__forceinline void operator = (const GSVertexSW& v)
|
|
|
|
{
|
|
|
|
p = v.p;
|
|
|
|
t = v.t;
|
|
|
|
c = v.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline void operator += (const GSVertexSW& v)
|
|
|
|
{
|
|
|
|
p += v.p;
|
|
|
|
t += v.t;
|
|
|
|
c += v.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline friend GSVertexSW operator + (const GSVertexSW& a, const GSVertexSW& b)
|
|
|
|
{
|
|
|
|
GSVertexSW v;
|
|
|
|
|
|
|
|
v.p = a.p + b.p;
|
|
|
|
v.t = a.t + b.t;
|
|
|
|
v.c = a.c + b.c;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline friend GSVertexSW operator - (const GSVertexSW& a, const GSVertexSW& b)
|
|
|
|
{
|
|
|
|
GSVertexSW v;
|
|
|
|
|
|
|
|
v.p = a.p - b.p;
|
|
|
|
v.t = a.t - b.t;
|
|
|
|
v.c = a.c - b.c;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline friend GSVertexSW operator * (const GSVertexSW& a, const GSVector4& b)
|
|
|
|
{
|
|
|
|
GSVertexSW v;
|
|
|
|
|
|
|
|
v.p = a.p * b;
|
|
|
|
v.t = a.t * b;
|
|
|
|
v.c = a.c * b;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
__forceinline friend GSVertexSW operator / (const GSVertexSW& a, const GSVector4& b)
|
|
|
|
{
|
|
|
|
GSVertexSW v;
|
|
|
|
|
|
|
|
v.p = a.p / b;
|
|
|
|
v.t = a.t / b;
|
|
|
|
v.c = a.c / b;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
static bool IsQuad(const GSVertexSW* v, int& tl, int& br)
|
|
|
|
{
|
|
|
|
GSVector4 v0 = v[0].p.xyxy(v[0].t);
|
|
|
|
GSVector4 v1 = v[1].p.xyxy(v[1].t);
|
|
|
|
GSVector4 v2 = v[2].p.xyxy(v[2].t);
|
|
|
|
|
|
|
|
GSVector4 v01 = v0 == v1;
|
|
|
|
GSVector4 v12 = v1 == v2;
|
|
|
|
GSVector4 v02 = v0 == v2;
|
|
|
|
|
|
|
|
GSVector4 vtl, vbr;
|
|
|
|
|
|
|
|
GSVector4 test;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
if(v12.allfalse())
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
test = (v01 ^ v02) & (v01 ^ v02.zwxy());
|
|
|
|
vtl = v0;
|
|
|
|
vbr = v1 + (v2 - v0);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
else if(v02.allfalse())
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
test = (v01 ^ v12) & (v01 ^ v12.zwxy());
|
|
|
|
vtl = v1;
|
|
|
|
vbr = v0 + (v2 - v1);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 1;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
else if(v01.allfalse())
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
test = (v02 ^ v12) & (v02 ^ v12.zwxy());
|
|
|
|
vtl = v2;
|
|
|
|
vbr = v0 + (v1 - v2);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 2;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!test.alltrue())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
tl = i;
|
|
|
|
|
|
|
|
GSVector4 v3 = v[3].p.xyxy(v[3].t);
|
|
|
|
GSVector4 v4 = v[4].p.xyxy(v[4].t);
|
|
|
|
GSVector4 v5 = v[5].p.xyxy(v[5].t);
|
|
|
|
|
|
|
|
GSVector4 v34 = v3 == v4;
|
|
|
|
GSVector4 v45 = v4 == v5;
|
|
|
|
GSVector4 v35 = v3 == v5;
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
if(v34.allfalse())
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-03-22 13:10:31 +00:00
|
|
|
test = (v35 ^ v45) & (v35 ^ v45.zwxy()) & (vtl + v5 == v3 + v4) & (vbr == v5);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 5;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
else if(v35.allfalse())
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-03-22 13:10:31 +00:00
|
|
|
test = (v34 ^ v45) & (v34 ^ v45.zwxy()) & (vtl + v4 == v3 + v5) & (vbr == v4);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 4;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
else if(v45.allfalse())
|
|
|
|
{
|
2009-03-22 13:10:31 +00:00
|
|
|
test = (v34 ^ v35) & (v34 ^ v35.zwxy()) & (vtl + v3 == v5 + v4) & (vbr == v3);
|
2010-04-25 00:31:27 +00:00
|
|
|
i = 3;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!test.alltrue())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
br = i;
|
|
|
|
|
2011-03-12 22:10:58 +00:00
|
|
|
#if _M_SSE >= 0x500
|
|
|
|
|
|
|
|
{
|
|
|
|
// p.z, p.w, t.z, t.w, c.x, c.y, c.z, c.w
|
|
|
|
|
|
|
|
GSVector8 v0 = GSVector8(v[0].p.zwzw(v[0].t), v[0].c);
|
|
|
|
GSVector8 v1 = GSVector8(v[1].p.zwzw(v[1].t), v[1].c);
|
|
|
|
GSVector8 v2 = GSVector8(v[2].p.zwzw(v[2].t), v[2].c);
|
|
|
|
GSVector8 v3 = GSVector8(v[3].p.zwzw(v[3].t), v[3].c);
|
|
|
|
GSVector8 v4 = GSVector8(v[4].p.zwzw(v[4].t), v[4].c);
|
|
|
|
GSVector8 v5 = GSVector8(v[5].p.zwzw(v[5].t), v[5].c);
|
|
|
|
|
|
|
|
GSVector8 test = ((v0 == v1) & (v0 == v2)) & ((v0 == v3) & (v0 == v4)) & (v0 == v5);
|
|
|
|
|
|
|
|
return test.alltrue();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
v0 = v[0].p.zwzw(v[0].t);
|
|
|
|
v1 = v[1].p.zwzw(v[1].t);
|
|
|
|
v2 = v[2].p.zwzw(v[2].t);
|
|
|
|
v3 = v[3].p.zwzw(v[3].t);
|
|
|
|
v4 = v[4].p.zwzw(v[4].t);
|
|
|
|
v5 = v[5].p.zwzw(v[5].t);
|
|
|
|
|
|
|
|
test = ((v0 == v1) & (v0 == v2)) & ((v0 == v3) & (v0 == v4)) & (v0 == v5);
|
|
|
|
|
|
|
|
if(!test.alltrue())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
v0 = v[0].c;
|
|
|
|
v1 = v[1].c;
|
|
|
|
v2 = v[2].c;
|
|
|
|
v3 = v[3].c;
|
|
|
|
v4 = v[4].c;
|
|
|
|
v5 = v[5].c;
|
|
|
|
|
|
|
|
test = ((v0 == v1) & (v0 == v2)) & ((v0 == v3) & (v0 == v4)) & (v0 == v5);
|
|
|
|
|
|
|
|
if(!test.alltrue())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2011-03-12 22:10:58 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|