WPF应用程序和DirectX光栅化器中的访问冲突异常

时间:2014-07-21 14:47:20

标签: c# .net wpf directx

我有一个WPF应用程序,经过一些微不足道的游戏(打开和关闭一些应用程序控件)后崩溃了。当我打开崩溃转储文件时,我看到异常是

FAULTING_IP: 
rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+b4
000007fe`f7625b88 428b0c10        mov     ecx,dword ptr [rax+r10]

EXCEPTION_RECORD:  ffffffffffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 000007fef7625b88 (rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+0x00000000000000b4)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 000000009f011620
Attempt to read from address 000000009f011620

表示directx光栅化中的访问冲突错误,并且错误的线程堆栈跟踪是(我省略了调用地址)

rgb9rast!D3D8RGBRast::CRGBContext::PackGenVertex+0xb4
rgb9rast!D3D8RGBRast::CRGBContext::DoDrawOneGenIndexedPrimitive+0x72b
rgb9rast!D3D8RGBRast::CRGBContext::DP2DrawIndexedPrimitive2+0x1d4
rgb9rast!DX8SDDIFW::SDP2MFnParser::ParseDP2<DX8SDDIFW::CStdDrawPrimitives2<D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBStateSet,D3D8RGBRast::static_hash_map<unsigned long,D3D8RGBRast::CRGBStateSet,32,D3D8RGBRast::hash<unsigned long>,std::equal_to<unsigned long>,D3D8RGBRast::allocator<std::pair<unsigned long const ,D3D8RGBRast::CRGBStateSet> > >,DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(_D3DHAL_DP2COMMAND const * __ptr64,void * __ptr64) __ptr64,89> >::TMFnCaller,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,DX8SDDIFW::CConstDP2CmdIterator<D3D8RGBRast::SDP2NextCmdExt> >+0x69
rgb9rast!DX8SDDIFW::CStdDrawPrimitives2<D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBStateSet,D3D8RGBRast::static_hash_map<unsigned long,D3D8RGBRast::CRGBStateSet,32,D3D8RGBRast::hash<unsigned long>,std::equal_to<unsigned long>,D3D8RGBRast::allocator<std::pair<unsigned long const ,D3D8RGBRast::CRGBStateSet> > >,DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(DX8SDDIFW::CDP2DataWrap<D3D8RGBRast::SDP2NextCmdExt> & __ptr64,_D3DHAL_DP2COMMAND const * __ptr64,void const * __ptr64) __ptr64,89>,D3D8RGBRast::block<long (__cdecl D3D8RGBRast::CRGBContext::*)(_D3DHAL_DP2COMMAND const * __ptr64,void * __ptr64) __ptr64,89> >::DrawPrimitives2+0x345
rgb9rast!DX8SDDIFW::CSubDriver<D3D8RGBRast::CRGBDriver,D3D8RGBRast::CRGBContext,D3D8RGBRast::CRGBSurfAllocator,D3D8RGBRast::CRGBPerDDrawData,D3D8RGBRast::set<D3D8RGBRast::CRGBContext * __ptr64,std::less<D3D8RGBRast::CRGBContext * __ptr64>,D3D8RGBRast::allocator<D3D8RGBRast::CRGBContext * __ptr64> >,D3D8RGBRast::map<_DDRAWI_DIRECTDRAW_LCL * __ptr64,D3D8RGBRast::CRGBPerDDrawData,std::less<_DDRAWI_DIRECTDRAW_LCL * __ptr64>,D3D8RGBRast::allocator<std::pair<_DDRAWI_DIRECTDRAW_LCL * __ptr64 const,D3D8RGBRast::CRGBPerDDrawData> > >,D3D8RGBRast::set<D3D8RGBRast::IRGBSurface * __ptr64,std::less<D3D8RGBRast::IRGBSurface * __ptr64>,D3D8RGBRast::allocator<D3D8RGBRast::IRGBSurface * __ptr64> >,DX8SDDIFW::SFakeEntryPointHook<D3D8RGBRast::CRGBDriver> >::DrawPrimitives2+0x26
d3d9!SwDrawPrimitives2+0x7c
d3d9!CD3DDDIDX8::FlushStates+0x161
d3d9!CD3DBase::FlushStatesNoThrow+0x22
d3d9!CVertexBuffer::Lock+0xce
d3d9!CVertexBufferMT::Lock+0x7e
d3d9!CTLStream::Lock+0x6d
d3d9!CD3DDDIDX8::StartPrimTL+0x3b
d3d9!CD3DDDIDX8::ProcessIndexedPrimitiveC+0xa0
d3d9!CD3DBase::DrawIndexedPrimitive+0x489
wpfgfx_v0400!CD3DDeviceLevel1::DrawIndexedTriangleList+0x49
wpfgfx_v0400!CHw3DGeometryRenderer<unsigned long>::Render+0x152
wpfgfx_v0400!CHwShader::FixedFunctionDrawMesh3D+0x158
wpfgfx_v0400!CHwShader::DrawMesh3D+0x88
wpfgfx_v0400!CHwSurfaceRenderTarget::DrawMesh3D+0x1fb
wpfgfx_v0400!CHw3DSoftwareSurface::DrawMesh3D+0x38
wpfgfx_v0400!CSwRenderTargetSurface::DrawMesh3D+0x49
wpfgfx_v0400!CMetaRenderTarget::DrawMesh3D+0xee
wpfgfx_v0400!CModelRenderWalker::RealizeMaterialAndRender+0x17a
wpfgfx_v0400!CModelRenderWalker::ProcessMaterialAndRender+0x160
wpfgfx_v0400!CModelRenderWalker::RenderGeometryModel3D+0x11b
wpfgfx_v0400!CModelRenderWalker::PreSubgraph+0x19
wpfgfx_v0400!CModelIterator::Walk+0x64
wpfgfx_v0400!CModelRenderWalker::RenderModels+0x70
wpfgfx_v0400!CRender3DContext::PreSubgraph+0xd3
wpfgfx_v0400!CGraphIterator::Walk+0x4b
wpfgfx_v0400!CRender3DContext::Render+0xd9
wpfgfx_v0400!CDrawingContext::Render3D+0x277
wpfgfx_v0400!CMilViewport3DVisual::RenderContent+0x50
wpfgfx_v0400!CDrawingContext::PreSubgraph+0x766
wpfgfx_v0400!CGraphIterator::Walk+0x4b
wpfgfx_v0400!CDrawingContext::DrawVisualTree+0x23d
wpfgfx_v0400!CDrawingContext::Render+0x393
wpfgfx_v0400!CSlaveHWndRenderTarget::Render+0x206
wpfgfx_v0400!CRenderTargetManager::Render+0x4d
wpfgfx_v0400!CComposition::Render+0x28
wpfgfx_v0400!CComposition::ProcessComposition+0x13a
wpfgfx_v0400!CComposition::Compose+0x51
wpfgfx_v0400!CPartitionThread::RenderPartition+0x28
wpfgfx_v0400!CPartitionThread::Run+0x61
wpfgfx_v0400!CPartitionThread::ThreadMain+0x1c
kernel32!BaseThreadInitThunk+0xd
ntdll!RtlUserThreadStart+0x1d

仅在我检查应用程序的某些PC上发生这种情况。都有.Net 4.5和Directx 11.
原因可能是什么?在调试/调查转储文件时,我看不到任何可以导致这种情况的托管代码。我唯一的提示是我在应用程序中有一些3D内容,这可能与某些内容有关错误线程堆栈跟踪中的3D渲染方法。

1 个答案:

答案 0 :(得分:2)

DirectX栅格化(如果我没有记错的话,请输入9或更高),确定如何绘制三角形。给定三角形的三个点-您可以顺时针或逆时针绘制它们,还可以确定三角形的表面是面向内还是面向外-提供相交点。

它还提供了设置Multisample和AntialiasedLine的功能-这些功能(高级处理)可以渲染更平滑的线条。请记住,在2D屏幕中并不真正存在直线-您可能熟悉计算机图形学或Jaggies中的阶梯效果。

现在,当我们使用DirectX时,实际上是在对计算机图形卡的GPU进行编程。因此,图形卡必须准备好DirectX-取决于版本。

检查计算机的硬件,并确定onbard或PCI图形卡是否符合DirectX11。

您还可以调整WPF应用的呈现设置-如果需要,可以对其进行调整,或者在here处将其全部关闭

更多信息:

从MSDN documentation

注意 ProcessRenderMode 指定首选项,不一定更改实际的渲染模式。系统的其他部分可能会覆盖此首选项,并迫使系统进行软件渲染。

您可以在Window搜索框(我认为是Window 7及更高版本)中使用dxdiag来检查系统DirectX信息。