Category Archives: XNA - Page 2

Welcome to the new site!

Well, it’s been a long time since I’ve written a real blog post, and this is the first one on my new site, so what do I want to talk about!? I suppose we should start with why I migrated to a new site to begin with!

There are two major reasons in reality. First, I needed a web host for some experiments I wanted to run, so I figured I may as well just catch up with the times and buy one. I’m only a decade or so late, but better late than never right? Second, I needed to have more freedom in what I wanted to say. Having my blog hosted on MSDN was great and all, but despite the disclaimer up top, the reality is that anything I say there is essentially the same as saying it as Microsoft. While it’s certainly true some folks go wild on their MSDN blogs, I never felt very comfortable in doing so.  Now, I’ll be able to say whatever it is that I’m thinking!

Of course, this also means that my MSDN blog is essentially retired as of now, but given the frequency (or lack thereof) of posts there, it probably isn’t a big deal anyway!

So, what do I want to talk about on this new site? Well, a lot of stuff I used to talk about on the old site, game programming, XNA, Xbox, and Windows Phone! For example, while my latest XNA book is already out (look to the right), should I consider writing a new one? Perhaps I should release a few games on XBLIG or the WP7 marketplace? I’m not entirely sure what I want to do yet, but now i’ll have the chance to do them without having to worry about speaking as anyone but myself, which will be nice.

A new book on Game Studio 4.0

It has been about five years since my last book came out.  During that time, a lot has happened.  Heck, that book was about Managed DirectX, and at the time it came out XNA Game Studio didn’t even exist as an idea, much less a product.  Since then, it’s not only been released, but we’ve announced the *fourth* version of the product!  We’ve added support for Windows, Xbox, Zune, and soon, Windows Phone 7.

So much has changed, so much time has passed, it was time to do a new book.  This new book will cover Game Studio 4.0 in its entirety, including Windows Phone 7, the new features, Xbox, everything.  While we haven’t announced any release dates for Game Studio, I’m spending my spare time (what little I have) to make sure the book will come out as close as possible to the release of the product.

I’m also having some help with this one, and will have a co-author, so that is a bit exciting too!  Writing has begun so if you have suggestions, now is the time!

XNA Game Studio 3.1 Zune HD Extensions

If you were already developing games for your Zune using XNA Game Studio, you’ll be happy to know that moving that game over to the new Zune HD will be remarkably easy.  Today we’ve released the XNA Game Studio 3.1 Zune HD Extensions that will allow you to deploy to your new device and includes a few new API’s as well.

There is also a thread on the XNA Creators Club forums for any questions or discussions.

2009 Dream.Build.Play winners announced

At PAX this year, we announced the winners of the 2009 Dream.Build.Play contest with Dust: An Elysian Tail taking home the grand prize.

Big congratulations go out to all of the entries, and to the winners, keep up the amazing work.

Dream Build Play 2009 finalists…

Once again, the Dream-Build-Play 2009 competition has provided a ton of great games.  The finalist this years have been announced here, and the winner will be picked at PAX in just a few short days.

The talent and ability the people making these games and the quality of the entries we get never ceases to amaze me.

My blog is a constant source of new and exciting information…

It’s been over a year since my last post, and despite my many promises to myself (and anyone who still reads this thing), I never seem to find time to post here.  Well, other than right now, since I obviously am doing it now.

A lot has happened since my last post.  We shipped Game Studio 3.0 and opened up the Indie Games on Xbox Live, although it was so long ago, it wasn’t even *called* Indie Games back then, it was called Community Games.  I’m sure everyone has heard about it by now, and I still think it’s awesome that you can sell games you’ve created.  Then again, we also shipped a completely new version since then as well in Game Studio 3.1!  Wow, I really am behind aren’t I?  We added cool new stuff like Avatar support in that version.

I even completely forgot about my annual Aprils Fools post!  Of course, I didn’t really come up with a cool topic for that anyway.  I’d make up something outlandish now, but that wouldn’t be nearly as effective since it’s September.

