crosire / d3d8to9

A D3D8 pseudo-driver which converts API calls and bytecode shaders to equivalent D3D9 ones.
BSD 2-Clause "Simplified" License
881 stars 78 forks source link

Several fixes #53

Closed elishacloud closed 6 years ago

elishacloud commented 6 years ago

This update has several changes:

1. SetFVF Adds SetFvF() to CreateDevice() to initialize the vertex declaration. This allows the ValidateDevice() to work correctly and fixes an issue with Max Payne. See #43 for more details.

2. SetSoftwareVertexProcessing Removes SetSoftwareVertexProcessing() to prevent dynamic switching between hardware and software vertex processing and fixes an issue with Haegemonia: Legions of Iron. See #43 for more details.

3. CreateVertexDeclaration Modifies the code that translates the vertex declaration. If the Usage is 'blendindices' it will set the Method to Default. This fixes an error in CreateVertexDeclaration() found in True Crime New York City. See #44.

Was getting this error:

> 'IDirect3DDevice9::CreateVertexDeclaration' failed with error code 80004005!

4. Co-issued statements Updates the pixel shader translation to ignore co-issued statements to resolve an issue found in True Crime New York City. See #44.

Here is an example of a co-issued command (notice the '+' sign):

    lrp r0.xyz, c0.w, r1, r0
  + mul r0.w, 1-r0.w, 1-r0.w

This is fixed by adding 4 spaces at the beginning to ensure that the statement is not co-issued before updating it. See line 1699. Co-issued commands don't work right with this particular translation since it adds a new line.

5. Double swizzles Updates the pixel shader translation to ensure that double swizzles are not added when both the modified and modifier registers have swizzles. This fixes an issue found in True Crime New York City. See #44.

Here is what the pixel shader looked like:

    ps_1_1
    tex t0
    tex t1
    mul r0, v0, t0
    mul r1, v1, t1
    mul r0.xyz, r0, r0.w
    lrp r0.xyz, c0.w, r1, r0
  + mov r0.w, c0.w /* added line */
    mul r0.w, 1-r0.w, 1-r0.w.w /* changed c0 to r0.w */

Notice the double swizzle in the last line where it has: 1-r0.w.w

Updated this by removing '$10' and '$14' which are both modifier swizzles. The original swizzle is maintained in '$3'.

Testing I tested this with the following games:

DisguisedD commented 6 years ago

Thank you for your efforts~