Sign in to follow this  
jamesleighe

Much Derp About Dlls

Recommended Posts

How do major engines hide all their dlls?


I'm sure they use them, but I never see any. I know the source engine is supposed to be pretty modular (read: uses dlls) but I cant find em!
Is there a way to hide/compact my dlls into some kind of thing where I can use them as needed but don't need a crapload of dlls cluttering yup the game folder?

Thanks guys.

Share this post


Link to post
Share on other sites
You could use static code libraries instead of dynamic code libraries ([i][font="'Courier New"]lib[/font] instead of [font="'Courier New"]dll[/font][/i]) -- this kind of library gets compiled ([i]linked[/i]) directly into the [font="'Courier New"]exe[/font] file.

Share this post


Link to post
Share on other sites
I was thinking that, but then I will have some useless code in the exe (which is fine?) since the dx9 renderer is seperate from the dx8 renderer is sperate from the opengl renderer and only one needs to be loaded at once for example.

EDIT:
It's definately possible.
http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx

But it's more a matter of best practice at this point.
It would also be nice if I didn't have to change any code and could still call LoadLibrary (dllName) even if it's not really in the dir. (this might be asking too much)

Share this post


Link to post
Share on other sites
You'll find almost all .dll files stored in one subfolder or another. Usually folders like "System" and "Core" contain these things.There is no reason they need to be in the [i]same [/i]folder after all. Static linking is also there, if it's warranted.

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1317965747' post='4869989']
Why do you assume everyone uses DLLs for modularity?


Maybe more to the point: why do you assume DLLs are [i]synonymous[/i] with modularity?
[/quote]

I think I remember a keynote where valve said they are using dlls for all their components now.
So that's where I got that from.

It may not be synonymous completely, but it's pretty nice being able to plug in a system without having a larger exe than needed storing many systems when few will be used.

Share this post


Link to post
Share on other sites
[quote name='DarklyDreaming' timestamp='1317965768' post='4869990']
You'll find almost all .dll files stored in one subfolder or another. Usually folders like "System" and "Core" contain these things.There is no reason they need to be in the [i]same [/i]folder after all. Static linking is also there, if it's warranted.
[/quote]

Yeah, I guess I'll just put them into some dir out of the way, probably massively easier than anything else I could do.

Share this post


Link to post
Share on other sites
There are two basic timeframes at which modularity comes into play: code time, and run time. At code time, modularity is all about how you organize the program itself; whether it gets smashed into a single .EXE at the end is more or less irrelevant. Run time modularity is where dynamic linking (and DLLs on Windows) comes into play, and that's a different beast.

I think you'll find that much software accomplishes code-time modularity without needing any of the complexity or overhead of run-time modularity. This is certainly true of most games (and other software) I've worked on.

Probably what you're witnessing is that most people need code-time modularity but not run-time, and therefore don't bother with DLLs at all. Those who do often place them in subdirectories as has been mentioned, or if the DLLs are shared by multiple programs, might place them somewhere else entirely, such as AppData or a special path under Program Files. Older programs (which, it must be noted, are misbehaving by doing this) might even use System32.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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? [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]

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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='markr' timestamp='1317974353' post='4870020']
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.
[/quote]

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.

Share this post


Link to post
Share on other sites
[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? [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]

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).
[/quote]

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.

Share this post


Link to post
Share on other sites
[quote name='James Leighe' timestamp='1317977911' post='4870030']
[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? [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]

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).
[/quote]

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...

Share this post


Link to post
Share on other sites
[quote name='DarklyDreaming' timestamp='1317985394' post='4870060']
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...
[/quote]

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

Share this post


Link to post
Share on other sites
Actually, using DLLs is [i]more[/i] 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 [i]real[/i] 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.

Share this post


Link to post
Share on other sites
[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? [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]
[/quote]
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.

Share this post


Link to post
Share on other sites
[quote name='James Leighe' timestamp='1317970954' post='4870011']
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.
[/quote]

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)

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1318012566' post='4870216']
Actually, using DLLs is [i]more[/i] 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.
[/quote]

Thats interesting.

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this