How to boost your Doom3 performance by 40% on ATI hardware

Discussion in 'PC Gaming' started by Humus, Aug 8, 2004.

  1. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Edit:

    This thread is now obsolete. This tweak is no longer needed. Just use the latest drivers.



    ------------------------------------------------------------------------------------




    Old Edit:

    Quick guide for those who don't want to read the full thread.

    Download this file:
    http://esprit.campus.luth.se/~humus/temp/doom3PerformanceTweak.rar

    Extract so that the shader file goes under doom3\base\glprogs. This replaces a dependent texture read with equivalent math, which runs better on ATI cards, but seems to run slower on NV boards, so only apply this if you got an ATI card.


    So there's no confusion. Do the above. Anything below the line below is here only for historical reasons. It was the first post with the first attempt. Don't pay any attention to it. Just do the above, and don't touch any .pk4 files since it will ruin multiplayer.


    ------------------------------------------------------------------------------------

    Original post:

    I picked up Doom3 today and let be begin by saying it's a kickass game so far. :) A few minuses like weapon reload (which I find add nothing to a game, except annoyance, so I don't know why many devs keep adding it to their games), but overall much above my expectations.

    Anyway, to the fun part, exploring the technology. :)
    I think I've found the source of why this game runs comparably slow on ATI hardware vs. nVidia at the moment, and found a solution to the problem.

    First, open your doom3\base folder. Doubleclick on the pak000.pk4 file. In the "window can't open this file .. .bla bla" dialog, go on and associate the file with an app like WinRar. With this file open in WinRar, go to the glprogs directory in the file. In there you'll find the shaders. The interaction.vfp file seems to be the main rendering shader. Altering this shader to output a constant color turns most objects into that constant color, except for stuff like computer screens etc.

    So doubleclick the interaction.vfp file to open it (you may have to associate the .vfp extension with a text editor like notepad or wordpad first since we're going to edit the file). Scroll down to the fragment shader. You'll find these rows:

    Code:
    PARAM	subOne = { -1, -1, -1, -1 };
    PARAM	scaleTwo = { 2, 2, 2, 2 };
    
    Add this right below them:

    Code:
    PARAM specExp = { 16, 0, 0, 0 };
    
    Now scroll down to this:

    Code:
    # perform a dependent table read for the specular falloff
    TEX	R1, specular, texture[6], 2D;
    
    Comment out that line by adding a "#" to it, and add another line that will do the same thing with math instead, so it should look like this:

    Code:
    # perform a dependent table read for the specular falloff
    # TEX	R1, specular, texture[6], 2D;
    POW	R1, specular.x, specExp.x;
    
    Save the file and close your text editor. WinRar will ask if you want to update the file in the archive, select yes. Close WinRar and enjoy about 40% higher performance in Doom3. Haven't done extensive testing yet, but my performance went from 34fps in 1280x1024 to 48fps.

    Conclusion and discussion:
    I don't want to complain about Carmack's work, I still consider him to be the industry leader in graphics engines. Though when I read the shader it striked me how many texture accesses it did compared to the relatively short shader, even for stuff that could just as well be done with math for a small cost in instructions. Using a dependent texture lookup for POW evaluation makes a lot of sense for R200 level hardware due to instruction set limits, but for R300 and up it's much better to just spend the three cycles it takes to evaluate POW with math instead of risking texture cache trashing with a dependent texture read, which may be much more costly, especially since the access pattern in this case will be far from linear. Also, using math improves the quality too, even though it may not be very noticable in this game.

    I should point out though that I'm not sure if the constant specular factor 16 that I chose is the one that the game uses, so output may be slightly different, but if this solution will be worked into the game in a future patch, then this is easily configurable by the game so that there won't be a difference, except a lot faster.

    An interesting follow-up discussion may be why this dependent texture lookup is much slower on our hardware than on nVidia. Maybe there's an architectural difference that's to blame, or maybe something else? The main point here though is that this should be good enough proof that ATI hardware can run Doom3 just as good if not better than nVidia, and that we can pass on all the "ATI suck in OpenGL", "ATI's drivers suck" etc. into the trashcan where it belongs.
     
  2. K.I.L.E.R

    K.I.L.E.R Retarded moron
    Veteran

    Joined:
    Jun 17, 2002
    Messages:
    2,952
    Likes Received:
    50
    Location:
    Australia, Melbourne
    Anyone trying this I suggest you backup the file.

    Since you work for Ati couldn't you assist JC on these matters?

    JC isn't a god, your input would be much appreciated.
     
  3. thop

    thop Great Member
    Veteran

    Joined:
    Feb 23, 2003
    Messages:
    1,286
    Likes Received:
    0
    I think you just earned yourself a raise 8)
     
  4. jvd

    jvd
    Banned

    Joined:
    Feb 13, 2002
    Messages:
    12,724
    Likes Received:
    9
    Location:
    new jersey
    hmm winrar crashes whenever i try to do this
     
  5. elchuppa

    Newcomer

    Joined:
    Jan 20, 2003
    Messages:
    56
    Likes Received:
    0
    it amazes me the way that shader source is included with the game.

    that's awesome.
     
  6. K.I.L.E.R

    K.I.L.E.R Retarded moron
    Veteran

    Joined:
    Jun 17, 2002
    Messages:
    2,952
    Likes Received:
    50
    Location:
    Australia, Melbourne
    Oh heck.

    Humus, you're gonna die. :x



































    I get tearing in almost all parts of the game even under heavy fights. :)

    Enabled vsync and game runs much faster than before.

    Thanks
     
  7. Toasty

    Newcomer

    Joined:
    Jul 24, 2002
    Messages:
    51
    Likes Received:
    2
    I tried this for my 9700PRO + AXP 3200 at the settings I've been playing the game at.

    1024x768x32, NoAA, NoAF, VSYNC off,
    Medium settings, All advanced options enabled.
    Timedemo demo1 (avg of 3 runs)
    Code:
    Before:   36.8  fps
    After:    37.5  fps
    
    I've checked and double-checked that I altered the shader file exactly as specified.

    Visually I did not see any difference in the timedemo, but that's all I've looked at thus far.
     
  8. K.I.L.E.R

    K.I.L.E.R Retarded moron
    Veteran

    Joined:
    Jun 17, 2002
    Messages:
    2,952
    Likes Received:
    50
    Location:
    Australia, Melbourne
    A64 3000 + 9700 Pro and I get *I have no idea about my framerate but game feels faster than before*.

    I'm hoping Humus can find more places where he can improve JC's code.
     
  9. jvd

    jvd
    Banned

    Joined:
    Feb 13, 2002
    Messages:
    12,724
    Likes Received:
    9
    Location:
    new jersey
    athlon xp 1700 1 gig of ram 9600 pro (stock)

    before 19.6 then 21.5

    after 20.4 and 22.7
     
  10. digitalwanderer

    digitalwanderer Dangerously Mirthful
    Legend

    Joined:
    Feb 19, 2002
    Messages:
    18,684
    Likes Received:
    3,183
    Location:
    Winfield, IN USA
    Humus, I love you man!!!! :D

    Thanks, I'm off to try it. (Oh, you made frontpage...of course! :roll: )
     
  11. DarN

    Regular

    Joined:
    Jan 19, 2004
    Messages:
    406
    Likes Received:
    1
    Location:
    Norway
    Before = 43,0. After = 43,4. Woohoo! :lol:
     
  12. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Interesting. Got me worried first, maybe I made a mistake, but I've double-checked it now. My scores are just from a random spot in the game I chose and checked with the fps counter. Hadn't tried running a timedemo though. So I did that now, and I'm still getting a large performance increase, though not quite as large. It went from 17.5 to 20.0, so that's a 14% boost, which is still a large improvement. I can see the reason why the timedemo doesn't give the same performance boost though. It's not as dependent on the lighting shader, but depends a lot on the performance of the multiple layers of smoke and fire that those darn monsters are throwing around.
     
  13. Crawdaddy79

    Newcomer

    Joined:
    Aug 8, 2004
    Messages:
    13
    Likes Received:
    0
    I went from 24.8 FPS with 4xAA/ 1024x768 (consistant) to 27.6 with same settings in my own custom pinkyfight demo.

    Performance with shadows off seems to be increased tenfold, though.

    (I didn't realize that shadows were off when I first ran the demo.. imagine how amazed I was when I saw a 43FPS average on the first run :shock: )

    Edit: Humus you are a genius.

    Edit #2: Sys specs: 9700 Pro w/ 2000+ AthlonXP & 768 Megs of RAM.
     
  14. jvd

    jvd
    Banned

    Joined:
    Feb 13, 2002
    Messages:
    12,724
    Likes Received:
    9
    Location:
    new jersey
    x800xt pe , athlon 64 3000+ at 2.2 ghz 1 gig of ram.

    before 61.1 after 63.9

    not a bad boost.

    Find more darn it :)
     
  15. davea

    Newcomer

    Joined:
    Aug 8, 2004
    Messages:
    13
    Likes Received:
    0
    HOLY ****! fps is now in the 50s most of the time. dipping into the 40s occasionally. when walking around i got 60fps!!!!!!

    9800pro at stock!!!!

    1024x768 2xaa 16xaf quality by control panel. high quality, no shadows. dude!!!!!!

    this is on a fresh install of doom 3 btw. no other modifications.

    before in the same spot i was getting in the mid 30s on average. humus i love you!

    specs:

    athlon xp 2700+
    his iceq 9800 pro 128mb catalyst 4.9 beta
    asus a7n8x deluxe
    1gig ram
    audigy 2zs
     
  16. digitalwanderer

    digitalwanderer Dangerously Mirthful
    Legend

    Joined:
    Feb 19, 2002
    Messages:
    18,684
    Likes Received:
    3,183
    Location:
    Winfield, IN USA
    Good gods did I screw that up! :oops:

    I had a brainfart somewhere 'tween bouncing back and force 'tween browser and notepad and somehow ended up editing the wrong bit and putting this:

    Code:
    # perform a dependent table read for the specular falloff
    TEX	R1, specular, texture[6], 2D;
    
    # modulate by the constant specular factor
    #MUL	R1, R1, program.env[1];
    POW   R1, specular.x, specExp.x; 
    Which got me a HUGE boost in performance as it eliminated most of the textures in the game....it was VERY dark! :shock:

    Off to try with the correct version...
     
  17. kyleb

    Veteran

    Joined:
    Nov 21, 2002
    Messages:
    4,165
    Likes Received:
    52
    Re: How to boost your Doom3 performance by 40% on ATI hardwa

    it would be better to just copy the directory structure to the file and save it outside the .pk4, that way the game will use it for sp but it will fall back to the .pk4 files if you want to play on a pure server.

    anyway, off to check it out now.


    * went from 42.7 to 44.6 in the timedemo for my standard settings. good work humus. :)
     
  18. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Ok, I did more testing. Performance doesn't improve a whole lot with AA/AF on application preference. I get a few percent increase with that. But with 6xAA/16xAF I get these huge increases. I also installed a new (unreleased) driver and the increase there is even larger. Using the new driver the 17.5fps with standard shader went to 17.6fps (wohoo! ;)) and 20.0fps with modded shader went to 20.7fps. So then the increase by the shader mod is 18%.
     
  19. TheAlSpark

    TheAlSpark Moderator
    Moderator Legend

    Joined:
    Feb 29, 2004
    Messages:
    22,146
    Likes Received:
    8,533
    Location:
    ಠ_ಠ
    Have you contacted JC, Humus :?:
     
  20. jvd

    jvd
    Banned

    Joined:
    Feb 13, 2002
    Messages:
    12,724
    Likes Received:
    9
    Location:
    new jersey
    um please don't tease us with new drivers :)
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...