Time to take a leap. Since XNA is a generation old now, and I never did use the Pipeline or Game Engine in it, I’m going to move the entire codebase to SharpDX 3. This is a big step but will unlock the DirectX 11 pipeline to me, enabling me to use Geometry Shaders (useful for procedural generation of grass and non-model geometry), and hopefully get a speed boost.
For anyone else trying this; its a big step. XNA “holds your hand” for a lot of the way, especially its useful features for saving and loading textures, dealing with Effects etc. SharpDX 3 is also the first SharpDX release to completely deprectate their XNA-lite Toolkit namespace – there are no Models, no Effects and no handholding. Its you and the bare metal, only barely wrapped in a Managed wrapper to handle COM pointer releases.
Principal issues are
- No support for saving and loading of textures to streams or files
- Use of cBuffer instead of XNA global parameters
- Use of shader fragments (individual PS, VS and GS bytecode) and no Techniques
- Sampler States defined in C# not HLSL
This should all make the code faster because the programmer is more in control of the IO going to the GPU, for instance by being able to update a cBuffer only for the parameters you’ve actually changed, but … if thats your biggest performance rendering headache, you probably have more problems than will be solved by SharpDX.
I found that with a lot of cursing (not least of which is the SharpDX.org site being 404 which is a right pain when Google still indexes it) I could overcome all this, and am gradually debugging through the various code issues raised.
More updates when I get out of the other side.