VOGONS


Pentium MMX emulation patch

Topic actions

Reply 20 of 26, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Reply 21 of 26, by kekko

User metadata
Rank Member
Rank
Member
jmarsh wrote on 2020-06-24, 16:15:

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Hmm, it looks like that array saves/restores host fpu regs, not emulated machine ones.
I can't understand when I should save/restore mmx regs to fpu.regs[], and if anything else needs to be done. Any hint?

Reply 22 of 26, by kekko

User metadata
Rank Member
Rank
Member
jmarsh wrote on 2020-06-24, 16:15:

I think that's a bit of a mess at the moment. When X86_DYNFPU_DH_ENABLED is defined and the dyn_x86 core is active, it saves/restores the x87 state when it enters/exits the dynamic code (to the dyn_dh_fpu struct) but never actually copies everything back to the global FPU_rec struct.

So TL;DR: you need to manually copy them to/from the dyn_dh_fpu.state.st_reg array.

Ok I got an effect, reaching titles with the game in the first post, by just commenting out dyn_mmx_check define.
Apparently he is mixing host fpu status and emulated mmx status, by letting them share host regs.
The recompiler backs up host fpu status before running a block, in CPU_Core_Dyn_X86_Run > gen_dh_fpu_save
Then restores host fpu status at end of block, in CreateCacheblock > dyn_closeblock > dyn_fill_blocks
This breaks mmx status across different blocks.

you know the recompiler far better than me; do you have any suggestion on a possibly polite solution for this?

Reply 25 of 26, by kekko

User metadata
Rank Member
Rank
Member

Hi,
I updated the patch on the first post
- Added x86 recompiler support
- Fixed fpu regs usage
- Fixed makefiles and vc project files

x86 recompiler support is very basic, yet still much faster than the interpreter.
On my 13yr old core2 it reaches almost playable speeds with Serious Sam.
It uses emulated mmx regs, just like the interpreter. It doesn't use host mmx registers at all, avoiding breaking host fpu status/regs.
this approach is way more stable than the dosbox-x implementation.
plus it should be easier to port to other architectures.

QCoVDPs.png

Last edited by kekko on 2021-03-13, 10:02. Edited 1 time in total.