Speaking of Indie Games though, I think I’ve finally decided the game I’m going to write to ship there.  Of course, my idea is way too ambitious for my artistic talent (read; zero), and I have no idea where I’m going to find the time to actually write it, but no matter.  I will finish it and ship it and suffer the ridicule of the masses!

Maybe that will even give me the impetus for writing more here.  We can hope…  If not, lets hope I’ll remember to write something sooner than the next two versions of Game Studio.

Make money from your amazing game creations!

Today we announced the Xbox LIVE Community Games.  You can read more information about it (including a FAQ) here.

What is the big thing in the announcements that could be considered exciting?  You’ll be able to make money from your creations.

As an XNA Creator Club premium member you’ll be able to submit your games to the service, set a price point for your games (between 200 and 800 Microsoft Points), and after a peer review your game will be available to download by millions of game players on Xbox LIVE.  Every quarter, you’ll receive a payment for up to 70% of all money your game has earned.  People will be able to play a trial of your game before they buy it as well.

I remember what seems like forever ago now.  I was sitting in my office trying to convince people that you could use managed code to make games.  That it was feasible to run managed code and make a good game on a console as well as Windows.  I remember the reluctance people had in believing that.  Now look today.  Have you seen Schizoid?  A game that has been released and making money.  Now we have this announcement today.  Almost anyone has the potential to make money by writing a game and getting it on the service.  It couldn’t be simpler.

As for me, I’m celebrating this announcement by taking a trip to Vegas.  (Ok, that’s just coincidence, but still).

Community Games!

For those of you who don’t read the XNA Team Blog the Community Games on Xbox LIVE feature has gone into a beta release!

Plus, the web site looks much cooler now.

So, what does this mean?  It means that premium members can create a game, submit it for peer review, and then have it available on Xbox LIVE.  There’s also a new starter kit, a 2D RPG Game.  There is plenty of information and new cool stuff on the new web site, so go check it out!

I just tried to use four render targets on my Xbox 360 and it failed!!

Dear Mr Miller, you suck.  I’m running in 1080p resolution, and needed to have four simultaneous render targets, and a depth buffer, and I can’t do it.

Now, to be fair, I didn’t actually receive a message like that, but I could see it happening (and I’ve gotten some similar).  One of the features that we added this last release was the ability to use multiple simultaneous render targets on Xbox (up to four of them).  However, this isn’t without restriction.  All render targets that will be used on the device need to fit within the EDRAM (a 10MB chunk of memory). This includes the depth buffer if it exists.  EDRAM isn’t very big at all.

Let’s take a look at an example.  Your Xbox is rendering in wide screen 720p mode with a resolution of 1280×720.  You set your game to run at this exact same resolution with a surface format of Color (32bits) and a 32bit depth buffer as well.  You also turn on 2x multisampling because you hate jaggies like the rest of us.  All of this data needs to fit into EDRAM, so let’s see how big we are.  Each pixel in the back buffer will be 8 bytes (32bit for color, double it for multisampling).  There are 1280×720 pixels, so the back buffer will be taking up approximately 7.3MB of memory.  The depth buffer is the same size, so that’s another 7.3MB, and we’re looking at a total of almost 15MB of data we need to store in our 10MB chunk of memory.

As you can see, even this simple scenario we overstepped our bounds.  Luckily, we have a mechanism (called “tiling”) that allows us to work with this data anyway.  We essentially break our large 1280×720 set of pixels into a series of smaller sets of pixels that *do* fit within the memory constraints.  In the example above, the back buffer could be broken down into two separate “tiles” of size 640×720 with 2X multisampling, and things would work just fine.  With only two possible consumers of this chunk of memory in version one (the back buffer and the depth buffer), you could easily fit the largest possible back buffer sizes within this chunk of memory.

In version two though, we allow up to five consumers of this memory (four simultaneous render targets and the depth buffer).  The memory is broken up equally by all consumers, so in the maximum case, each render target and buffer has to fit within 2 MB of EDRAM.  You can imagine if I called 10MB small what I think about 2MB.  I’m sure you could just think “Well sure Miller, that’s fine, but we could just create hundreds of little tiles and make it all fit.”

