migrating from dx10 to 11 gives me an undebug-able error
Now I am running into a "vshost32.exe has stopped working" and it gives me the option to debug but it then tells me " a debugger is attached to myprogram.vshost.exe but not configured to debug this unhandled exception. to debug this exception, detach the current debugger."
so i went digging, i set vs to break on all exceptions thrown, and turned on unmanaged debugging. when it hits the exception there is no available source code for me to see where any of this is happening it only gives me some point buried in the assembly, but it always seems to happen in an nvwgf2um.dll in the call stack.
> nvwgf2um.dll!09bbd565()
[Frames below may be incorrect and/or missing, no symbols loaded for nvwgf2um.dll]
nvwgf2um.dll!09b945fd()
nvwgf2um.dll!09d30f8b()
nvwgf2um.dll!09d12419()
nvwgf2um.dll!09cd82ac()
nvwgf2um.dll!09b68296()
nvwgf2um.dll!09b65b51()
nvwgf2um.dll!09c212f8()
nvwgf2um.dll!0a1de315()
nvwgf2um.dll!0a1de39f()
kernel32.dll!763a3677()
ntdll.dll!776c9f42()
ntdll.dll!776c9f15()
so i dug a little deeper and this seems to happen in bf3 quite a bit where people say that a newish release of the nvidia drivers are the culprit ad to just roll back the drivers. so i did and it did not help, so i installed the latest and again still having the same issue. so i went to laptopvideo2go and installed a modded one, still nvwgf2um.dll crashes.
anyone have any ideas? am i stuck waiting for an update from nvidia, or is it possibly something in my code i did wrong?
ok so im not sure i have really narrowed it down to this point as the try catch block does not catch the exception, but when i do not allow the texture to be written to, then it stops crashing. the map function is as follows,
[source lang="csharp"]
try
{
// if everything is in order then send data to graphics memory.
if (pTexture != null)
{
DataBox mappedTex = null;
//assign and lock the resource
mappedTex = g_pd3dDevice.ImmediateContext.MapSubresource(pTexture, 0, pTexture.Description.Height * pTexture.Description.Width*4, D3D11.MapMode.WriteDiscard, D3D11.MapFlags.None);
// if unable to hold texture
if (!mappedTex.Data.CanWrite)
{ throw new InvalidOperationException("Cannot Write to the Texture"); }
// write new data to the texture
mappedTex.Data.WriteRange<byte>(NewData);
// unlock the resource
g_pd3dDevice.ImmediateContext.UnmapSubresource(pTexture, 0);
}
}
catch (Exception P)
{
MessageBox.Show("texheight = " + pTexture.Description.Height + " \n" + "texwidth = " + pTexture.Description.Width + "\n" + "data size = " + NewData.Length);
throw;
}
[/source]
could this be some kind of threading issue with the ImmediateContext ? there was some issue with having to move from a datarectangle to a databox as well.
no i did not have the debug enabled, but now that i do, i am getting sehexceptions at random places, from the clear render target view, map, write, and unmap,
not in any specific order or consistent place, just literally at random from one of those places. though it is hitting a different exception much faster than it was before. with the debug on i get through about 50-100 frames before it throws the seh exceptions and crashes. weird that it would crash on new exceptions that didnt show up before?
D3D11: ERROR: ID3D11DeviceContext::Draw: Draw cannot be invoked while a bound Resource is currently mapped. The Resource bound at Pixel Shader Resource slot (0) is still mapped. [ EXECUTION ERROR #364: DEVICE_DRAW_BOUND_RESOURCE_MAPPED ]
D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Draw cannot be invoked while a bound Resource is currently mapped. The Resource bound at Pixel Shader Resource slot (0) is still mapped. [ EXECUTION ERROR #364: DEVICE_DRAW_BOUND_RESOURCE_MAPPED ]
D3D11: CORRUPTION: ID3D11DeviceContext::Unmap: Two threads were found to be executing functions associated with the same Device at the same time. This will cause corruption of memory. Appropriate thread synchronization needs to occur external to the Direct3D API. 2420 and 2432 are the implicated thread ids. [ MISCELLANEOUS CORRUPTION #28: CORRUPTED_MULTITHREADING ]
First-chance exception at 0x75a4c41f in WPControlPanel.exe: 0x0000087D: 0x87d.
D3D11: ERROR: ID3D11DeviceContext::Draw: Draw cannot be invoked while a bound Resource is currently mapped. The Resource bound at Pixel Shader Resource slot (0) is still mapped. [ EXECUTION ERROR #364: DEVICE_DRAW_BOUND_RESOURCE_MAPPED ]
so it is a threading issue. i have a draw function spinning on the main thread and a separate consumer thread trying to pull frames from a usb device as fast as possible which then loads it into the texture. this never was an issue with dx10, it seemed to just wait for one to let go of the resource, seems dx11 does not deal with multiple threads pulling a resource from the device context at the same time. hopefully this is the cause of both exceptions, i think i can just double buffer it into a separate texture and then copyresource on the draw call with a lock to minimize stall time.