Hi I am tinking to make my sprites "compiled sprites" in order to gain speed in my game animation loop. Now this will generate from 32 up to 320 progedures for act object i the game... I an not wanting to make them a part of my main exe :) i whoul rather make a .dll out of them and call them at runtime ... My question is how slow will those calls to .dll procedures will be compared to direct calls from my main PE (exe) file? Because this matteres a lot to my frames per second :) Any comments are wellcome... Thx Bogdan
a DLL resides in the same process address space as your EXE so there is no performance loss whatsoever. Calling a function in a DLL is identical to calling one in your own EXE.
As similarly, calling an in-process COM method has the same penality, about zero overhead. (Hey, a COM server is just a DLL exporting it's functions thru a single dll export)
Thanks! So, a custom DLL can read/write my main PE variables?
Bogdan, There may be a couple of tricks that are useful to you, DLL access is fast enough to do what you need but you also need to be aware of the effects of paging and the load time of resources. You can defeat the time lag of paging by preloading the bitmaps with the normal LoadBitmap() API and to make sure the DLL is loaded in memory you can compress it with a PE EXE/DLL compressor. UPX, PEcompact etc .. This forces the whole DLL to be loaded in memory which removes any effect from delays in paging parts of it into memory. Regards, email@example.com
Hutch Well, the whole of the game bitmaps (now about 64M when in memory) will be in this DLL as ASM code (ie compiled sprites). Do you think that this DLL will be paged out? Consider that functions from it (ie painting sprites) will be called in each frame. Is there a way to mark this DLL as un-pageable? We hope it will be smaller than the original bitmaps because all black areas will be omitted.
Hello to all. Calls to procs in LIB and DLL are two different things, although penalty is insignificant comparing with the stuff of procs. Let myProc1 resides in qwe.lib and myProc2 - in asd.dll. Then call myProc1 will be direct call to myProc1, and call myProc2 will be direct call to some "springboard" instruct jmp dword ptr[_imp__myProc2@] linked to your exe from import library asd.lib, that transfers the program workflow to the proper destination. The fastest call to myProc2 will be indirect one call dword ptr [_imp__myProc2@] The _imp__myProc2@ is generated for free to you by linker, when you make importlib for your dll. You may see it in asd.lib. See my message of 30.12.2000 for another usage of the same technique. DVA