Much Derp About Dlls

Started by
18 comments, last by jamesleighe 12 years, 6 months ago
That's true, though to put it in the same context as your original post -- when was the last time that a major game gave you the option to choose between DX8, DX9 or GL? wink.gif

These days I'd just have one executable per platform --
one for Win XP (with the DX9 renderer compiled into it),
one for Linux (with the GL renderer compiled into it),
one for Mac (with the GL renderer compiled into it), and
one for Win Vista/7 (with the DX11 renderer compiled into it).
Advertisement
There is just NO advantage of using DLLs nowadays; at least not for a (simple) game.

Sure, you could claim that you save a few K of memory (but .exe files are demand-loaded anyway, aren't they - in Linux they are, what about Windows?), but I think that's pretty irrelevant.

If your game exe is, say 10M (of code+initialised data, not including linking data and debug stuff which doesn't need to be in memory anyway), and you have 100M of data (which is pretty smalll really), then you might save 2M by making an unused part of your game engine a DLL.

It really is a pointless, premature optimisation, for no particularly good reason.

Use DLLs if you HAVE to, and not otherwise.

There is just NO advantage of using DLLs nowadays; at least not for a (simple) game.

Sure, you could claim that you save a few K of memory (but .exe files are demand-loaded anyway, aren't they - in Linux they are, what about Windows?), but I think that's pretty irrelevant.

If your game exe is, say 10M (of code+initialised data, not including linking data and debug stuff which doesn't need to be in memory anyway), and you have 100M of data (which is pretty smalll really), then you might save 2M by making an unused part of your game engine a DLL.

It really is a pointless, premature optimisation, for no particularly good reason.

Use DLLs if you HAVE to, and not otherwise.


What would be the advantage that a larger game gets over a smaller game?

You never have to use dlls afaik. It's a choice.
It's also not really an optimization, more of a choice of framework.

As for space saving on the exe, its more about instruction cache misses than anything else.
To be fair, I'm doing it for no good reason.
Feels more elegant tho lol.

EDIT:
Plus, the whole engine is already in dlls, I was just trying to hide them. So I'm not really sure what your saying I should do here.
I think people are just scared of them because they think they are complicated but they are ridiculously simple things.

That's true, though to put it in the same context as your original post -- when was the last time that a major game gave you the option to choose between DX8, DX9 or GL? wink.gif

These days I'd just have one executable per platform --
one for Win XP (with the DX9 renderer compiled into it),
one for Linux (with the GL renderer compiled into it),
one for Mac (with the GL renderer compiled into it), and
one for Win Vista/7 (with the DX11 renderer compiled into it).


To be fair, there are plenty of people rocking win7 without dx11 comparable hardware.
I dunno if that would just show up in the capabilities and you would not use dx11 specific stuff or just fail altogether.

[quote name='Hodgman' timestamp='1317974241' post='4870019']
That's true, though to put it in the same context as your original post -- when was the last time that a major game gave you the option to choose between DX8, DX9 or GL? wink.gif

These days I'd just have one executable per platform --
one for Win XP (with the DX9 renderer compiled into it),
one for Linux (with the GL renderer compiled into it),
one for Mac (with the GL renderer compiled into it), and
one for Win Vista/7 (with the DX11 renderer compiled into it).


To be fair, there are plenty of people rocking win7 without dx11 comparable hardware.
I dunno if that would just show up in the capabilities and you would not use dx11 specific stuff or just fail altogether.
[/quote]

You fall back to the highest supported Feature Level then, be that 9_1/2/3 or 10/10_1. If 11 or 11_1 is supported, great! Otherwise, just follow the fall back route. DX8 is deprecated as shit; forget about it. DX9 is still highly relevant, ofc, but less so as XP sees the last rays of light and Vista/Win7 takes over. Since DX11 can use the feature set of DX9 there is no need for DX9...unless you are still supporting XP, which is fair enough I guess. In a couple of years though, that will have changed...
"I will personally burn everything I've made to the fucking ground if I think I can catch them in the flames."
~ Gabe
"I don't mean to rush you but you are keeping two civilizations waiting!"
~ Cavil, BSG.
"If it's really important to you that other people follow your True Brace Style, it just indicates you're inexperienced. Go find something productive to do."
[size=2]~ Bregma

"Well, you're not alone.


There's a club for people like that. It's called Everybody and we meet at the bar[size=2].

"

[size=2]~

[size=1]Antheus

You fall back to the highest supported Feature Level then, be that 9_1/2/3 or 10/10_1. If 11 or 11_1 is supported, great! Otherwise, just follow the fall back route. DX8 is deprecated as shit; forget about it. DX9 is still highly relevant, ofc, but less so as XP sees the last rays of light and Vista/Win7 takes over. Since DX11 can use the feature set of DX9 there is no need for DX9...unless you are still supporting XP, which is fair enough I guess. In a couple of years though, that will have changed...


I'm just saying that would be harder if you ship with special exes for each os.
I'm assuming you would have a launcher that would pick the appropreate exe but there may be other windows7 specific things you do in the win7 exe that you would lose.
Dunno what that would be, but you might.

Windows XP still has 20 percent of the gaming market. (source: valve stats)

I didn't actually write a renderer for dx8, it was more to illustrate a point, I don't even have a fully functional gl renderer up (and prolly will leave it as it is for a while).
Just good ol dx9.
Soon a dx11 when I care enough about the features, I'm gonna skip dx10 :P
Actually, using DLLs is more likely to increase instruction cache misses, because the DLL code is loaded into separate pages of memory by the OS. So when jumping between code in the .EXE and the .DLL, you're crossing a larger memory span than just jumping around within an .EXE.

Of course, whether or not this makes a real difference is hard to say - as always, profiling is king - but using DLLs to make your EXE smaller in the hopes of speeding up the IC is just misguided at best.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


That's true, though to put it in the same context as your original post -- when was the last time that a major game gave you the option to choose between DX8, DX9 or GL? wink.gif

Quite recently, as a matter of fact. I don't have any examples off-hand, but I certainly remember within the last year or two playing games that allowed me to choose between DX9, DX10, or DX11 (perhaps not OGL). It's still relevant to ask the user, too, since different graphics hardware has varying degrees of support, compatibility, and performance with regard to their DX implementations. This is especially true when it comes to performance, since in my experience a particular piece of hardware can claim to "support" a particular featureset, but it doesn't necessarily mean with any degree of performance :) Sometimes it's just so they can get that bullet point on the marketing material!

With regard to the OP, we use DLLs internally for our Debug builds and static linking for our Release builds, simply to reduce link times during development when rapid iteration is necessary... it can take a looooooooong time to statically link an EXE with many libraries, so that's certainly something to consider.

Yeah, turns out that source engine just puts its dlls into a folder derp. (I downloaded hl2 from my steam account and checked)

I thought that having a large exe was generally bad because you have more 'cache misses' or something when you get instructions.
Am I wrong here?
That smaller exes are generally faster?

Does instruction caching work exactly like data caching? (I imagine it would but...)

EDIT:
You don't strictly NEED 'run time modularity' for anything afaik. But people still use it for whatever reason.
I'm doing it simply because, so, maybe that's it.


No, a smaller exe will not have fewer cache misses automatically, it really doesn't matter where the code is loaded from.

The main thing affecting cache misses is local code size (You want the currently running set of functions and the data they operate on to fit in the cache, where that code is loaded from is irrelevant)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Actually, using DLLs is more likely to increase instruction cache misses, because the DLL code is loaded into separate pages of memory by the OS. So when jumping between code in the .EXE and the .DLL, you're crossing a larger memory span than just jumping around within an .EXE.


Thats interesting.

Not that I was using dlls for that.
Like I have said I chose that a while back for no good reason.

This topic is closed to new replies.

Advertisement