elishacloud / dxwrapper

Fixes compatibility issues with older games running on Windows 10/11 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
zlib License
1.17k stars 83 forks source link

BloodRayne 2 #7

Closed Keith94 closed 6 years ago

Keith94 commented 6 years ago

Sorry if this is the wrong place to post, but I couldn't find a solution elsewhere yet.

There exists an unofficial "FSAA Patch" that adds new features to the game.

BR2 FSAA Patch 1.666.zip

However with the patch installed it crashes the game on startup. The developer commented that it's a problem with a Windows 10-specific call:

IDirect3D8::CreateDevice(Adapter: 0, DeviceType: 1, hFocusWindow: 2165074, BehaviorFlags: 66|D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING, PresentationParameters: (0x00A013F4BackBufferWidth: 2560, BackBufferHeight: 1440, BackBufferFormat: D3DFMT_X8R8G8B8, BackBufferCount: 1, MultiSampleType: 4, SwapEffect: D3DSWAPEFFECT_DISCARD, hDeviceWindow: 2165074, Windowed: false, EnableAutoDepthStencil: true, AutoDepthStencilFormat: D3DFMT_D24S8, Flags: NONE, FullScreen_RefreshRateInHz: D3DPRESENT_RATE_DEFAULT, FullScreen_PresentationInterval: D3DPRESENT_INTERVAL_IMMEDIATE), ReturnedDeviceInterface: 0x00000001)

I'm on Windows 8 and I also tried the workarounds detailed in that thread (disabling AA color samples/enabling MSAA externally etc.) to no avail. Is there anything I missed or any insight on how to use this patch that you know of? Thanks.

elishacloud commented 6 years ago

It looks like the issue is with Anti-Aliasing. Have you tried disabling Anti-Aliasing or setting the "AA Color Samples" to '0'?

Also I made a quick update to the patch. I don't have BloodRayne 2 so I could not test it. Let me know if this works or not. Basically this patch does two things:

  1. Converts Direct3D8 to Direct3D9.
  2. Tests Anti-Aliasing and sets the highest supported mode. If no Anti-Aliasing is supported it disables Anti-Aliasing.

Edit: removing fix download since it did not work.

Keith94 commented 6 years ago

Hi @elishacloud and thanks for the support.

Yes, I made sure to turn off AA color samples in the config tool. But it did not solve the crashing issue. :(

I tested your updated patch also but I get the same results. If you're interested I can link you the GOG installer for the game for better testing.

elishacloud commented 6 years ago

I did purchase the game on GOG (interesting game!). This issue with Windows 10 is much larger than just what is mentioned on that thread.

  1. It is pretty easy to bypass the AA issue (and send MultiSampleType of '0').
  2. Also it is not too hard to 'patch' this dll so that it can be used with a Direct3D8 to Direct3D9 converter.

However there seems to be a third issue with unofficial "FSAA Patch" that makes is crash on Windows 10. I am not sure what this third issue is.

There are comments on the thread that says there is "some kind of data structure ... [but] the memory used by this structure gets obliterated with text midway through the function and corrupts the data structures." The patch may be using hard coded memory addresses and these addresses could be in a different location in Windows 10 compared to other versions of Windows. I need more time to investigate this.

I suspect the issue is with some Direct3D call that is changed in Windows 10.

Keith94 commented 6 years ago

Interesting, well I do experience the same startup crashes on Windows 8, so I'm not sure if my issue is related to that. Looking forward to your findings anyhow.

elishacloud commented 6 years ago

Hello Keith,

I think I figured out the issue. It had to do with the VertexShader instruction count. It seems that d3d8to9 was adding too many extra instructions and causing the shader assembly to fail. See this site here for more details.

The fix was relatively straight forward. I reduced the number of extra instructions that needed to be added and I made sure that the critical ones got added first.

Here is the update: BR2.FSAA.Patch.1.666 Fix v1.zip

Just make sure that all your compatibility settings are disabled. It does not seem to work if any compatibility settings are turned on. At least it did not work for me.

compatibility

Keith94 commented 6 years ago

Awesome, that fixed the crashing issue. I didn't know d3d8to9 by itself could do it.

Btw if AA Color Samples is set above 8, it will still crash, but at least it works fine now. Thanks for the update!

elishacloud commented 6 years ago

I didn't know d3d8to9 by itself could do it.

There is more in here than just using d3d8to9. But this also fixes the issue with d3d8to9 and BloodRayne.

if AA Color Samples is set above 8, it will still crash, but at least it works fine now. Thanks for the update!

Yes, that is an issue with the BloodRayne 2 FSAA Patch 1.6 itself. The patch does not have very good error checking. Setting the wrong options for your system can cause it to crash. I doubt your video card supports anything over AA 8 anyways.

I am going to go ahead and close this since the core issue has been fixed.

elishacloud commented 6 years ago

I posted the code for this fix on GitHub: BloodRayne-2-Patch

Keith94 commented 6 years ago

Nice dude! Thanks for that.

justm34evah commented 6 years ago

I need help, using Windows 10 and the game finally sees my gtx 1070 with your patch, but it has many graphical glitches and misaligned stuff. Am I forgetting something? I copied all files into the game's folder. GOG version.

justm34evah commented 6 years ago

If I use the normal patch the game forcibly runs on my integrated graphics card, which sucks.

justm34evah commented 6 years ago

Please help...

elishacloud commented 6 years ago

@justm34evah, I assume you are using a laptop with an integrated Intel and Nvidia graphics card? It seems like the GPU's on these laptops are limited and do not support all of the required functions. This issue might be similar to the issue with Start Trek Armada 1 seen on fleetops.net.

I probably need to figure out which functions are not available and rewrite them. I am not sure when I will have time to look at this, but you are welcome to open a new issue on this.

justm34evah commented 6 years ago

Yes, that is completely true. A laptop with both, and I can't disable the integrated graphics card... Well, for now I'll stick to dgvoodoo2 and wide-screen, but the FSAA on Nvidia would have so much better performance...please look into this matter whenever you have the time. A patch update for ppl like me would be great :). Should I open a new thread?

