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


Part of:



[More information...]
 

Latest News
spacer View All spacer
 
November 7, 2009
 
Iwata: 35% Japanese Connectivity Ratio For Wii, 20% For DS
 
iPhone Dev Storm8 Sued Over User Data Harvesting Allegations [5]
 
Game Boy, The Ball Admitted To National Toy Hall Of Fame
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 7, 2009
 
Trion Redwood City
Sr. Environment Artist
 
Trion Redwood City
Sr. Evnironment Modeler
 
FarSight Studios
Software Engineer
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
Texture Artist
 
Sucker Punch Productions
Network Programmer
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
spacer
Latest Features
spacer View All spacer
 
November 7, 2009
 
arrow On Bringing Modern Warfare 2 To Life [3]
 
arrow Games Demystified: Dissidia Final Fantasy [1]
 
arrow Building Social Success: Zynga's Perspective [3]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part I [7]
 
arrow Valve's Writers And The Creative Process [11]
 
arrow Sony's Software Strategy: Shuhei Yoshida Speaks [3]
 
arrow A Holistic Approach to Game Dialogue Production [7]
 
arrow Ancients Reborn: Launching League of Legends [4]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 7, 2009
 
Space of Possibility and Pacing in Casual Game Design - A PopCap Case Study [1]
 
Defining "Hard Core" and "Casual"? [10]
 
Comparative Ludology: A Case Study Using The Sims and Total War
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
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