Pking
Pking

Reputation: 963

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. However, but I'm getting some really poor performance when rendering simple scenes (e.g. GameOfLife in the SlimDX samples) at high resolution (2560x1440).

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.

_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?

Upvotes: 2

Views: 1589

Answers (1)

MikeP
MikeP

Reputation: 7959

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. 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.

Upvotes: 1

Related Questions