SharpDX 3 Pain Points

Well down the road to converting my XNA4 project to SharpDX 3 and I think I’ve overcome most of the pain points. The ones that held me up were;

1) Write a SpriteBatch replacement. I did this by downloading the existing SpriteBatch class originally in the SharpDX Toolkit (now deprecated) and converted it for my use. I use this extensively in my texture preparation pipeline.
2) Write a Texture to byte[] serializer and deserializer to store textures in my content database instead of on disk. It probably would have been easier just to revert to single disk file access, but the performance penalty of opening all those little files all the time was noticably slower than fetching them from a nice efficient database (I use SQLCE but will probably move to Raven).
3) The custom vertexes work sublty differently in DirectX11 and this looked like being a real pain, until I discovered the SharpDX.D3DCompiler.ShaderReflection namespace which allowed me to calculate the various VertexElement structures directly from the compiled shader code.
4) The Constant Buffers byte alignment rules were just painful. Took a while to get them right, and found it very helpful to use the command line Shader compiler to output its headers, which helpfully had all the byte offsets in them, and it was an easy cross check to my C# struct declarations.

I’ve got the basic landscape rendering again, and I just need to extend the re-work to all the world objects – vegetation principally, which should be a matter of “rinse and repeat” then I can get my hands on the new Geomoetry and Hull shaders to get rid of some of my large geometry buffers that could be generated from texture samples – especially grass blades.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s