void OnDxgkrnlAdapterStart(TraceEvent obj) { Debug.Assert(obj.EventName == "Adapter/DC_Start" && obj.PayloadNames.Length == 27); Debug.Assert(obj.PayloadNames[1] == "pDxgAdapter"); ulong pDxgAdapter = (ulong)obj.PayloadValue(1); if (adapterLookup.ContainsKey(pDxgAdapter)) { Debug.Assert(false); return; } AdapterInfo adapter = new AdapterInfo(); AllAdapters.Add(adapter); adapterLookup.Add(pDxgAdapter, adapter); adapter.pDxgiAdapter = pDxgAdapter; Debug.Assert(obj.PayloadNames[2] == "NbVidPnSources"); adapter.NumVidPnSources = (int)obj.PayloadValue(2); Debug.Assert(obj.PayloadNames[22] == "PagingNode"); adapter.PagingNode = (int)obj.PayloadValue(22); Debug.Assert(obj.PayloadNames[25] == "AdapterType"); adapter.AdapterType = (AdapterType)(int)obj.PayloadValue(25); }
/// <summary> /// CreateAdapterCapabilitiesFromGraphicsProfile creates appropriate AdapterCapabilities from the specified GraphicsProfile. /// </summary> /// <param name="graphicsProfile">GraphicsProfile</param> /// <returns>AdapterCapabilities</returns> public AdapterCapabilitiesBase CreateAdapterCapabilitiesFromGraphicsProfile(GraphicsProfile graphicsProfile) { AdapterCapabilitiesBase adapterCapabilities; if (graphicsProfile.DriverType == GraphicsProfile.DriverTypes.DirectXHardware) { Adapter1 hardwarAdapter = graphicsProfile.DefaultAdapter; if (hardwarAdapter == null) { if (AllAdapters.Length > 0) { hardwarAdapter = AllAdapters[0]; } else { throw new DXEngineException("Cannot create default adapter from GraphicsProfile " + graphicsProfile.Name ?? ""); } } else { var hardwarAdapterDescription1 = hardwarAdapter.Description1; // Check if the adapter is in the list of available adapters if (AllAdapters.FirstOrDefault(a => a.Description1.Description == hardwarAdapterDescription1.Description) == null) { if (AllAdapters.Length > 0) { hardwarAdapter = AllAdapters[0]; // Just use the first adapter } else { throw new DXEngineException("Cannot create default adapter instead of adapter specified in GraphicsProfile " + graphicsProfile.Name ?? ""); } } } adapterCapabilities = new HardwareAdapterCapabilities(hardwarAdapter); } else if (graphicsProfile.DriverType == GraphicsProfile.DriverTypes.DirectXSoftware) { adapterCapabilities = SoftwareAdapterCapabilities; } else { adapterCapabilities = WpfAdapterCapabilities; } return(adapterCapabilities); }
AdapterInfo FindOrCreateAdapter(ulong pDxgAdapter) { // Already seen this adapter? if (adapterLookup.ContainsKey(pDxgAdapter)) { return(adapterLookup[pDxgAdapter]); } else { AdapterInfo adapter = new AdapterInfo(); adapter.pDxgiAdapter = pDxgAdapter; AllAdapters.Add(adapter); adapterLookup.Add(pDxgAdapter, adapter); return(adapter); } }