我在C#,VS.net 2015 Update 3中使用针对DirectX11的SharpDX 3.1包装器(截至此日期的最新NuGet)有一个解决方案。该解决方案工作正常,但我想使用内置的VS.net Graphics Profiler来检查性能。
我使用VS.net“Debug-> Graphics-> Start Graphics Debugging”启动解决方案,并成功捕获诊断会话中显示的屏幕截图。单击“查看框架”链接可在我的临时文件夹中创建.vsglog和子文件夹,并使用该.vsglog文件加载Visual Studio图形分析器(“VSGA”)。
问题是VSGA总是显示错误“图形诊断引擎遇到致命错误。请尝试重新打开文档...”,这是在Windows事件查看器中记录的(因此可能代表真正的崩溃)
我试过了
我只能通过Google找到对此特定错误消息的一个引用,并建议强制该应用程序使用我已完成的DirectX 11功能级别11。
我正在使用安装了可选图形工具功能的Windows 10。
有关信息,我的设备创建代码是;
private static void initializeDirect3DGraphicsDevice(System.Windows.Forms.Control winFormsControl, out Device device, out SharpDX.DXGI.SwapChain sc)
{
// SwapChain description
SharpDX.DXGI.SwapChainDescription destination = new SharpDX.DXGI.SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new SharpDX.DXGI.ModeDescription(
winFormsControl.ClientSize.Width,
winFormsControl.ClientSize.Height,
new SharpDX.DXGI.Rational(60, 1),
SharpDX.DXGI.Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = winFormsControl.Handle,
SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
SwapEffect = SharpDX.DXGI.SwapEffect.Discard,
Usage = SharpDX.DXGI.Usage.RenderTargetOutput
};
// https://connect.microsoft.com/VisualStudio/feedback/details/3102011/the-graphics-debugger-fails-to-load-on-gtx-1080
// To enable graphics debugging we avoid featre levels above 11.
SharpDX.Direct3D.FeatureLevel[] featureLevels = new SharpDX.Direct3D.FeatureLevel[]
{
SharpDX.Direct3D.FeatureLevel.Level_11_0
};
device = new Device(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.Debug, featureLevels);
using (SharpDX.DXGI.Factory1 factory = new SharpDX.DXGI.Factory1())
{
sc = new SharpDX.DXGI.SwapChain(factory, device, destination);
factory.MakeWindowAssociation(winFormsControl.Handle, SharpDX.DXGI.WindowAssociationFlags.IgnoreAll);
}
System.Diagnostics.Debug.WriteLine("Device created with feature level " + device.FeatureLevel);
}