Migrating the Bastion (to XNA 4.0), part one
by shinali
After further inspection of MonoGame, it seems they're trying to move over to XNA 4.0 as well. It's kind of annoying how either MonoXNA or MonoGame haven't fully structured towards the XNA 4.0 API, but making changes that is obvious that they are. I might be thinking about MonoGame since that seems more supported. Anyways, onto XNA 4.0. I've confirmed my suspicions of ResolveBackBuffer via expe...
After further inspection of MonoGame, it seems they're trying to move over to XNA 4.0 as well. It's kind of annoying how either MonoXNA or MonoGame haven't fully structured towards the XNA 4.0 API, but making changes that is obvious that they are. I might be thinking about MonoGame since that seems more supported.
Anyways, onto XNA 4.0.
I've confirmed my suspicions of ResolveBackBuffer via experimentation, and while "Resolve" is probably the most confusing word to use in this instance, it almost means what it says it is. That is, copy over the contents of the back buffer into whatever texture you pass into. This would be done after you've drawn all that you need to. This is similar to using SetRenderTarget, which you call before you draw anything. The operation isn't meant as "copying", though, as it changes the render target from the "screen" to a texture you've created in the GPU. Forgive me on reiterating how XNA works, I've never used much of it.
ResolveBackBuffer is used in two ways in Bastion: grabbing the unprocessed scene in order to apply some bloom post process, and to get a screen shot. One way I think I can solve this is setting a RenderTarget in the beginning of the drawing process, replace all calls to ResolveBackBuffer to refer to this RenderTarget texture, then setting the render target back to the screen and rendering the drawn-into render target texture onto a full screen quad at the end of the drawing cycle. This looks like something I can implement into XNA 3.1 first, so I'll try that just to confirm the process. Once that is done, that can be transitioned into my XNA 4.0 branch with little modification.
There are two more issues, though I haven't investigated them fully. One deals with SpriteBlendMode, or rather the lack of it in XNA 4.0. It's been transitioned to else where but I need to investigate the code further. The next is a little scarier; XNA 4.0 axed the DepthStencilBuffer object and directly incorporated it into render targets. This means every render target has it's own depth stencil buffer and cannot be switched out; meaning multiple render targets cannot share a stencil buffer. Hopefully Bastion doesn't do this, but I'll figure out a way regardless.
Addendum:
Found out a patch was recently released, should look into merging it's changes into my tree.