Jump to content
  • Advertisement
Sign in to follow this  
ApolloCay

Code paths

This topic is 5057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a CVector class with different code paths optimized for various cpu features. Features like 3D Now, SSE, SSE2. I also have a path that supports standard C++ in case none of those features are supported. The code path is chosen based on another class called CPUTest. This class just checks what type of processor is being used and what type of SIMD it supports. I accomplish the path switching using function pointers. All this works fine except... I don't know how to tie the two classes together without calling the CPUTest class functions over and over again. Every time I create an object of my CVector class, it needs to call the CPUTest functions for SIMD support. That's not what I want. So what's the best way to tell my CVector class what path to choose without having to run the CPUTest every time a CVector object is created?

Share this post


Link to post
Share on other sites
Advertisement
have a static member function within your class that you run once at startup to set the function pointers for the whole class, and then just use the static function pointers that C-Junkie suggested.

That way you wont even have to check whether or not the static has been set you'll just be able to use it. Obviously use asserts in your code to catch unassigned function pointers in debug mode [smile]

i think anyway, sounds like quite a good system already though.

Andy

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!