crosire / d3d8to9

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

Failed vertex shader assembly (mad oFog) + solution #81

Closed PatrickvL closed 6 years ago

PatrickvL commented 6 years ago

The following vertex shader assembly line fails :

mad oFog /* removed swizzle */, -r3, c150.z, c150.w

It can be fixed by adding this regexp to Direct3DDevice8::CreateVertexShader() :

    SourceCode = std::regex_replace(SourceCode, std::regex("mad (oFog|oPts)(.*), (-?)([crv][0-9]+(?![\\.0-9])), (.+)\\n"), "mad $1$2, $3$4.x /* select single component */, $5\n");

The result is :

mad oFog /* removed swizzle */, -r3.x /* select single component */, c150.z, c150.w

..which succesfully compiles. (Not sure if the .x component is the right choice.)

Test-case : Cxbx-Reloaded, running Morrowind.

crosire commented 6 years ago

Do you want to make this into a pull request?

PatrickvL commented 6 years ago

No time, I'm sorry

PatrickvL commented 6 years ago

You neither it seems ;)

crosire commented 6 years ago

? It's fixed in https://github.com/crosire/d3d8to9/commit/52a32ef4d8f569ec299bcad13f1a531ce12504c1?