This project is read-only.

Using DrawTargetTexture2D in iterative computations

Feb 25, 2009 at 8:40 AM
If I wished to offload simulations onto the gpu using stochastic relaxation methods (like Jacobi iteration), would any tools in the Xen API give a leg up over Xna?  I am aiming for 360 compatibility.

I was thinking about how DrawTargetTexture2D ties drawing objects (functions) to output (data), which is great for encapsulating rendering chains, but not good when the input and output texture are swapped many times to converge on a solution.  Have I missed a better mechanism for doing this with Xen?

Thanks!

Feb 25, 2009 at 11:06 AM

Hi. Thanks for your question.

DrawTargetTexture2D is fairly simple in Xen, the aim is a safe wrapper on XNA render targets and depth stencil buffers (which can cause all sorts of problems if you don't use them in exactly the right way). So in that sense, they have no significant advantage over XNA in terms of ability. They can be cloned with the Clone() method, which allows two or more draw targets to share the same internal render targets, which makes it easier to reuse the target within the frame (if this is your goal).

One advantage the xbox has you may be able to exploit - on the xbox all render targets are drawn in fast temporary ram (the EDRAM on the 360's GPU daughter die). This means if you are applying a single pass filter to a render target, you do not need to do 'ping-pong' drawing (draw A to B, draw B to A...). However this is only true provided the render target (and depth stencil buffer if you use one) fit within the 10mib size of the EDRAM. (so for example 1280x720 with depth fits, but add antialiasing and it doesn't fit). If the target doesn't fit, then it gets drawn in tiles, which could mess up your filter.

Feb 26, 2009 at 3:44 AM
Thanks for the clarification.  It is my goal to reuse the target within the frame, so I think this answers my question.

For the Xbox advantage, do you mean draw to target A, resolve to texture B, and repeat that pair of operations?

Feb 26, 2009 at 3:56 AM
On the PC you must ping-pong, so A->B->A->B->A... Most graphics drivers won't let you sample a texture you are currently rendering to, etc.
However because on the xbox you render your texture to a temporary edram buffer, it's perfectly valid to sample the texture at the same time, because it's only resolved from edram into main memory (replacing the texture) at the very end of the render process. So A->A->A->A... is OK on the xbox. Unless the texture is too big, and is rendered in tiles (in which case you can get problems). The only other side effect is that resolves from edram have their own overhead, so it's something you can only do so many times a frame (anything over ~200 and you will start being resolve limited, even if the textures are very small).
Feb 28, 2009 at 2:20 AM
Very good to know thanks!