Thursday, November 27, 2008

Code Samples coming soon

In preparing for the arrival of LRB-1 hardware, I have been updating my personal testbed to D3D10.

Yes, I had been stuck in a D3D9 rut for a while, just like a lot of the rest of the industry. :-)

My personal testbed is based on a maze-generation and solving algorithm, the Kruskal algorithm. A good page to describe maze algorithms in general is here. From this you should understand that a Kruskal maze is a "perfect" maze or a minimal spanning tree over a set of cells in comp-sci speak. I use the "wall-follower" solving strategy.

I decided to use a maze as a testbed for several reasons. First, it lets me easily generate "level geometry". Second, I can use different creation and rendering strategies for the level geometry. to use different Draw APIs, different Draw API frequencies, and advanced features like Instancing and TextureArrays. Third, inside each "cell" or "room" is a perfect candidate to render some special effect like a particle system, an animated object, a reflection system, a shadow system, or something like that. Fourth, I can set up and manage different camera/views. Fifth, the viewpoint inside the maze that tracks the solver is perfect for rendering an animated character.

That is a lot of leverage out of what is a relatively simple algorithm, which is why I picked it and have been using it since D3D6 to keep my skillz current.

Now that I have some simple D3D10 code working, I want to write this up as both a service to other developers and a way to solidify my learnings in my own head. I will use the same style I had in the Driving DirectX articles, which you can see from this article on Flipcode which was essentially the last article in Driving DirectX from me.

I am going to leverage the new DX SDK framework DXUT, which enables writing a single app that will work on D3D9 and D3D10. Some features will be slightly different, due to the fact that the D3D10 SDK does not support .x files well, but other than that the functionality will be the same.

I see 7 articles so far:
1) Explanation of DXUT and what it gives you
2) Basic sample, renders only a frame rate
3) Rendering a "skybox" to place your level "inside" something and give the feel of being in a world.
4) Generating the maze geometry and rendering it
5) Using multiple cameras
6) Solving the maze
7) Rendering a skinned character at the location of the "inside the maze" camera

Each article will cover both the D3D9 and D3D10 implementation. All rendering uses D3D Effects ( .fx files ) and HLSL. SM 2.0 for D3D9 and SM 4.0 for D3D10. If any single article gets too large I will consider splitting the D3D9 and D3D10 pieces into a "2-fer".

Once we get that far, I will see what else I have time for. Possibilities include Instancing and TextureArrays for the level geometry and special effects in a randomly selected subset of the rooms.

The other "big" thing I intend to do is port this to LRB-1 and generate the same series of 7 articles on LRB-1. Hopefully that will also be of some interest?

I am currently working on the D3D9 skinned character in the code for article 7, so the work is well along. Once I finish that code, then the article production beings. So we'll see how fast I can finish the D3D9 skinning code and then pump the first two articles out, and that will give us an idea of what sort of pace you can expect from me. I'd guestimate 2 weeks for the 1st article.

And by the time that is done, the time to start talking LRB-1 in detail should be closer.

And Happy Thanksgiving!

Friday, November 14, 2008

Intel SES 2008

I just got back from my 1st Intel conference. Software and Services Group (SSG) is where most of us “ISV focused” LRB software types live. SSG has a yearly conference for the top engineers, this year called Software Enabling Summit (SES) in recognition of our role in enabling the up-and-coming hardware platforms from Intel. It was held in downtown Portland this year, Nov 10-12. 3 days of "coolbits" at Intel.

Wow, was that intense! Where to start?

I had a cold and that limited my participation in the “after hours bonding sessions”, I mean the drinking at the bars (plural ). Don’t feel sorry for me, though. My limited participation meant I was both chipper in the morning and got to watch my fellow comrades come down in the am much the worse for wear. Some much more than others, J, you know who you are.

Ok, for real this time. :-) Renee James. She is the VP and General Manager who owns SSG. She gave a great keynote to open the conference, especially considering she had a cold and told us so. And her handling of the Q&A was to go right at the questions. Very refreshing.

The materials. My brain hurt each day from the upload of so much information. As well as the Intel tendency to start each day at 8:00am and end it at 6:00pm. Ouch. Don’t they have any respect for drinkers, I mean software engineers :-)? There was a lot of good LRB information. Much of it I already new, since my day job is LRB-focused. But there were some new bits (like how great LRB support for 64-bit will be). Offset continues to look great. And the Smoke demo looks good, with some excellent work combining L-system grammars, particle systems, and systematic exploitation of parallelism on the CPU, which means it will kick butt on LRB.

The people! I met execs that really get it, marketing people I can respect, and a set of engineers who are top, bar done. In terms of specific people, the opportunity to meet up again with Tom Forsyth and chat up Steve Junkins was great..It was excellent to meet Ian Lewis and Nat Duca. Mike Bunnell is amazing. And that’s before we get to the great hires Intel has made like Doug Binks and others on the extended team I am a part of. And I should mention the tool chain; I think Intel may surprise people there.

I get to work with this crew every day. I cannot imagine a better set of people to change the world with.

Saturday, November 8, 2008

When I’m 64*

When will 64-bit take over?

It’s a question whose time has come, in several dimensions, the hardware, the applications, and the pace of innovation.


The hardware is ready.

