通过Texture2D 执行图像处理算法的有效方法
我遇到的情况是,每次旋转纹理时,我都需要对其应用一些算法。
我的问题是 - 在 XNA 中应用图像处理算法的最佳方法是什么?
现在纹理是 RenderTarget2D,算法对其像素执行一些操作并将它们设置回 RenderTarget2D。这种方法会导致我的应用程序终止,并且性能非常糟糕。
我在 stackoverflow 上进行了搜索,但没有找到任何与该主题相关的内容。 我还阅读了这篇文章 http:// blogs.msdn.com/b/shawnhar/archive/2008/04/14/stalling-the-pipeline.aspx 并了解我的方法有多糟糕。
I have a situation where I need to apply some algorithm to my texture every time it's rotated.
My question is - what is the best approach to apply an image processing algorithms within XNA?
Now the texture is a RenderTarget2D and the algorithm performs some operation with it's pixels and sets them back to the RenderTarget2D. This approach causes termination of my app and it's performance is very bad.
I searched through the stackoverflow but have no found anything relevant to the subject.
I also read this article http://blogs.msdn.com/b/shawnhar/archive/2008/04/14/stalling-the-pipeline.aspx and understand how bad my approach is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您可能需要的操作,通过 HLSL 着色器执行这些操作将是一个非常好的主意。
着色器确实是正确的选择,因为您可以利用 GPU 的多个核心,并且不需要解析渲染目标中的数据;数据在到达屏幕的途中得到处理,而不会导致任何停顿。
Depending on the operations that you may require, then doing them through an HLSL shader would be a very good idea.
Shaders are really the right choice because you can take advantage of the multiple cores the GPU has AND you don't need to resolve the data in the rendertarget; the data gets process on its way to the screen without causing any stalling.