Quote:DieterVW: Can you check the error message in the exception that is thrown when using the debug device? From the sounds of it, something in the D3D11 pipeline is set incorrectly, (possibly NULL, or maybe a random value). The debug device will throw an exception when it hits an egregious error, often an unexpected NULL. The exception should containly information about the error. Alternatively, you could use the ID3D11Debug or ID3D11InfoQueue to get the messages about the error that way. Without the debug device, D3D will just ignore the draw call since it detected an error when validating the pipeline.
DieterVW,
The problem I am having is that after using GDI (specifically after calling GetDC and Release DC on the DXGISurface1 associated with the D3D11 backbuffer) during a particular frame, no further rendering is possible as exceptions are raised by the rendering call. Previously I stated that the D2D1 compositing failed after a GDI call, but further investigation revealed that all rendering fails after the call to GetDC.
If ID3D11Debug.ValidateContext is called immediately prior to rendering, then that throws the same exception (see below) as Direct3DDeviceContext.DrawIndexed raises.
The exception reports "Access violation at address 642017B5 in module 'D3D11SDKLayers'dll". Read of address 0000004C.". There is no output to "Output" when the exception occurs. With the D3D11 call that throws the exception in a try...finally, D3D11InfoQueue.GetNumStoredMessages reports no messages.
The DirectX SDK is Aug 2009.
I am currently investigating why the problem does not occur in the next frame if the GetDC call is the last D3D operation in the frame rendering (as opposed to being followed by other rendering). I've tried clearing ("ClearState") and resetting the device context state after the call to GetDC but that didn't help.
There is always a chance that the problem is due to an error on my part. However it is odd (and troubling) that D3D is not diagnosing/reporting any errors.
Help would be appreciated. Strictly speaking this is no longer a D2D1 interop issue, as D2D1 is not involved in this problem, but I've raised it here because it follows on from your diagnosis advice.
JB.
Edit: Calling "Direct3DDeviceContext.OMSetRenderTargets(1,&RenderTargetView,RenderTargetDepthStencilView)" after the GetDC/ReleaseDC and before any subsequent rendering solves the problem (i.e. no exception and rendering works). GetDC is causing the render target to be set to NULL (confirmed with Direct3DDeviceContext.OMGetRenderTargets).
GetDC is giving rise to debug info message: STATE_SETTINGINFO #49: OMSETRENDERTARGETS_UNBINDDELETINGOBJECT "OMSetRenderTargets: Forcing OM Render Target slot 0 to NULL, since the resource is marked D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX, but has not been acquired via IDXGIKeyedMutex::AcquireSync".
I have removed all D2D1 and I am not using the D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX flag explicitly. The only flag set for the back buffer is DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE.
There is something very unpleasant going on in D3D, because if after calling GetDC/ReleaseDC I call Direct3DDeviceContext.OMGetRenderTargets and use the returned values (i.e. a NULL render target and a valid depth buffer) in a call to Direct3DDeviceContext.OMSetRenderTargets (on simply just set the render target to NULL), the exception does not occur (though of course render does not occur either).
JB.
[Edited by - JB2009 on September 30, 2009 11:58:00 AM]