AMD first shipped 64-bit CPUs in 2003. AMDs CPU product line has 2 segments, desktop and mobile. AMDs desktop line is 64-bit top to bottom, eg Phenom, Athlon, Sempron. The low-end Sempron desktop has been 64-bit since 2005. AMDs mobile line of Turion and Athlon are also 64-bit. Turion has been 64-bit since 2005. Only the bottom end of AMDs mobile line, the mobile Sempron, is not 64-bit.

Intel shipped its first 64-bit CPU in June of 2004. The Intel desktop line consists of Core i7, Core 2 Duo and Core 2. Core 2 was released in June 2006. This “leaked” data with picture gives an idea of the Intel desktop roadmap, although with all sources like this the real data could change.The Intel mobile line consists of Performance (Mobile Core2), Value (Celeron) and NetBook (Atom lines. Only Atom at the very bottom of the line up is Intel not 64-bit.

So AMD since 2005 and Intel since 2006 have had 64-bit support in the vast majority of their CPU products. Considering Gartners’ volume expecatation for 2005 was 202 million units that means we have on the order of 600 million 64-bit capable CPUs in the market as of the end of 2008. 800 million as of the end of 2009.

The size of the installed hardware base is not a gating factor.


Address space is essentially the size of the sandbox each application gets to play in. With a 32-bit OS, the maximum is 4G and Windows democratically splits this into 2G for each application and 2G for the OS “stuff” each application requires. This is called “process address space” and is a hard limit on the memory size available. Note this is completely different than physical RAM; this is virtual space for each process.

There is a growing and significant tide of applications that now need 64-bit address space. You see a hint of this in the fact that Microsoft released the /3G switch at all.

Initially this feature was aimed at and released for “line-of-business” applications like SQLServer and Exchange. Ok, fine, we don’t really care what runs in the server closet.

However, now there are now at least 2 32-bit games that get major benefit from this switch, Supreme Commander and FSX (with Acceleration or SP2). And once there are 2, there will be more. Note, care must be taken with this switch, you cannot just turn it on for any application.

Even 32-bit applications get benefits under a 64-bit OS in that the /3G switch isn’t required to get that extra dollop of process address space.

64-bit-ness just makes this address space issue go away. And the 32-bit limit on address space is starting to cause design challenges in algorithm development. It needs to go away.

The main gating factor here is the availability of 64-bit versions of key applications.

Check out a list of 64-bit native applications. And check out this list of 64-bit games. Note Microsoft is not leading the pack here. Where is Visual Studio as a 64-bit native application? Where is Office as a set of native 64-bit applications? Where is a roadmap showing us when these are coming? I only see criticisms about the lack of roadmaps. How do you convince other developers to go there, when you don’t even show your own plans to go there?

Contrast that to the 13 games on the games list above and key DCC apps like Adobe Photoshop (news already released about Photoshop 64-bit native) and AutoDesk 3DStudio Max which is already available in a 64-bit native version. SoftImage is another native 64-bit app in the DCC space.

Clearly the external developer community is leading here. That is even more impressive given the confusing leadership from Microsoft.

Pace of Innovation

Pace of innovation is the toughest dimension of the issue I am covering. This is another “Goldilocks” zone, in that you want to be “just right". Pick your moment too early, and a product languishes. Pick your moment too late, and you are behind the curve. Pick the right moment and you ride the wave.

In Microsoft's case, though, they could create the wave for the rest of the software development community and by extension the end-user community.

If we examine the past, we can see what the previous pace was and use that to judge the current pace.

The window of time for 16-bit PC OS was 1981 (release of the PC) to 1995 (release of Windows 95 as the 1st mainstream 32-bit OS). That’s 14 years.

Windows 95 to the expected release of Windows 7 in 2009 is also 14 years. Microsoft could have chosen to make Windows 7 the 1st mainstream 64-bit OS.

The "pace of innovation" clock is certainly within reason, as is the hardware and support from non-Microsoft applications. Plus Microsoft certainly has evidence that sales of Win64 Vista are picking up, so it’s unfortunate that Microsoft hasn’t turned the switch in the Windows division or been more effective in flogging the other Microsoft divisions to be fully supportive of this important platform move.

To be fair, Windows division execs are challenging the development community to make 64-bit versions of the applications available.

But that is a little bit of the cart and the horse,and its hard to see how external developers should take this to heart when it appears major parts of Microsoft have not. See above about Microsoft’s own “key applications” and plans for 64-bit. In the past Microsoft led the way in a global sense (all divisions worked together better) and external developers saw this and followed. Now it appears Microsoft wants the external developer community to lead and the non-Windows parts of Microsoft want to follow. That is more than a bit confusing.


Showing true platform leadership and having a grounded belief that sales would follow leadership (and by implication not the other way around) was one of the things that made Microsoft great.

The fact that Microsoft is not “leading” any more in a global sense, since the other divisions do not seem to be playing in the same game as the Windows division - this is disappointing. More than that, though, it is another indication that Microsoft is no longer what it once was. What we have is a void in platform leadership and evangelism from a company that used to define what platform leadership and evangelism was all about…sigh.

The other, even more negative (for Microsoft) side of this is that without Microsoft showing true platform leadership across all divisions in driving the industry forward (and thus being a moving target) means they are now much easier to aim at like Google, Amazon, and others have been doing for the last 6 years since XP shipped.

And thats before we get to gaming strategy on the PC or lack thereof.

*Apologies to Paul and John