0031445: Advanced wrappers, C# wrapper - provide device info in About dialog of WPF...
authorkgv <kgv@opencascade.com>
Thu, 19 Mar 2020 14:14:48 +0000 (17:14 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 19 Mar 2020 16:08:10 +0000 (19:08 +0300)
D3DHost_View::DiagnosticInformation() now appends D3D device information to the map.

src/D3DHost/D3DHost_View.cxx
src/D3DHost/D3DHost_View.hxx

index fc61996..cf573e7 100644 (file)
 
 IMPLEMENT_STANDARD_RTTIEXT(D3DHost_View,OpenGl_View)
 
+namespace
+{
+  enum D3DHost_VendorId
+  {
+    D3DHost_VendorId_AMD    = 0x1002,
+    D3DHost_VendorId_NVIDIA = 0x10DE,
+    D3DHost_VendorId_Intel  = 0x8086,
+  };
+}
+
 // =======================================================================
 // function : d3dFormatError
 // purpose  :
@@ -131,6 +141,51 @@ void D3DHost_View::SetWindow (const Handle(Aspect_Window)& theWindow,
 }
 
 // =======================================================================
+// function : DiagnosticInformation
+// purpose  :
+// =======================================================================
+void D3DHost_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
+                                          Graphic3d_DiagnosticInfo theFlags) const
+{
+  base_type::DiagnosticInformation (theDict, theFlags);
+  if (myD3dDevice == NULL)
+  {
+    return;
+  }
+
+  D3DCAPS9 aDevCaps;
+  memset (&aDevCaps, 0, sizeof(aDevCaps));
+  if (myD3dDevice->GetDeviceCaps (&aDevCaps) < 0)
+  {
+    return;
+  }
+
+  const UINT anAdapter = aDevCaps.AdapterOrdinal;
+  D3DADAPTER_IDENTIFIER9 aDevId;
+  memset (&aDevId, 0, sizeof(aDevId));
+  if (myD3dLib->GetAdapterIdentifier (anAdapter, 0, &aDevId) < 0)
+  {
+    return;
+  }
+
+  TCollection_AsciiString aVendorId ((int )aDevId.VendorId);
+  switch (aDevId.VendorId)
+  {
+    case D3DHost_VendorId_AMD:    aVendorId = "AMD";    break;
+    case D3DHost_VendorId_NVIDIA: aVendorId = "NVIDIA"; break;
+    case D3DHost_VendorId_Intel:  aVendorId = "Intel";  break;
+  }
+  theDict.Add ("D3Dvendor",      aVendorId);
+  theDict.Add ("D3Ddescription", aDevId.Description);
+  theDict.Add ("D3DdeviceName",  aDevId.DeviceName);
+  theDict.Add ("D3Ddriver",      aDevId.Driver);
+  theDict.Add ("D3DdeviceId",    TCollection_AsciiString((int )aDevId.DeviceId));
+  theDict.Add ("D3Dinterop",     myD3dWglFbo.IsNull() || myD3dWglFbo->D3dFallback()
+                               ? "Software Fallback"
+                               : "WGL_NV_DX_interop");
+}
+
+// =======================================================================
 // function : d3dInitLib
 // purpose  :
 // =======================================================================
index 47b4bb1..baa5999 100644 (file)
@@ -58,6 +58,11 @@ public:
   //! Redraw only immediate layer.
   Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
 
+  //! Fill in the dictionary with diagnostic info.
+  //! Should be called within rendering thread.
+  Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
+                                                      Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
+
 public:
 
   //! @return true if IDirect3DDevice9Ex device has been created