There are two big issues with this.  First, performance would be horrible.  Each tile that is rendered actually will have your *entire* scene rendered on to it, then the results of the tiles glued together.  In a complex scene this could add up very very quickly.  Second (and more importantly) we only allow a maximum of 15 tiles to be created at one time.  If your render target or depth buffer cannot fit inside 2MB of memory with 15 tiles or less, you will fail.

Knowing that, what size of render targets can you make?  What if you have a 2048×2048 render target (surface format of Color) with no multisampling?  Would that fit if you had four of them at the same time?  A quick and dirty way of figuring it out would be this:

2048 * 2048 = 4MB * 4bytes (color) = 16MB (total amount of memory needed) / 2MB (maximum size) == 8

So, you’d need 8 tiles for this buffer to render correctly, 8 is less than 15 so you’d be safe.  What if you added 2x multisampling though?

2048 * 2048 == 4MB  * 8 bytes (color+ms) == 32 MB (total amount of memory needed) / 2MB (maximum size) == 16

Nope, 16 tiles is too many, this wouldn’t fit.  What if you didn’t have a depth buffer though?  Depth buffer counts as a buffer in the EDRAM so without it, you’d have 2.5MB per surface available:

2048 * 2048 == 4MB  * 8 bytes (color+ms) == 32 MB (total amount of memory needed) / 2.5MB (maximum size) == 13

13 tiles, you’d fit again!

It’s also important to point out that not all tiles are created equal.  Tiles aren’t calculated based on a memory size, but on a pixel size.  Odd shaped (ie, non-square) render targets will create odd shaped tiles, and the last tile may be larger than needed to account for that.  For example, if you have a 1280×720 surface and 3 tiles used in that, you can be assured that you don’t have 3 separate tiles each of size 426.67×720.  Each tile is rounded up to the next size it can be (normally a mutliple of 32).  In the case above, that 1280×720 surface would really be three tiles of size 448×720 with the third title having some “empty” space in it.  So if you do your little math above and it comes to exactly 15 tiles, you still may be too big if the tiles aren’t the size you’d expect.

Do I really expect someone to try to create and use four simultaneous 2048×2048 Color render targets with 4x multisampling and a 32bit depth buffer?  Well no, because as you’ve seen here, it would fail!  However, if it does fail, at least this hopefully explains why!

By the way, in reference to my fake first question.  You can actually do this just fine, so long as you aren’t using 4x multisampling, and even with 4x multisampling, it just barely doesn’t fit with a depth buffer (1900x1080x16bytes == 31.3 MB / 2MB == 15.6 tiles).  Four 2x multisampled render targets at 1080p would fit though.

Why purple?

One of the things I’m going to try to do this year is write more on my blog.  The publisher for my books is hoping I’ll write something new for them this year as well, although at the moment I don’t know if I’d have the time, or what I’d write about anyway..  Anyone have suggestions on topics they’d like me to cover in a book or a blog post?  Shawn normally goes a great job staying ahead of the curve so the possibilties of topics diminishes some. =)

So for now I’m just going to post a random anecdote that was asked in our internal alias one day..  Why does the framework clear the targets (render targets, back buffer) to purple when RenderTargetUsage.DiscardContents is turned on?

When I originally implemented that feature, I wanted something that jumped out at me and was extremely noticeable.  I picked the brightest, most obnoxious shade of neon green I could.  It did the trick, it was instantly noticeable when it was there.  As time went on though, I kept seeing it all the time, day in, day out, over and over again.  It irritated me something fierce and eventually I decided I just had to change it to something much less obnoxious, so I picked a dark purple.  The intention was to switch it back to the bright neon green before we shipped to ensure everyone got to experience the joy that was that color.

As time went on though, we all got used to the purple.  It was pretty quickly and easily recognized and that was the goal for the clear to begin with.  Why torture everyone’s eyes and have them all hate me when everyone is soothed by the purple?

So, why purple?  To avoid the hate mail that would have come from the original neon green!