crosire / d3d8to9

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

Missing textures in Hitman 2 Silent Assassin #17

Closed elishacloud closed 7 years ago

elishacloud commented 7 years ago

There seems to be missing textures on Hitman 2 Silent Assassin when using this wrapper/converter.

Here is what I get with d3d8to9: hitman2_d3d8tod9

Here is what it is supposed to look like: hitman2

I think this problem is different than the problem with Rayman 3: Hoodlum Havoc because when I try other converters, like the one here, it works fine. I am hoping someone can look into this as I need this converter to play the game in Windows 10.

CookiePLMonster commented 7 years ago

Have you tried comparing pix frames from this wrapper and the one from Boris/ENBSeries? While those are useless for anyone but you (frames can't be viewed from a PC with a different driver/GPU model), maybe you'll spot something obvious in the render states (or texture sampler settings) for 47's draw call.

elishacloud commented 7 years ago

Thanks for the suggestion! However I an new to DirectX programming (and C/C++ programming for that matter). I am not sure how to compare pix frames. I don't have the source code for the Boris/ENBSeries converter.

CookiePLMonster commented 7 years ago

You'd need to use it to capture frames from ingame and then most likely compare render states during the draw call - no need for the source.

elishacloud commented 7 years ago

Ok, I started looking at this in PIX for Windows using this guide here. So far I have found three differences between d3d8to9 and the Boris/ENBSeries converter.

  1. In the SetVertexShader function it seems that the Boris/ENBSeries converter calls SetFVF and SetVertexDeclaration before it calls SetVertexShader. Whereas d3d8to9 calls them in reverse order.

  2. In the SetRenderTarget function the Boris/ENBSeries converter does not call Release and only calls AddRef once. Whereas d3d8to9 calls Release and calls AddRef more than once.

  3. In the frame I captured the Boris/ENBSeries converter called GetRenderTarget as the very first call and then GetDepthStencilSurface as the third call, whereas these calls were completely missing from d3d8to9.

The first two items were easy to change. However for the third item, it seems like d3d8to9 is missing a call to GetRenderTarget and GetDepthStencilSurface. But I am not sure how to add these calls.

I did take a quick look at the GetRenderTarget and GetDepthStencilSurface functions in d3d8to9 and I noticed that neither of these call out to their D3D9 equivalent. When I manually added the GetRenderTarget and GetDepthStencilSurface functions then the calls for d3d8to9 and Boris/ENBSeries converter were exactly the same. However this did not solve the issue. Probably because when I called GetRenderTarget and GetDepthStencilSurface I just threw away their return results.

Anyways I think the problem is in here somewhere, but I am not quite sure how to fix it. Is it possible that there are multiple render targets in this game and d3d8to9 can only handle one?

CookiePLMonster commented 7 years ago

This doesn't seem to be the case. GetRenderTarget and GetDepthStencilSurface don't call their d3d9 equivalents because the emulated device seems to cache those by itself.

Looks like d3d8 can't handle multiple render targets either (notice the absence of Index parameter in d3d8's GetRenderTarget). The issue is puzzling.

elishacloud commented 7 years ago

This is the same issue as described in Indiana Jones And The Emporer's Tomb missing textures issue. The solution can be found in the comment here.

elishacloud commented 7 years ago

Fixed with pull #27. Closing.