简体   繁体   English

WPF和SlimDX(DirectX 11)互操作

[英]WPF and SlimDX (DirectX 11) interop

Hello I've managed to integrate SlimDX and DirectX 11 graphics in a WPF application by using D3DImage and shared textures. 您好,我已经通过使用D3DImage和共享纹理将SlimDX和DirectX 11图形集成到WPF应用程序中。 However, but I'm getting some really poor performance when rendering simple scenes (eg GameOfLife in the SlimDX samples) at high resolution (2560x1440). 但是,但是在以高分辨率(2560x1440)渲染简单场景(例如SlimDX样本中的GameOfLife)时,我得到的性能确实很差。

I've tried doing some performance profiling of my render method and it looks like most of the time is spent on locking the D3DImage when invalidating the backbuffer. 我已经尝试对我的render方法进行一些性能分析,并且看起来大部分时间都在使backbuffer无效时花费在锁定D3DImage上。

_d3dImage.Lock(); // <- this call takes 78,5 % of the time when rendering the frame
_d3dImage.AddDirtyRect(new Int32Rect(0, 0, _d3dImage.PixelWidth, _d3dImage.PixelHeight));
_d3dImage.Unlock();

A lot of time is spent flusing the device after drawing: 绘制后将大量时间用于熔化设备:

_device.ImmediateContext.Flush(); // <- 20,6% of the time when rendering the frame

Anyone know the problem and how to optimize this? 有谁知道这个问题,以及如何优化它? Can you expect to get descent performance when integrating WPF and SlimDX? 集成WPF和SlimDX时,您能否期望获得下降性能?

Since you're seeing performance issues on locking and flushing calls (which are points where the GPU needs to sync with the CPU), I'd guess that your program is severely GPU bound, and the CPU has to keep stalling waiting for it to catch up. 由于您在锁定和刷新调用时遇到性能问题(这是GPU需要与CPU同步的点),因此我猜您的程序受到了GPU的严格限制,CPU必须一直停滞等待它跟上来。 That's also born out by the performance increase when disabling the compute shader. 禁用计算着色器时的性能提高也可以证明这一点。

I'm not sure what to tell you at that point, except that if that guess is right, it would appear that your card can't handle the load. 我不确定当时该如何告诉您,除非这个猜测正确,否则看来您的卡无法处理负载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM