Skip to content

Commit

Permalink
Fix ppu_thread::get_stack_arg regression
Browse files Browse the repository at this point in the history
Matches #5325
  • Loading branch information
elad335 committed Feb 9, 2019
1 parent fd67eff commit 75d4629
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions rpcs3/Emu/Cell/PPUCallback.h
Expand Up @@ -18,6 +18,7 @@ namespace ppu_cb_detail
// This constant can be increased if necessary.
// It's possible to calculate suitable stack frame size in template, but too complicated.
static const auto FIXED_STACK_FRAME_SIZE = 0x90;
static const auto FIXED_STACK_FRAME_GAP = 0x70;

template<typename T, _func_arg_type type, u32 g_count, u32 f_count, u32 v_count>
struct _func_arg
Expand Down Expand Up @@ -62,7 +63,7 @@ namespace ppu_cb_detail

static inline void set_value(ppu_thread& CPU, const T& arg)
{
const s64 stack_pos = (g_count - 1) * 0x8 + 0x30 - FIXED_STACK_FRAME_SIZE;
const s64 stack_pos = (g_count - 1) * 0x8 + FIXED_STACK_FRAME_GAP - FIXED_STACK_FRAME_SIZE;
static_assert(stack_pos < 0, "TODO: Increase FIXED_STACK_FRAME_SIZE (arg count limit broken)");
vm::write64(CPU.gpr[1] + stack_pos, ppu_gpr_cast(arg)); // TODO
}
Expand Down Expand Up @@ -167,9 +168,9 @@ namespace ppu_cb_detail
FORCE_INLINE static void call(ppu_thread& CPU, u32 pc, u32 rtoc, T... args)
{
const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...);
CPU.gpr[1] -= stack ? FIXED_STACK_FRAME_SIZE : 0x70; // create reserved area
CPU.gpr[1] -= stack ? FIXED_STACK_FRAME_SIZE : FIXED_STACK_FRAME_GAP; // create reserved area
CPU.fast_call(pc, rtoc);
CPU.gpr[1] += stack ? FIXED_STACK_FRAME_SIZE : 0x70;
CPU.gpr[1] += stack ? FIXED_STACK_FRAME_SIZE : FIXED_STACK_FRAME_GAP;
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -782,7 +782,7 @@ cmd64 ppu_thread::cmd_wait()
be_t<u64>* ppu_thread::get_stack_arg(s32 i, u64 align)
{
if (align != 1 && align != 2 && align != 4 && align != 8 && align != 16) fmt::throw_exception("Unsupported alignment: 0x%llx" HERE, align);
return vm::_ptr<u64>(vm::cast((gpr[1] + 0x30 + 0x8 * (i - 1)) & (0 - align), HERE));
return vm::_ptr<u64>(vm::cast((gpr[1] + ppu_cb_detail::FIXED_STACK_FRAME_GAP + 0x8 * (i - 1)) & (0 - align), HERE));
}

void ppu_thread::fast_call(u32 addr, u32 rtoc)
Expand Down

0 comments on commit 75d4629

Please sign in to comment.