|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic Page: 1 2 3 4 5 6 7 8 9 »» |
Last Thread Next Thread ![]() |
| Enginuity, Part III |
|
![]() pan narrans Staff Member since: 6/4/2002 From: Leeds, United Kingdom |
||||
|
|
||||
| Hmmmmm, some interesting new concepts for me to explore. Cheers, superpig pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code |
||||
|
||||
![]() voodoo_john Member since: 5/2/2001 From: Glasgow, United Kingdom |
||||
|
|
||||
| num num num :9 |
||||
|
||||
![]() superpig GDNet Technical Lead Member since: 5/26/2001 From: Oxford, United Kingdom |
||||
|
|
||||
| pan narrans, is it just me or do you have the first reply in all the Enginuity discussion topics? |
||||
|
||||
![]() Ready4Dis Member since: 4/26/2002 From: USA |
||||
|
|
||||
| A few problems with that code though... first, it relies on SDL_GetTickCount, which.. well, just isn't accurate enough for such small time stamps, hence you could see a bottleneck in one run, and the next run it dissappears (because it wasn't really a bottleneck, the timer just isn't accurate enough to measure such small time slices). I would say you are better off using the rdtsc (Read time stamp counter). It measures the number of CPU cycles taken to process a certain section, and is thus, MUCH more accurate. (Of course, you have to store this in a 64-bit number as it grows very large, very quickly). Simple example on how to use this (msvc style):
inline unsigned __int64 readTimeStampCounter()
{
#pragma warning( disable: 4035 ) // Disable warning message "no return value"
__asm rdtsc
}
This will return the clock cycle of the CPU |
||||
|
||||
![]() Greg K Member since: 9/20/2001 From: Canada |
||||
|
|
||||
| If you want to use RDTSC I suggest you take a look at this. |
||||
|
||||
![]() superpig GDNet Technical Lead Member since: 5/26/2001 From: Oxford, United Kingdom |
||||
|
|
||||
quote: Sounds good... but: 1) Are you sure _rdtsc is cross-platform? Remember, this is all meant to run on linux/macOS... 2) SDL_GetTickCount uses (on Win32 at least) QueryPerformanceCounter, or so I'm told. For a quick-and-dirty runtime profiler, that's accurate enough for me... If you're not bothered by those, then by all means use a cycle counter - I could forsee problems when trying to calculate the framerate from that, though. Superpig - saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery. |
||||
|
||||
![]() skillfreak Member since: 8/22/2001 From: East Lansing, MI, United States |
||||
|
|
||||
| Could you please push out the next article? =) I know you have a few more written. This community, as well as I, would def be most appreciative if you could push another one out soon. lol aka. tomorrow? Aside from that, your series is absolutly fabulous. Keep up the great work. -- andy |
||||
|
||||
![]() lucinpub Member since: 12/21/2001 From: Irvine, CA, United States |
||||
|
|
||||
| love the series so far, waiting for more... just one thing... its www.fmod.org not www.fmod.com |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Great article! Really! |
||||
|
||||
![]() superpig GDNet Technical Lead Member since: 5/26/2001 From: Oxford, United Kingdom |
||||
|
|
||||
quote: Aww, crap. I thought it was the other way around... had the same problem with the original draft in the Game Programming forum. skillfreak: Uh, I'd better give my typing fingers time to cool down first Superpig - saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery. |
||||
|
||||
![]() cthulhu78 Member since: 5/26/2003 From: Dundee, UK |
||||
|
|
||||
| Astonishing article as the others two! Congratulations I'm waiting for the next one! |
||||
|
||||
![]() Pipo DeClown Member since: 2/16/2002 From: Amsterdam, Netherlands |
||||
|
|
||||
| No need to say the said, tell the told, speak the spoken. How many articles more do you still have for us? .lick |
||||
|
||||
![]() Synder Member since: 12/27/2002 |
||||
|
|
||||
| Enginuity (lol) I'm glad somebody's willing to tackle how to make a game engine properly (using OOP w/ C++ at least). Chris Hargrove did a good job in cotc, sad to see it's 'fate' though. Be interesting to see what kinda games come from gamedevers using the engine from yer series. Looking forward to part 4, gl superpig (I hope you didn't get yer name from savin those pigs in Earthworm Jim |
||||
|
||||
![]() sbennett Member since: 9/27/2001 From: United Kingdom |
||||
|
|
||||
| <nit-pick> In the kernel loop, isn't ++it faster than it++? </nit-pick> |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| The warnings are starting to build up and I'm getting 3 errors due to not returning anything from the CMMPointer's = operator (although I didn't earlier) error C4716: 'CMMPointer<ITask>::operator=' : must return a value with the first one, inline operator =(const CMMPointer<T> &p) and error C4716: 'CMMPointer<ITask>::operator=' : must return a value error C4716: 'CMMPointer<BaseDator>::operator=' : must return a value with inline operator =(T* o) |
||||
|
||||
![]() superpig GDNet Technical Lead Member since: 5/26/2001 From: Oxford, United Kingdom |
||||
|
|
||||
quote: You must be using GCC or MSVC7. MSVC6 lets me get away with it, but I'm aware that it officially, operator= is meant to have a return type specified. should be It's fixed in my current code (as far as I know) so the later articles will have updated source. Pipo: Not sure, at least 3 more. Synder: heh. Actually, it comes from a cartoon character I used to draw, though I'm told it's also the name of an obscure anime series. Oh, and if anyone actually *does* develop something using Enginuity code, I always appreciate a heads-up. I wanna see what amazing things people do with it! sbennett: *sigh* I seem to remember the discussion on the draft article (in the depths of the game programming forum) lost about 3 pages to that question Superpig - saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery. Enginuity1 | Enginuity2 | Enginuity3 [edited by - Superpig on July 5, 2003 5:42:52 PM] |
||||
|
||||
![]() Ready4Dis Member since: 4/26/2002 From: USA |
||||
|
|
||||
quote: You can use rdtsc on any current x86 cpu (I forget when it came out, but I beleive any pentium 1+ has it, maybe even the 486's?). MacOS, you will have to find a different way to acheive this (although, i believe it has something very similar), but I wouldn't rely on GetTickCount.. it's only accurrate to 10 milliseconds, which is MUCH longer than a lot of smaller functions take. So, it will appear that a 10ms function takes the same time as a 1ms function, and if that 1ms function is called repeatedly, it will appear like it's taking up WAY more time than it really is, so you'll be trying to fix things that aren't actually bottle necks. Yes, calculating the frame rate from it would be hard (you'd have to figure out the cpu speed to be able to use this value for anything time based), but comparing it against itself for percentages will work properly for something like this without needing the clock speed. When it comes to profiling small sections of code that are run many times, the missing accuracy in the GetTickCount method will probably have a lot of people optomizing stuff that isn't a problem. |
||||
|
||||
![]() superpig GDNet Technical Lead Member since: 5/26/2001 From: Oxford, United Kingdom |
||||
|
|
||||
quote: Could you point me to evidence of that? Not that I don't believe you, just that I've been told it uses QueryPerformanceCounter (which is accurate to 1ms). Superpig - saving pigs from untimely fates, and when he's not doing that, runs The Binary Refinery. Enginuity1 | Enginuity2 | Enginuity3 [edited by - Superpig on July 5, 2003 5:33:56 PM] |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| I'm thoroughly enjoying this series so far, even though I'm not personally interested in writing a game at this point, it's still providing tons of useful information applicable to many other projects. Good job |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Why should settings be stored in a std::string? Why not boost::any? |
||||
|
||||
![]() voodoo_john Member since: 5/2/2001 From: Glasgow, United Kingdom |
||||
|
|
||||
quote: Because BOOST isn't being used..... |
||||
|
||||
![]() Illumini Member since: 10/13/2002 From: California, USA |
||||
|
|
||||
| superpig I believe your right about the Performance counter, however SDL most likely falls back to Window's GetTickCount if a performance counter is not available (not sure what cpu's don't have this). If so your only going to have 10-15 ms accuracy. |
||||
|
||||
![]() Ready4Dis Member since: 4/26/2002 From: USA |
||||
|
|
||||
| I just checked the SDL code, and it uses querryperformancecounter if available, but does fall back to GetTickCount when it's on windows CE (under a windows platform). It should be accurate enough under most version of windows, not sure about the linux implementation. I also found out that queryperformancecounter is very slow to call, where my version is much faster in this case. I guess it'll be fine for the majority of programmers on this site, as most run a version of windows with a high performance counter built in. I wasn't sure what SDL_GetTickCount used and judging by the name, it appeared to be just a copy of GetTickCount with an SDL thrown in front of it |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| Settings.cpp c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(14) : warning C4311: 'type cast' : pointer truncation from 'CSettingsManager *' to 'int' c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(9) : while compiling class-template member function 'Singleton<T>::Singleton(void)' with [ T=CSettingsManager ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\Settings.h(16) : see reference to class template instantiation 'Singleton<T>' being compiled with [ T=CSettingsManager ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(14) : warning C4311: 'type cast' : pointer truncation from 'Singleton<T> *' to 'int' with [ T=CSettingsManager ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(15) : warning C4311: 'type cast' : pointer truncation from 'Singleton<T> *const ' to 'int' with [ T=CSettingsManager ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(15) : warning C4312: 'type cast' : conversion from 'int' to 'CSettingsManager *' of greater size c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\mmanager.h(41) : error C2440: 'return' : cannot convert from 'CMMPointer<T>' to 'int' with [ T=BaseDator ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\mmanager.h(37) : while compiling class-template member function 'int CMMPointer<T>::operator =(const CMMPointer<T> & with [ T=BaseDator ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\utility(56) : see reference to class template instantiation 'CMMPointer<T>' being compiled with [ T=BaseDator ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(42) : see reference to class template instantiation 'std: with [ _Ty1=const std::string, _Ty2=CMMPointer<BaseDator> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled with [ _Traits=std::_Tmap_traits<std::string,CMMPointer<BaseDator>,std::less<std::string>,std::allocator<std: ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled with [ _Traits=std::_Tmap_traits<std::string,CMMPointer<BaseDator>,std::less<std::string>,std::allocator<std: ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(101) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled with [ _Traits=std::_Tmap_traits<std::string,CMMPointer<BaseDator>,std::less<std::string>,std::allocator<std: ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(77) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled with [ _Traits=std::_Tmap_traits<std::string,CMMPointer<BaseDator>,std::less<std::string>,std::allocator<std: ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\Settings.h(31) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr,_Alloc>' being compiled with [ _Kty=std::string, _Ty=CMMPointer<BaseDator>, _Pr=std::less<std::string>, _Alloc=std::allocator<std: ] Kernel.cpp c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(14) : warning C4311: 'type cast' : pointer truncation from 'CKernel *' to 'int' c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(9) : while compiling class-template member function 'Singleton<T>::Singleton(void)' with [ T=CKernel ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\Kernel.h(20) : see reference to class template instantiation 'Singleton<T>' being compiled with [ T=CKernel ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(14) : warning C4311: 'type cast' : pointer truncation from 'Singleton<T> *' to 'int' with [ T=CKernel ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(15) : warning C4311: 'type cast' : pointer truncation from 'Singleton<T> *const ' to 'int' with [ T=CKernel ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\singleton.h(15) : warning C4312: 'type cast' : conversion from 'int' to 'CKernel *' of greater size c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\mmanager.h(48) : error C2440: 'return' : cannot convert from 'ITask' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\mmanager.h(44) : while compiling class-template member function 'int CMMPointer<T>::operator =(T *)' with [ T=ITask ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\list(34) : see reference to class template instantiation 'CMMPointer<T>' being compiled with [ T=ITask ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\list(51) : see reference to class template instantiation 'std::_List_nod<_Ty,_Alloc>' being compiled with [ _Ty=CMMPointer<ITask>, _Alloc=std::allocator<CMMPointer<ITask>> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\list(71) : see reference to class template instantiation 'std::_List_ptr<_Ty,_Alloc>' being compiled with [ _Ty=CMMPointer<ITask>, _Alloc=std::allocator<CMMPointer<ITask>> ] c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\list(88) : see reference to class template instantiation 'std::_List_val<_Ty,_Alloc>' being compiled with [ _Ty=CMMPointer<ITask>, _Alloc=std::allocator<CMMPointer<ITask>> ] c:\Documents and Settings\Matt\My Documents\Visual Studio Projects\Engine\Engine\Kernel.h(34) : see reference to class template instantiation 'std::list<_Ty,_Ax>' being compiled with [ _Ty=CMMPointer<ITask>, _Ax=std::allocator<CMMPointer<ITask>> ] Still alot of problems. |
||||
|
||||
|
Page: 1 2 3 4 5 6 7 8 9 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|