(XNA) 切换渲染目标会导致性能下降
我有以下问题。我尝试使用 Stencil、AlphaTestEffect 和 RenderTarget 剪切部分纹理,但这对我造成了巨大的性能影响。如果没有它,我的帧率接近 30 fps,而有了它,它会下降到 4 fps。
我试图隔离问题的根源,在处理它时,我注意到即使我什么都不做,但将活动渲染目标切换到我的自定义渲染目标,然后如果我将其切换回 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。我评论了与切断图像部分有关的所有部分,并且仍然只是切换渲染目标,这对性能造成了影响。有人可以指导我找出这个问题的原因吗?
卢卡斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论