Hack/Fix to re-enable Crossfire on DX9 (can fix sli on dx9 too)

aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
edited September 2013 in Technical Support
UPDATE: uwe fixed this in the build 255!
althrough you can still have some extra framerate (and non glitched shadows) using the arma2 crossfile profile, this profile thing is a problem entirelly related to the ATI/AMD drivers.


this thread has 2 important topics, one is a actual solution to crossfire issues using dx9 since build 252, the other one is that i think i uncovered a bug in the game code, that is worth mentioning.

======================

The solution: (confirmed if you have crossfire, likely will help anyone using sli under dx9 too)

Download this:
http://www.megafileupload.com/en/file/447817/ns2-MGPU-FIX-rar.html

inside you have instructions and a proxy dll named d3d9.dll, the only thing it does is to "rewrite" a request that the game engine does to directX 9.

Warning:
this will only work on fullscreen, be sure to select fullscreen in the options BEFORE using the mod.


======================

The second part, the "i think i found a bug"

When the "ermagerd, sdl" patch came out, i noticed that the game never went "true full screen" (we have in the options the fullscreen and fullscreen windowed but in my computer both act the same)
and amd crossfire requires "true full screen" to work. (if not i am forced to play at half gpu speed, what is pretty sad for ns2)

i did poked the code a little and noticed that the "CreateDevice" method of d3d9 was being called with the flag "Windowed" always as true, likely as a bug, maybe someone forgot something before compiling.

i made the change (forcing the flag to false) and the game started crashing when creating the d3d9 device, i thinkered a little more with the code and noticed (for some bizarre reason imho) that the engine requested a "full screen resolution" that didnt matched what it did asked for sdl, or anything else, my game resolution is set to 1920x1080 and d3d9::CreateDevice received 1926x1108 in the parameters. (why? no idea)

