Archived

This topic is now archived and is closed to further replies.

redigjohn

Is it worth it to optimize your game for AMD and/or Pentium processors?

Recommended Posts

After writing a couple small, stupid programs i was pondering the creation of a game and i was thinking about different parts of games and came across the use of optimization in corp. class games, they usually always optimize their code for Intel/AMD. Is it worth the hassle to recode everything to make your code run fast and be small? It just sounds like it would be a hassle to do that for a big project.

Share this post


Link to post
Share on other sites
Some of the SIMD operations can be much faster if your data are setup to take advantage of them, but when you are optimizing any program, its imortant to remember to concentrate on optimizing the most frequently executed code. For instance, you may cut your file loading time by 50%, but if you spend only 2 seconds loading the files, you saved only a second. If you optimize the render loop and save 10%, you could get several frames per second. If you use direct X, it should already be optimized for SIMD instructions. The portion of your code that you have to optimize should be fairly small.

Share this post


Link to post
Share on other sites
Yup, I agree with invective, you should only optimise the stuff which needs optimising. In our last 3D PC game (Pac-Man:AIT/publ. by Hasbro), only about 1-2% of the code had any CPU specific optimisations. (The engine uses D3D so we got their PSGP CPU specific optimisations for free too). Keeping the engine extremely modular makes it very easy to recode specific parts without having to make changes all over the code base.

The way to tell which stuff will give you the best peformance boost you should profile the code with something like Intel VTune or NuMega TrueTime.

I''ll assume you''re talking about SIMD optimisations (MMX, 3DNow!, SSE, SSE2) here rather than other CPU specific differences (such as cache sizes etc)...:

Generally SIMD is best suited to situations where you need to perform a _small_ repetetive job on a largeish block of data where you don''t need much logic based on the data.

MMX (Multi Media eXtensions) is now widely supported. It allows you to perform the same operation multiple *integers*. It''s well suited to jobs like software rendering, software alpha translucency etc where the same operation if performed on each pixel. A really simple use for it is adding an offset to every index in a very large array of numbers (something the Pac-Man engine needed to do with mesh indices quite a lot).

3DNow!, SSE (Streaming SIMD Extensions) and SSE2 are reasonably well supported (most modernish AMD chips do 3DNow!, Pentium3 does SSE and Pentium4 does SSE2). These follow the same idea as MMX, except they operate with floating point data. Which makes them ideal for repetetive maths operations.

An example of an ideal task for floating point SIMD is "transform a large array of 4D vectors (x,y,z,w) by a single matrix". In D3D, this is one of the things it''s used for. But the same kind of operation pops up all over 3D games programming. For example the physics code might want to transform a list of collision points or forces into some specific space.

Both AMD and Intel have lots of examples, tutorials, training notes, hints&tips etc on their websites if you''re interested in doing this stuff.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites