HWndHost resizing #857
Description
I'm fairly new to SharpDX. I want use one ore more HwndHost hosted windows to draw 3D content inside a Visual Studio UI like WPF application.
I modified a WinForms sample and got the render system including mouse and keyboard input working.
The only issue is that after manually resizing the main WPF window (containing my HwndHost) sometimes the area, that is newly visible after reszing, is left blank.
This happens only when doing the resize operation with the mouse very quickly. Holding the mouse a short time still after end of resizing (as one usually will do) will never cause this error.
Maximizing the window and restoring it also works well.
- Using the graphic debugging tools in VS I can see that the output is rendered in the right (new) dimensions of the window, but seems to get clipped somewhere.
- My debug output shows me that the reszing of the swapchain buffers is done using the correct dimensions.
- Using Spy I could verify, that the hosted window has the correct size after the resize operation.
I'm in doubt that my threading model is correct. I use a worker thread just for the rendering. Rendering and resizing of the swapchain and related buffers is mutally excluded using a lock.
During resizing (WM_ENTERSIZEMOVE to WM_EXITSIZEMOVE) the rendering is deactivated. In recation to WM_EXITSIZEMOVE the swapchain is resized and the rendering is activated.
AFAIK only one thread at a time should access the D3DContext and related DXGI objects (which will be ensured by the lock). But I'm unsure if the rendering has to be done only in main UI thread, that runs the windows message pump (which is not the case in my solution).
The problem at all looks like a synchronization issue.
It would be great if someone could give my a hint to solve this issue and applying a correct threading model or provide me a link to a working similar solution.
SharpDX 3.1.1
.Net 4.6.1