DeviceInfo FindOrCreateDevice(ulong hDevice) { // Already seen this device? if (deviceLookup.ContainsKey(hDevice)) { return deviceLookup[hDevice]; } else { DeviceInfo device = new DeviceInfo(); device.hDevice = hDevice; AllDevices.Add(device); deviceLookup.Add(hDevice, device); return device; } }
void OnDxgkrnlDeviceStart(TraceEvent obj) { Debug.Assert(obj.EventName == "Device/DC_Start" && obj.PayloadNames.Length == 6); Debug.Assert(obj.PayloadNames[0] == "hProcessId"); int processId = (int)(UInt64)obj.PayloadValue(0); Debug.Assert(obj.PayloadNames[1] == "pDxgAdapter"); ulong pDxgAdapter = (ulong)obj.PayloadValue(1); Debug.Assert(obj.PayloadNames[3] == "hDevice"); ulong hDevice = (ulong)obj.PayloadValue(3); // Make sure the device doesn't already exist (error if it does) if (deviceLookup.ContainsKey(hDevice)) { Debug.Assert(false); return; } DeviceInfo device = new DeviceInfo(); AllDevices.Add(device); deviceLookup.Add(hDevice, device); device.hDevice = hDevice; device.Adapter = FindOrCreateAdapter(pDxgAdapter); device.Process = FindOrCreateProcess(processId); }