Live data from Hacker News

Exercises in Emulation: Xbox 360’s FMA Instruction

randomascii.wordpress.com

41–50 of 50 posts

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#41
post #33

Personally found this article overly dramatic and a bit dumb. All this wall of text just to point out that FMA needs to be emulated... ok.. but it’s a solved problem. This is also not a new problem.. fmaf is defined in C99 standard so There are multiple open source library implementations of FMA using round to odd for years. You can just read that code and see how it’s done. Despite the ridiculous ending there was no…

That is weird. The paper was published in 2009 by Microsoft Research, and the Xbox One entered development in early 2011 according to Wikipedia (https://en.wikipedia.org/wiki/Xbox_One). So when the author started working on the problem for Microsoft, Microsoft already knew how to solve the problem.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#42
post #30

Earlier quoted context omitted.

This makes me wonder if the Halo Master Chief Collection release on PC will be based on emulation.

The Xbox One is x86/64, so emulation shouldn't be necessary for the MCC. The remaining questions are how much it is a "port" from what was released on the Xbox One. - Supposedly the early Xbox One games used a fork/version of DirectX that wasn't ever quite released in that form in Windows 10. Rumors are that has been corrected in the upcoming April Release. - Also, the early Xbox One games used very different Microso…

Also, to point out it doesn't appear that the MCC itself uses 360 emulation. It predates the 360 emulation, for one thing, and you can easily contrast how the MCC runs to Rare Replay which does clearly boot up the 360 VM for some of its games (and which show up outside of the combined Replay launcher in the Games Library as back compat 360 games).

Supposedly a true x64 port of the multiple generations of the Halo engines was an important goal of the 343 team to feel that they knew the engines inside and out, and had a good handle on using that engine for Halo 5 to give a longer lead time on their next engine. (Halo Infinite [6] supposedly will use a brand new engine codenamed "Slipspace".)

Other signs that MCC was most likely a very "proper" port of the engines to x64 include some of the ways bugs riddled the early post-launch phases, especially in multiplayer code.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#43
post #33

Personally found this article overly dramatic and a bit dumb. All this wall of text just to point out that FMA needs to be emulated... ok.. but it’s a solved problem. This is also not a new problem.. fmaf is defined in C99 standard so There are multiple open source library implementations of FMA using round to odd for years. You can just read that code and see how it’s done. Despite the ridiculous ending there was no…

That is weird. The paper was published in 2009 by Microsoft Research, and the Xbox One entered development in early 2011 according to Wikipedia ( https://en.wikipedia.org/wiki/Xbox_One ). So when the author started working on the problem for Microsoft, Microsoft already knew how to solve the problem.

it's possible he left before that. they were working on xbox 360 bc for a long time.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#44
post #33

Personally found this article overly dramatic and a bit dumb. All this wall of text just to point out that FMA needs to be emulated... ok.. but it’s a solved problem. This is also not a new problem.. fmaf is defined in C99 standard so There are multiple open source library implementations of FMA using round to odd for years. You can just read that code and see how it’s done. Despite the ridiculous ending there was no…

That is weird. The paper was published in 2009 by Microsoft Research, and the Xbox One entered development in early 2011 according to Wikipedia ( https://en.wikipedia.org/wiki/Xbox_One ). So when the author started working on the problem for Microsoft, Microsoft already knew how to solve the problem.

Author here: I don't remember exactly when I did my investigation but I left the Xbox team in early 2009, so it would have been some time before that.

The 2011 date from Wikipedia is for when hardware development began. Investigations into what hardware would be used would obviously predate that so there's no contradiction.

Anyway, I'll have to digest that FMA emulation article and see what sort of performance their algorithm achieves. A branchless and vector-math compatible implementation would be important for performance.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#45

> If you apply for a mortgage when your job title is emulation ninja then you are in a quandary. If you write that on the mortgage application then you look like a lunatic. If you write “software engineer” then you get in trouble when the mortgage broker calls your employer. You know. Hypothetically.

As an employed "software engineer" who has recently applied for a mortgage (house closing tomorrow!), I'm highly interested in this statement. I've encountered no trouble whatsoever, and I'm honestly surprised that its gone as smoothly and quickly as it has.

The problems only arise if your actual official title at your employer is "Emulation Ninja", because that means that if the lender verifies your employment (common practice) then the job title doesn't match, and suddenly the lender gets nervous...

In normal cases it's fine

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#46
post #13

Do games really rely on the rounding behaviors of floats to not break? Seems like there should always be plenty of margin around that. But maybe something does a loop with these instructions over and over and the error compounds? And wouldn't the solution on x86 be to use the more than double precision floats that are available in the platform? https://en.wikipedia.org/wiki/Extended_precision

A lack of precision is not the problem. The problem is that at some point the game logic makes a decision such as whether a bullet hit a target, whether a player made a jump, or many others.

These decisions sometimes end up right on a cusp, where a single unit in the last place determines the behavior. In a sensitive physics engine these happen more often than you might think. And when the result changes, all future events are impacted.

This is crucial for replays, it may be crucial for multiplayer, and it can result in unexpected behavior in ways that you only find when writing an emulator.

A slight change in floating-point math may also result in a slightly larger-than-expected number which may then result in a slightly negative number which may result in a NaN (sqrt(-1e39) perhaps) which then results in the poisoning of all future math that uses that number.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#47
post #16

Earlier quoted context omitted.

They do. Slight problems with floating point behavior are the cause of many historical problems with GameCube and Wii games in the Dolphin emulator (which also has to emulate PPC on x86/x64) For a simpler example from personal experience, I had a textbook implementation of triangulation via ear clipping to turn polygons into a list of triangles I could send to the GPU. On Windows it worked great but when I ran it on…

> This turned out to be because the rounding behavior on the 360 was different and the algorithm is fundamentally unstable using floats. That sounds like a bug though but I guess that's the point. Unless you're bug for bug compatible a reasonable amount of code will fail a significant amount of time...

That may have been a case where the FMA instructions on Xbox 360 gave different results. Or maybe the code was relying on the x86's odd x87 floating-point unit, or maybe the compilers were rearranging the instructions slightly in one of the ways that is legal. Lots of reasons why floating-point math code might behave differently without it being a CPU or compiler bug.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#48

The whole time I was reading I was interested in what they chose to do... a lot of build up and no solution :/ Maybe they did recompile the games for backwards compatibility, maybe they do have an emulator, IDK, but I want to know how they would have fixed this issue.

They ended up shipping processors that support FMA on the xbone, so they probably just used that.

everywhere i looked said jaguar doesn't though

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#49
post #48

Earlier quoted context omitted.

They ended up shipping processors that support FMA on the xbone, so they probably just used that.

everywhere i looked said jaguar doesn't though

Oh weird, you're totally right.

Looks like the removed FMA4 on the bobcat to jaguar transition.

Re: Exercises in Emulation: Xbox 360’s FMA Instruction

#50

Earlier quoted context omitted.

That is weird. The paper was published in 2009 by Microsoft Research, and the Xbox One entered development in early 2011 according to Wikipedia ( https://en.wikipedia.org/wiki/Xbox_One ). So when the author started working on the problem for Microsoft, Microsoft already knew how to solve the problem.

Author here: I don't remember exactly when I did my investigation but I left the Xbox team in early 2009, so it would have been some time before that. The 2011 date from Wikipedia is for when hardware development began. Investigations into what hardware would be used would obviously predate that so there's no contradiction. Anyway, I'll have to digest that FMA emulation article and see what sort of performance their…

Thank you for response/clarifying the timeline. I didn't realize that development on non-hardware parts of the system would happen so much earlier, but it makes sense that you'd want to know if changing archs made your catalog unplayable!
Post reply on HN