PDA

View Full Version : checkfpu



Skarma
September 23rd, 2010, 02:59 PM
There is this command line argument: -checkfpu
Does anyone know what this means? I can't find any info on it and only thing I can find on FPU is about floating point units and I don't understand it.

I am reversing some engine vertex / index shader stuff. The Usage parameter when calling IDirect3DDevice9::CreateIndexBuffer() is based off of the behavioral flags parameter when calling IDirect3D9::CreateDevice(), which is calculated based on the -checkfpu flag.

Any info let me know!!!

CrAsHOvErRide
September 23rd, 2010, 03:32 PM
FPU is the processor inside the CPU that is responsible for floating point arithmetic.
FPU has its own registers and functions to calculate and store floats. But you knew this stuff already...? or am I misunderstanding your post.

A long time ago the FPU was not part of every computer and could be bought additionally...but that was a long time ago so I don't think -checkfpu was made for that purpose. The GFX card processor is mostly a FPU...maybe it has some purpose for that.

Skarma
September 23rd, 2010, 04:18 PM
-checkfpu is checked here, result is stored in 0x006B8374 (halo ce 1.08)

00544DE5 . PUSH OFFSET 00610778 ; /Arg1 = ASCII "-checkfpu"
00544DEA . XOR EDI,EDI ; |
00544DEC . CALL 005460B0 ; \haloce.005460B0
00544DF1 . MOVZX EDX,AL
00544DF4 . MOV DWORD PTR DS:[6B8374],EDXOther than the CreateDevice call, these are the only other 2 places it's referenced:

004CAC7A |. |CMP DWORD PTR DS:[6B8374],EBX
004CAC80 |. |JE SHORT 004CAC91
004CAC82 |. |MOV DWORD PTR SS:[ESP+20],7E
004CAC8A |. |WAIT
004CAC8B |. |FINIT
004CAC8D |. |FLDCW WORD PTR SS:[ESP+20]
004CAC91 |> |CMP WORD PTR DS:[6B471C],0FFFF
0051ADEE |> \ |CMP DWORD PTR DS:[6B8374],EBX
0051ADF4 |. |JE SHORT 0051AE05
0051ADF6 |. |MOV DWORD PTR SS:[ESP+1C],7E
0051ADFE |. |WAIT
0051ADFF |. |FINIT
0051AE01 |. |FLDCW WORD PTR SS:[ESP+1C]
0051AE05 |> |MOV AL,BYTE PTR SS:[ESP+13]FWAIT, FINIT, and FLDCW are FPU internal instructions. FINIT resets all the fpu registers and flags to default, to prevent exceptions. Why it is done in these 2 places in the engine and why load 7E into the FPU stack? no idea. I am testing out what the difference is with CreateDevice and the flags, this stuff is interesting to me and I'll post my findings.

Skarma
September 23rd, 2010, 04:54 PM
Alright, so if you start up halo with no command line arguments, CreateDevice just uses D3DCREATE_HARDWARE_VERTEXPROCESSING for it's behavioral flags, but if you start up halo with -checkfpu, it also uses D3DCREATE_FPU_PRESERVE:


Set the precision for Direct3D floating-point calculations to the precision used by the calling thread. If you do not specify this flag, Direct3D defaults to single-precision round-to-nearest mode for two reasons:

Double-precision mode will reduce Direct3D performance.
Portions of Direct3D assume floating-point unit exceptions are masked; unmasking these exceptions may result in undefined behavior.



CreateIndexBuffer seems to not be affected. It's usage parameter is always D3DUSAGE_WRITEONLY regardless of -checkfpu status.