Contents
Secrets of Multiplatform Data Baking
 
 
Printer-Friendly VersionPrinter-Friendly Version
 


Part of:



[More information...]
 

Latest News
spacer View All spacer
 
February 9, 2010
 
EA Reduces Quarterly Loss, Claims #1 Publisher Position [5]
 
EA: Distribution Business To Be Pared Down, Headcount Stable In 2010
 
Game Developer Announces Salary Survey Call, Now Including Indies [4]
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
February 9, 2010
 
Tarsier Studios
Senior Game Engine Programmer
 
Konami Digital Entertainment Co., Ltd.
Sound designer
 
Vicarious Visions / Activision
Tools Programmer
 
Trion Redwood City
Sr. Environment Modeler
 
Trion Redwood City
Sr. Graphics Programmer
 
Sparkplay Media
Senior Game Designer
 
Blue Fang Games
Producer: Online/Mobile
 
Blue Fang Games
Senior Server Engineer: Online/Mobile
spacer
Latest Features
spacer View All spacer
 
February 9, 2010
 
arrow Television, Meet Games
 
arrow Two Halves, Together: Patrick Gilmore On Double Helix [1]
 
arrow The Road To Hell: The Creative Direction of Dante's Inferno [18]
 
arrow The Sensible Side of Immersion [10]
 
arrow Jumpstarting Your Creativity [5]
 
arrow Truth in Game Design [49]
 
arrow Postmortem: Vicious Cycle's Matt Hazard: Blood Bath and Beyond [4]
 
arrow Developers React: The iPad's Future [16]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
February 9, 2010
 
[Lineage 2] Freya Update Is Just a Beginning ②
 
Swashbuckling for Landlubbers: Why you may already be encouraging piracy! [7]
 
[Lineage 2] Freya Update Is Just a Beginning ①
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Feature Submissions
Features
  Secrets of Multiplatform Data Baking
by Noel Llopis
0 comments
Share RSS
 
 
May 6, 2009 Article Start Page 1 of 3 Next
 

[In this technical article, originally printed in Game Developer magazine late last year, veteran game programmer Llopis continues his look at data baking by examining how different console and PC game platforms treat data in memory.]

Baking is often described as precision cooking. Unlike boiling spaghetti or simmering a stew, baking usually requires a very particular ratio of ingredients, precise directions, and an exact time and temperature in the oven. If any of those parts changes, the overall result will be affected, often in not very pleasant ways.

The same is the case with data baking. In last month's column, I covered the basics of data baking, from the time data is exported from the content-creation tool, to the time it makes it into the game.

What I didn't discuss was that different target platforms often have different in-memory formats. If the memory image created by the baking process is off even by a single bit somewhere, the result is usually completely unusable data.

Bypassing the Problem

It is possible to bypass the problem completely by baking your data in the target platform. Then all you need to do is load up your data structure and save it to disk. End of story.

That approach might work well for PC games, even when you're doing cross-platform development. If you're developing in Windows, it's pretty easy to involve a Mac or a Linux machine in the baking process.

Although in the case of PC games, the amount of data baking you can do is limited because you hardly ever know the exact hardware your game will run on, so you might not need to involve target machines at all.

If you're developing for game consoles or other fixed platforms, where you definitely want to create the exact memory image of your data, you could consider involving the target platform in the data baking process.

While it is possible to use a game console to build your data, and some games have done that in the past, it's a route fraught with peril and potential for disaster. You're likely to encounter difficulties in automating data builds, poor handling of errors and crashes, slow builds because of underpowered machines, or even just a lack of hardware to build data on.

Whenever possible, stick to using development PCs for data baking. That will give you the fastest and most reliable builds, but you'll need to invest a bit of work to create the exact memory image for your data.

A Matter of Size

Imagine you're about to bake a structure like this:

struct WaypointInfo
{
int m_id;
bool m_active;
float m_position[3];
char m_letter;
};

It looks like an innocent enough data type, right? Surprisingly, it can have wildly varying sizes and layouts in different platforms (see Figure 1, below). There are three things that will affect its size and layout:


Figure 1: Two possible ways the structure could be in memory.

1. Size of Basic Data Types

How big is an int exactly? Or a bool? The C standard doesn't specify a size for any fundamental data type.

In some platforms ints and floats will be 32 bits, and sometimes they will be 64 bits. You're likely to encounter the inconsistency that a Boolean can sometimes be 32 bits and sometimes 8 bits. That's going to change things!

2. Member Padding

You may think that all members of the structure will be laid out sequentially in memory, and that's almost true. Again, referring to our trusty, if slightly verbose, C standard, we find that members have to be laid out in memory in the same order they were declared in the structure (only if they're within the same public/private/protected block though), but they could have gaps between them.

How big are those gaps? It depends on the platform, compiler, and specific compilation flags. Most often compilers will add padding between member variables to improve performance access to each member variable.

In 32-bit processors, it's faster to load a 32-bit value if it's aligned on a 32-bit boundary, so most compilers will insert enough padding to align it that way.

 
Article Start Page 1 of 3 Next
 
Comments

none
 
Comment:
 


Submit Comment