On Thu, 26 Apr 2018, 03:02 Elisha Riedlinger, notifications@github.com wrote:

@justm34evah https://github.com/justm34evah, I assume you are using a laptop with an integrated Intel and Nvidia graphics card? It seems like the GPU's on these laptops are limited and do not support all of the required functions. This issue might be similar to the issue with Start Trek Armada 1 seen on fleetops.net https://www.fleetops.net/forums/armada/armada-1-in-windows-10-12841?p=205906#p205906 .

I probably need to figure out which functions are not available and rewrite them. I am not sure when I will have time to look at this, but you are welcome to open a new issue on this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384489058, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1R1h8KiCt2Fp3c9ifmC-iLWyuyzPJks5tsSrRgaJpZM4O_OrZ .

mirh commented 6 years ago

I have some information about optimus and <D3D9 here.

justm34evah commented 6 years ago

Silly optimus. Whoever came up with it? Jesus these people.

On Thu, 26 Apr 2018, 11:35 mirh, notifications@github.com wrote:

I have some information about optimus and <D3D9 here https://pcgamingwiki.com/wiki/User_talk:Garrett/Troubleshooting/Windows_10 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384593153, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1Rwl7JADiGeyRKHxCqEoS0O6C-IErks5tsaL4gaJpZM4O_OrZ .

mirh commented 6 years ago

Smart engineers trying to make the best of both worlds. For some reason though, <D3D9 was left out.

@ataulien did you ever figured out if this choice(?) was technical, laziness or else?

justm34evah commented 6 years ago

Why not let me choose what video card I want, why does optimus have to force my answer to save battery life. Maybe I do not want that. I don't understand this concept at all. Nvidia should get their shait together.

On Thu, 26 Apr 2018, 17:03 mirh, notifications@github.com wrote:

Smart engineers trying to make the best of both worlds. For some reason though, <D3D9 was left out.

@ataulien https://github.com/ataulien did you ever figured out if this choice(?) was technical, laziness or else?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384696524, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1R7zm4A7ZHa5k5bGD2QKF7AjGBjNuks5tse_HgaJpZM4O_OrZ .

elishacloud commented 6 years ago

http://www.vogons.org/viewtopic.php?f=8&t=45661#p459344

if you have a laptop with Nvidia Optimus and you try to run a game that uses DX1-8, it always runs on Intel GPU

http://nvidia.custhelp.com/app/answers/detail/a_id/3733

Games based on DirectX 8 and older versions of DirectX will only run on integrated graphics in an Optimus laptop

@mirh, these articles seem to be talking about D3D8 and older. Are you saying that D3D9 also does not work with Optimus?

justm34evah commented 6 years ago

Dx9 and later use Dedicated cards.

On Thu, 26 Apr 2018, 19:36 Elisha Riedlinger, notifications@github.com wrote:

http://www.vogons.org/viewtopic.php?f=8&t=45661#p459344

if you have a laptop with Nvidia Optimus and you try to run a game that uses DX1-8, it always runs on Intel GPU

http://nvidia.custhelp.com/app/answers/detail/a_id/3733

Games based on DirectX 8 and older versions of DirectX will only run on integrated graphics in an Optimus laptop

@mirh https://github.com/mirh, these articles seem to be talking about D3D8 and older. Are you saying that D3D9 also does not work with Optimus?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384746687, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1RyOmYYlnmws1Q8q1LKlWqrdCk_suks5tshOjgaJpZM4O_OrZ .

mirh commented 6 years ago

? Isn't BloodRayne d3d8?

justm34evah commented 6 years ago

Yes, testing it now using dgvoodoo2 emulator. Quite a few fps drops using my gtx 1070...if only I could force it to run on the dedicated card without an emulator...the original FSAA patch works great for me, no crash, but it's forcibly run using my Intel gt630 so it has extremely poor performance...

On Thu, 26 Apr 2018, 20:25 mirh, notifications@github.com wrote:

? Isn't BloodRayne d3d8?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384761431, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1RxcM9etkzufAeMSxmjI8IKthNBA1ks5tsh8TgaJpZM4O_OrZ .

elishacloud commented 6 years ago

dgVoodoo just converts this to DirectX 11.

My patch converts it to DirectX 9. This is why Optimus opens it up using your Nvidia GTX 1070. I think the "graphical glitches and misaligned stuff" comes because the Nvidia card has a bunch of missing/unsupported functions.

justm34evah commented 6 years ago

True. If you could look into this matter for me, that would be really appreciated. Like, I installed dx9, maybe I need a certain c++ or version of directx

On Thu, 26 Apr 2018, 23:29 Elisha Riedlinger, notifications@github.com wrote:

dgVoodoo just converts this to DirectX 11.

My patch converts it to DirectX 9. This is why Optimus opens it up using your Nvidia GTX 1070. I think the "graphical glitches and misaligned stuff" comes because the Nvidia card has a bunch of missing/unsupported functions.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/elishacloud/dxwrapper/issues/7#issuecomment-384808473, or mute the thread https://github.com/notifications/unsubscribe-auth/AJo1R1pcRpf5LpktuDdmORoqfP34ur8mks5tskpLgaJpZM4O_OrZ .