citra-emu
/
citra-canary
Archived
1
0
Fork 0

Merge pull request #1479 from JayFoxRox/mad-encoding

Fix MAD/MADI encoding
This commit is contained in:
bunnei 2016-03-16 13:17:07 -04:00
commit caba93fa45
4 changed files with 44 additions and 32 deletions

2
externals/nihstro vendored

@ -1 +1 @@
Subproject commit 445cba0b2ff8d348368e32698e4760a670260bfc Subproject commit 26a0a04a458df2b9ba6e39608bee183d8a0a00ec

View File

@ -179,9 +179,17 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con
AlignToColumn(kOutputColumnWidth); AlignToColumn(kOutputColumnWidth);
print_input(output, src1, swizzle.negate_src1, SelectorToString(swizzle.src1_selector)); print_input(output, src1, swizzle.negate_src1, SelectorToString(swizzle.src1_selector));
AlignToColumn(kInputOperandColumnWidth); AlignToColumn(kInputOperandColumnWidth);
if (src_is_inverted) {
print_input(output, src2, swizzle.negate_src2, SelectorToString(swizzle.src2_selector)); print_input(output, src2, swizzle.negate_src2, SelectorToString(swizzle.src2_selector));
} else {
print_input(output, src2, swizzle.negate_src2, SelectorToString(swizzle.src2_selector), true, instr.mad.AddressRegisterName());
}
AlignToColumn(kInputOperandColumnWidth); AlignToColumn(kInputOperandColumnWidth);
if (src_is_inverted) {
print_input(output, src3, swizzle.negate_src3, SelectorToString(swizzle.src3_selector), true, instr.mad.AddressRegisterName());
} else {
print_input(output, src3, swizzle.negate_src3, SelectorToString(swizzle.src3_selector)); print_input(output, src3, swizzle.negate_src3, SelectorToString(swizzle.src3_selector));
}
AlignToColumn(kInputOperandColumnWidth); AlignToColumn(kInputOperandColumnWidth);
break; break;
} }

View File

@ -413,9 +413,12 @@ void RunInterpreter(UnitState<Debug>& state) {
bool is_inverted = (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI); bool is_inverted = (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI);
const int address_offset = (instr.mad.address_register_index == 0)
? 0 : state.address_registers[instr.mad.address_register_index - 1];
const float24* src1_ = LookupSourceRegister(instr.mad.GetSrc1(is_inverted)); const float24* src1_ = LookupSourceRegister(instr.mad.GetSrc1(is_inverted));
const float24* src2_ = LookupSourceRegister(instr.mad.GetSrc2(is_inverted)); const float24* src2_ = LookupSourceRegister(instr.mad.GetSrc2(is_inverted) + (!is_inverted * address_offset));
const float24* src3_ = LookupSourceRegister(instr.mad.GetSrc3(is_inverted)); const float24* src3_ = LookupSourceRegister(instr.mad.GetSrc3(is_inverted) + ( is_inverted * address_offset));
const bool negate_src1 = ((bool)swizzle.negate_src1 != false); const bool negate_src1 = ((bool)swizzle.negate_src1 != false);
const bool negate_src2 = ((bool)swizzle.negate_src2 != false); const bool negate_src2 = ((bool)swizzle.negate_src2 != false);

View File

@ -160,23 +160,25 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source
ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type"); ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type");
unsigned operand_desc_id; unsigned operand_desc_id;
if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD ||
instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) {
// The MAD and MADI instructions do not use the address offset registers, so loading the
// source is a bit simpler here
operand_desc_id = instr.mad.operand_desc_id;
// Load the source
MOVAPS(dest, MDisp(src_ptr, src_offset_disp));
} else {
operand_desc_id = instr.common.operand_desc_id;
const bool is_inverted = (0 != (instr.opcode.Value().GetInfo().subtype & OpCode::Info::SrcInversed)); const bool is_inverted = (0 != (instr.opcode.Value().GetInfo().subtype & OpCode::Info::SrcInversed));
unsigned offset_src = is_inverted ? 2 : 1;
if (src_num == offset_src && instr.common.address_register_index != 0) { unsigned address_register_index;
switch (instr.common.address_register_index) { unsigned offset_src;
if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD ||
instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) {
operand_desc_id = instr.mad.operand_desc_id;
offset_src = is_inverted ? 3 : 2;
address_register_index = instr.mad.address_register_index;
} else {
operand_desc_id = instr.common.operand_desc_id;
offset_src = is_inverted ? 2 : 1;
address_register_index = instr.common.address_register_index;
}
if (src_num == offset_src && address_register_index != 0) {
switch (address_register_index) {
case 1: // address offset 1 case 1: // address offset 1
MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, SCALE_1, src_offset_disp)); MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, SCALE_1, src_offset_disp));
break; break;
@ -194,7 +196,6 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source
// Load the source // Load the source
MOVAPS(dest, MDisp(src_ptr, src_offset_disp)); MOVAPS(dest, MDisp(src_ptr, src_offset_disp));
} }
}
SwizzlePattern swiz = { g_state.vs.swizzle_data[operand_desc_id] }; SwizzlePattern swiz = { g_state.vs.swizzle_data[operand_desc_id] };