interp: Correct Vsgn out of swizzle bounds.

This commit is contained in:
Unknown W. Brackets committed 2019-03-30 12:26:09 -07:00
1 parent d708e2ebd9
commit ad7e322c7e
2 files changed
+9 -3

No files matched your search

+1 -1
View File
@@ -1841,7 +1841,7 @@ namespace MIPSComp {
void IRFrontend::Comp_Vsgn(MIPSOpcode op) {
CONDITIONAL_DISABLE(VFPU_VEC);
if (js.HasUnknownPrefix()) {
if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) {
DISABLE;
}
+8 -2
View File
@@ -659,14 +659,20 @@ namespace MIPSInt
int vs = _VS;
VectorSize sz = GetVecSize(op);
ReadVector(s, sz, vs);
ApplySwizzleS(s, sz);
// Not sure who would do this, but using abs/neg allows a compare against 3 or -3.
u32 tprefixRemove = VFPU_ANY_SWIZZLE();
u32 tprefixAdd = VFPU_CONST(1, 1, 1, 1) | VFPU_SWIZZLE(0, 0, 0, 0);
ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), sz);
for (int i = 0; i < GetNumVectorElements(sz); i++) {
int n = GetNumVectorElements(sz);
if (n < 4) {
// Compare with a swizzled value out of bounds always produces 0.
memcpy(&s[n], &t[n], sizeof(float) * (4 - n));
}
ApplySwizzleS(s, V_Quad);
for (int i = 0; i < n; i++) {
float diff = s[i] - t[i];
// To handle NaNs correctly, we do this with integer hackery
u32 val;