我有以下问题。我正在尝试使用Stencil,AlphaTestEffect和RenderTarget剪切部分纹理,但这会给我带来巨大的性能影响。没有它,我接近30fps,而它,它下降到4fps。
我试图找出问题的根源,虽然我已经注意到即使我什么都不做,但是将主动渲染目标切换到我的自定义渲染目标,然后如果我将其切换回backBuffer,我的fps接近10fps。我所做的就是:
graphicsDevice.SetRenderTarget(renderTargetA);
graphicsDevice.SetRenderTarget(null);
以这种方式创建渲染目标:
renderTargetA = new RenderTarget2D(KnightGame.CurrentGame.ScreenManager.GraphicsDevice, 800, 480,
false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8,
0, RenderTargetUsage.PreserveContents);
我尝试使用不同大小的DiscardContents,但它总是会丢弃fps。我评论了所有与切断图像部分有关的部分,并且只是通过切换渲染目标,它会对性能产生影响。任何人都可以指导我解决这个问题的原因吗?
卢卡斯