i forced the resolution of the device to the resolution of the desktop (at a point it is was already set by sdl) and voilá, the game worked with crossfire again, happy ending for a impatient (http://forums.unknownworlds.com/discussion/131634/build-252-fullscreen-exclusive-d3d9-device-problem-d3d11-problem#latest) guy looking for his daily fix of ns2.

would this be a bug? can i win a cookie if it is?

edit: a bunch of typos, and i won my cookie!

edit2: added the source -> http://pastebin.com/uUqfG44V
* the relevant part is at lines 192 to 194, the rest is just stuff to actually be able to alter what is being done in those lines.

edit3:
known bug:
* you cant alt+tab (will crash the game)

edit4: "remove something i added less than 3 minutes ago, better stop editing this @##$% post.

edit5: someone else confirmed it restored sli support too.

Comments

  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    edited September 2013
    Nice find.. one of our PTs discovered that not going fullscreen was the issue back on friday, but this is even more info.

    Devs are actively investigating the issue .. but I emailed them what you found, just in case.
    Again, nice work :)
    cookie.jpg

    edit: Didn't notice a difference... also weird that the ns2 folder doesn't already have that dll.. but instead has a d3dx9_43.dll
    Is this dll supposed to be used by dx11 as well?
  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    Also, for those not wishing to visit megaupload / in case it gets lost... here's the same file attached.
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    IronHorse wrote: »
    Nice find.. one of our PTs discovered that not going fullscreen was the issue back on friday, but this is even more info.

    Devs are actively investigating the issue .. but I emailed them what you found, just in case.
    Again, nice work :)
    cookie.jpg

    edit: Didn't notice a difference... also weird that the ns2 folder doesn't already have that dll.. but instead has a d3dx9_43.dll
    Is this dll supposed to be used by dx11 as well?

    the folder does not originally have a d3d9.dll, this file is originally located in c:\windows\system32\d3d9.dll

    this a "proxy dll", it receives the commands sent to the original one, "take a peek and/or modify them" and send to the original one (in the windows folder)

    it is true that the procedure i am talking about is located in "d3dx9_43.dll" (i think) but the procedure who instantiate the d3d9 object is from d3d9.dll (the one i really needed to hook)

    when you didnt noticed a difference, was in a system with 2 or more AMD gpus? (i cant confirm if it does help sli as well)
  • HeavenfallHeavenfall Join Date: 2010-08-14 Member: 73620Members
    edited September 2013
    The D3D9.dll doubled my fps in Direct 9 X. Ridiculous. Thanks.

    Edit: This was on a crossfire setup.
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    edited September 2013
    IronHorse wrote: »
    Nice find.. one of our PTs discovered that not going fullscreen was the issue back on friday, but this is even more info.

    Devs are actively investigating the issue .. but I emailed them what you found, just in case.
    Again, nice work :)
    cookie.jpg

    edit: Didn't notice a difference... also weird that the ns2 folder doesn't already have that dll.. but instead has a d3dx9_43.dll
    Is this dll supposed to be used by dx11 as well?


    This "fix" is very specific to dx9, there is no effect on dx11 or OpenGL, at least the crossfire is working on both opengl and dx11, but in the current driver, with 2 radeons 6870 the performance is VERY suboptimal (something like half of dx9)

    edit: a bunch of typos
  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    Not using AMD or crossfire setup.. but in theory there should be a notable FPS and GPU difference when using fullscreen and fullscreen windowed.
    When comparing to the 250 or 251 build, the current build is displaying results typically found with fullscreen windowed.

    If the fix you've included corrects this, it shouldn't just effect AMD and Crossfire users, it should positively impact all users, restoring a true fullscreen mode.
    Right?

    So does that DLL work with DX11 enabled as well?
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    edited September 2013
    IronHorse wrote: »
    Not using AMD or crossfire setup.. but in theory there should be a notable FPS and GPU difference when using fullscreen and fullscreen windowed.
    When comparing to the 250 or 251 build, the current build is displaying results typically found with fullscreen windowed.

    If the fix you've included corrects this, it shouldn't just effect AMD and Crossfire users, it should positively impact all users, restoring a true fullscreen mode.
    Right?

    So does that DLL work with DX11 enabled as well?

    Yes, it is true that even single gpu users can get a speed boost (but very small in my theory) with exclusive fullscreen direct3d.

    you can say the dll "works" with dx11 because by "working" its actually doing nothing (therefore nothing that would crash or alter the game). it does specifically changes how the engine creates the directx9 device, nothing besides that. (so nothing related to dx11 or OpenGL)

    i did posted the source code here in the case someone else wonder "why what or how"
    http://pastebin.com/uUqfG44V
    * the relevant stuff is line 192 to 194, the rest is just stuff to actually be able to alter what is being done in those lines.

    edit: wrong line numbers

  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    edited September 2013
    Hmm.. am i missing anything other than placing that DLL in my ns2 folder, running fullscreen in the options, and running DX11?
    Because we're testing it and we cannot tell if there is a difference for single GPU users.. and there should be if its going to true fullscreen.

    Edit: thx for the source!
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    IronHorse wrote: »
    Hmm.. am i missing anything other than placing that DLL in my ns2 folder, running fullscreen in the options, and running DX11?
    Because we're testing it and we cannot tell if there is a difference for single GPU users.. and there should be if its going to true fullscreen.

    Edit: thx for the source!

    ok, i dont know if i was not clear enough in the previous posts, but i can ASSURE YOU, this mod does NOTHING, EXACTLY NOTHING on DX11, nothing at all, it would be *impossible* to tell ANY difference on DX11 because it does NOTHING to DX11 calls, therefore, yes, no difference at all. (on dx11 or opengl)

    you can attest that dx9 is running at "actuall fullscreen" by doing the following:
    * open a app that will generate "always on top windows" created AFTER the main game window was created. (skype "someone is online" notification is a good example")
    -> without the mod: the actual notification show up on the top of the game render window. (therefore it is running windowed)
    -> with the mod: you will hear the skype sounds, but the app wont be able to show the notification window.

    yes, i know someone said that the performance loss is caused by not running the game on actual fullscreen, but then the game have some important changes, like the new shadowmapping shader, that could be slower (and its WAY better, i loved) that the previous one.

    even the extra abstration to the operating system (sdl2) introduced in build 252 (to allow easier porting to other plataforms) could cause some (although likely very small) performance loss.

  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    Ok that explains it. I think the devs are sorting this now as I type this. ;-)
  • Dictator93Dictator93 Join Date: 2008-12-21 Member: 65833Members, Reinforced - Shadow
    edited September 2013
    I can confirm this mod fixes DX9 SLI scaling on Nvidia cards.

    I went from messed up card utilization to 99%/99% Utilization. Allowing me to get the 100plus I need in this game.

    DX11 is still having the scaling problem since this fix is obviously not applied.

    EDIT: The game cannot be alt-tabbed on my system: after returning from alt tabbing the game screen is rendered black even though game sounds can still be heard.

    Similarly... the game attempts to minimize out on launch with this .dll. To prevent it, one must vigorously click the screen to maintain window focus.

    EDIT2: Game crashed after a bit. Not sure if it was due to the .dll
  • turtsmcgurtturtsmcgurt Join Date: 2012-11-01 Member: 165456Members, Reinforced - Supporter
    backstory: NS2 has never felt smooth for me, whether I had SLI enabled or not. I have a 120hz monitor and I have never had NS2 feel as buttery smooth as it does with this .dll. 90 FPS in NS2 used to feel like 40 FPS in any other game, but with this it feels just as it should.

    I have the same issue with the guy above, I can't tab back into the game, but to be honest I really couldn't care less. I'll happily give up my ability to alt-tab if it allows for me to play this game properly.

    This also gave me a 30-40 FPS boost in the menu, I have two 460's in SLI (so it does work with nvidia).

    as far as i'm concerned UWE needs to pay or hire this guy, he's done what they never could.
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    Dictator93 wrote: »
    I can confirm this mod fixes DX9 SLI scaling on Nvidia cards.

    I went from messed up card utilization to 99%/99% Utilization. Allowing me to get the 100plus I need in this game.

    DX11 is still having the scaling problem since this fix is obviously not applied.

    EDIT: The game cannot be alt-tabbed on my system: after returning from alt tabbing the game screen is rendered black even though game sounds can still be heard.

    Similarly... the game attempts to minimize out on launch with this .dll. To prevent it, one must vigorously click the screen to maintain window focus.

    EDIT2: Game crashed after a bit. Not sure if it was due to the .dll

    the alt tab thing is a known issue, to be honest i released the "fix" about 20 minutes after playing with it, havent tried to alt+tab while testing.

    the thing about the game window minimizing i have no idea about why it is happening, the game resolution is the same as the desktop resolution? (therefore not requiring to change the desktop resolution to create the fullscreen sdl window.)



    backstory: NS2 has never felt smooth for me, whether I had SLI enabled or not. I have a 120hz monitor and I have never had NS2 feel as buttery smooth as it does with this .dll. 90 FPS in NS2 used to feel like 40 FPS in any other game, but with this it feels just as it should.

    I have the same issue with the guy above, I can't tab back into the game, but to be honest I really couldn't care less. I'll happily give up my ability to alt-tab if it allows for me to play this game properly.

    This also gave me a 30-40 FPS boost in the menu, I have two 460's in SLI (so it does work with nvidia).

    as far as i'm concerned UWE needs to pay or hire this guy, he's done what they never could.

    i am glad i was able to help, but then this fix is a very simple job that a lot of programmers could have done (including ppl at uwe), most likely they dont have a multi gpu system to use for testing so the issue went unnoticed.
  • dushandushan Breaker of Games Join Date: 2011-10-30 Member: 130202Members, NS2 Developer, Squad Five Blue, Pistachionauts
    Hey guys, D3D9 fullscreen should be fixed in 255 (just went live). D3D11 is still as it was - we'll need to re-work our threading a bit to make it work reliably.
  • Zomb3hZomb3h Join Date: 2011-01-27 Member: 79241Members, Reinforced - Shadow
    @dushan
    Is that D3D9 fix directed at sli/crossfire cards or BOTH single-card+crossfire/sli?
  • dushandushan Breaker of Games Join Date: 2011-10-30 Member: 130202Members, NS2 Developer, Squad Five Blue, Pistachionauts
    edited September 2013
    It now correctly enters the DirectX exclusive mode again, which at the very least disables Aero but also allows the drivers to do whatever magic they like to do. This should reduce lag and potentially improve performance/reduce jitter in fullscreen mode on both single and multi GPU setups.
  • DeGDeG Join Date: 2013-08-29 Member: 187155Members
    Hi everyone,

    repeat my previous post and topic, I give the fun down here solution for injection of the D3D9 dll.

    You had to take your head aruametello to find the right dll, but play well.

    As I work in the middle of 3D programs, I know this dll injection process.

    Regarding Arma2 profile adds 20 fps but the possibility of detection or crash on some process, I use the drivers frame parcing 13.8 beta2, I give you the settings panel catalyst screenshot.



    http://forums.unknownworlds.com/utility/thumbnail/37017/~cf/FileUpload/f3/5ca82dfe914289c59a6d9be75e6803.jpg


    I said that this adjustment is made on a Tri-CrossfireX 6970, the sound of the order of 90 to 150 FPS in game performaces.

    If people encounter problems with framerate only two or three graphics.

    Set the antialiasing mode in controlling the application in the catalyst.

    PS:

    Frankly LOL what NS2, put your media time to react as I think even if we had not done it up like the accuracy of the new patch 255 would not exist soon.





    August 30

    Hi everyone,

    Thank you for your support towards the problem of performance drop from the last 252 days and 253.

    I said that the problem is that NS2 does not work in crossfire and tri-fire.

    In my case I use the drivers 13.8 beta2 parcing frame.

    I grieve that my time if this is not a concern for AMD drivers.

    Before this patch is D3D9 all work perfectly with a framerate more than well, and now even in passing in the game drivers in the D3D9 worry is not set.

    all my other single player games or even beta as well my takes arma3 Tri-fire.

    I understand the infatuation of NS2 developers to add maps contained, features that brings change, even as it is their creation, the more we create a superb engine.

    But frankly the drivers without any addition API tests must stop throwing stones at amd drivers.


    For my part I even try to inject a D3D9 driver other than the game, clamping is real at the current compile.
  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    dushan wrote: »
    It now correctly enters the DirectX exclusive mode again, which at the very least disables Aero but also allows the drivers to do whatever magic they like to do. This should reduce lag and potentially improve performance/reduce jitter in fullscreen mode on both single and multi GPU setups.


    This is only dx9 right? 11 will still be affected right?
  • Zomb3hZomb3h Join Date: 2011-01-27 Member: 79241Members, Reinforced - Shadow
    I can say with 100% guarantee that the patch fixed the jittering on initial loading after connecting to a server and that the mouse-lag is gone on DirectX 9.

    Specs:
    i5-3550 3.3ghz
    GTX 660 ti MSI Superclocked Edition 2GB
    8GB RAM
    Win7 Ultimate.
  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    edited September 2013
    @deg : What? Can't understand any part of your post.

    Everyone should be using DX9, as it is working properly now. DX11 and OpenGL will still have issues and are a work in progress.

    edit: closed at the OP's request.
This discussion has been closed.