(XNA) Switching Render Target causes performance hit

762 views Asked by At

I have the following problem. I'm trying to cut parts of the texture using the Stencil, AlphaTestEffect and RenderTarget, but this causes a huge performance hit for me. Without it, I have close to 30fps, while with it, it drops to 4fps.

I was trying to isolate the root of the problem, and while with it, I noticed that even if I do nothing, but switch the active render target to my custom render target, and then right afterwards if I switch it back to backBuffer, my fps drops by close to 10fps's. All I do is this:

            graphicsDevice.SetRenderTarget(renderTargetA);
            graphicsDevice.SetRenderTarget(null);

While the render target is created that way:

        renderTargetA = new RenderTarget2D(KnightGame.CurrentGame.ScreenManager.GraphicsDevice, 800, 480,
                                           false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8,
                                           0, RenderTargetUsage.PreserveContents);

I tried using DiscardContents, different sizes, but it always drops the fps. I commented all the parts that have to do with cutting off the part of the image and still just with switching the render target it makes a hit to the performance. Can anybody direct me to the cause of this problem?

Lucas

0

There are 0 answers