Novaleaf Technical Diary
moving to xna4

Now that the Xna4 Beta is out, our team decided to take the plunge.

A few things to be aware of

  1. Xna4 is VS2010 only.
    but xna4+vs2010 can live side-by-side xna3.1+vs2008 
  2. Xna4CTP uninstall is a PoS (broken)
    use the  XNA Game Studio cleanup tool if you run into problems uninstalling any version of XNA.  (you will)
  3. Resharper 4.5 does not work on VS2010
    upgrade to 5.0!
  4. Resharper 5.0 doesnt really work on VS2008
    a lot of key commands are broken :(
  5.  XNA4 contains breaking changes
    especially in rendering.  hope you like refactoring. 

Now is an ideal time to upgrade:  

we are rewriting our rendering system, so best to do this as part of our shift to xna4, especially looking at a “fixed function fallback” system.

We already did some tests to make sure our code isnt a nightmare to port, so good times.

-JasonS

critical section perf trick: reducing casts

If you’ve ever had to do something like this:

if(someObject is MyType)
{
var myClass = someObject as MyType;
myClass.DoStuff();
}

then give this a try in critical (perf) sections instead:

var myClass = someObject as MyType;
if(myClass!=null)
{
myClass.DoStuff();
}

it reduces your cast operations to 1 instead of two, and offers similar readability.

enjoys

-JasonS

.Net SortedSet<T> is almost awesome

I’m working on rendering infrastructure right now, and came up with an idea for how to store and sort renderPackets based on criteria efficiently using a binary heap.

What’s the BCL got?

That’s great, but I remembered seeing an MSDN article on a new BCL collection called SortedSet<T>

Nice features

It’s pretty sweet.  As this CodeProject article describes, it has a neat Sub-Tree filter that can be used to partition the view, and it has good CPU performance with O(LogN) time.

Not good enough

Unfortunately, it seems like the BCL team is lapsing a bit on QC:  SortedSet<T> is implemented using classes for Nodes, not structs.  This has massive, harmfull, repercussions on CF.NET, and therefore makes SortedSet<T> unusable for a core, high-performance game system.

What’s to be done?

Thankfully, I can salvage the goodness of SortedSet’s features by implementing my own version of the class using a struct Node[] array as storage.  It’ll take a little time, but I can use the BCL API’s as reference, and that will give me a SortedSet that offers good CPU and GC performance.

-JasonS

Everything you ever wanted to know about CF.NET performance

These are the holy scriptures of CF.NET performance,

specifically written for XNA’s XBOX360 CF.NET implementation 3 years ago,  those people doing WP7 development should be able to learn extremely useful perf tuning tricks from these:

  1. http://blogs.msdn.com/b/netcfteam/archive/2006/12/22/managed-code-performance-on-xbox-360-for-the-xna-framework-1-0.aspx
  2. http://blogs.msdn.com/b/netcfteam/archive/2006/12/22/managed-code-performance-on-xbox-360-for-xna-part-2-gc-and-tools.aspx

-JasonS

.net 4.0 “ElasticObject” (dynamic duck typing)

I came across something nice for .net 4.0, potentially scripting functionality 

http://amazedsaint.blogspot.com/2010/02/introducing-elasticobject-for-net-40.html

Elastic Object offers a nice way to define/edit xml via duck typing, which may be useful for user-specificed data formats.

keeping it in mind, but unfortunately compiler services are not part of the CF framework, so this long-term usefulness is fairly limited at this time.

-JasonS

new sandcastle is out

At Novaleaf, we use Sandcastle to generate code documentation.

Not only code documentation, but as part of our “Novaleaf Simplified Process”, a major concept is “Close To Code”, meaning if possible, all documentation should be done in the code files.

So, code documentation tools are very important to our development methodology.

We are about 2 weeks away from moving to Xna4, which requires VS2010, and would let us support use of .Net 4.0, so i was happy to find out today that a new .NET 4.0 version of sandcastle is released.

- JasonS

free c# design pattern ebook:  if you don’t own one, this may be your ticket….

Gamefest 2010 presentations

A msdn blog noted that the gamefest 2010 content is up and available to download

get the US or UK content

enjoy!

-JasonS

cool .net 4 feature: Unity

http://unity.codeplex.com/

Unity is a dependency injection framework.

not a mono based game engine ;)

-JasonS

Building Windows Phone 7 Games with Xna Game Studio 4.0

Microsoft TechEd has released a video presentation and it’s ppt slides describing how to do just that.

Great tools and education people, get your game on!

-JasonS