예제 #1
0
        private DeviceEntry[] searchForDevices()
        {
            if (mainForm.Renderer.Context == null)
            {
                return(null);                                              //bail out if the GL context hasn't been created
            }
            DeviceEntry[]      eDevs   = null;
            List <DeviceEntry> devList = new List <DeviceEntry>();

            try{
                OpenCLDeviceEntry.CheckSupport();                 //will throw an exception if not supported

                eDevs = OpenCLDeviceEntry.GetDevices();
                if (eDevs != null)
                {
                    devList.AddRange(eDevs);
                }
            }
            catch {}

            try{
                CudaDeviceEntry.CheckSupport();                 //will throw an exception if not supported

                eDevs = CudaDeviceEntry.GetDevices();
                if (eDevs != null)
                {
                    devList.AddRange(eDevs);
                }
            }
            catch {}

            try{
                CPUDeviceEntry.CheckSupport();                 //will throw an exception if not supported

                eDevs = CPUDeviceEntry.GetDevices();
                if (eDevs != null)
                {
                    devList.AddRange(eDevs);
                }
            }
            catch {}

            return(devList.ToArray());
        }
예제 #2
0
        private void hardwareInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.IO.StringWriter text = new System.IO.StringWriter();

            if (engineMgr.FoundDevices == null)
            {
                return;
            }

            try{
                CPUDeviceEntry.CheckSupport();
            }catch (Exception ex) {
                text.WriteLine("No CPU/OpenGL Support: " + ex.Message);
            }
            try{
                OpenCLDeviceEntry.CheckSupport();
            }catch (Exception ex) {
                text.WriteLine("No OpenCL Support: " + ex.Message);
            }
            try{
                CudaDeviceEntry.CheckSupport();
            }catch (Exception ex) {
                text.WriteLine("No CUDA Support: " + ex.Message);
            }
            text.WriteLine();
            foreach (DeviceEntry dev in engineMgr.FoundDevices)
            {
                text.WriteLine(dev.GetReport());
            }


            beginDlg();
            TextDisplayForm dlg = new TextDisplayForm();

            dlg.Text    = "Hardware Info";
            dlg.Content = text.ToString();
            dlg.ShowDialog();
            endDlg();
        }
예제 #3
0
        /// <summary>
        /// Select a device to use based on the current configuration. If no device can be found, this throws NoDevicesFoundException
        /// </summary>
        private DeviceEntry chooseDevice()
        {
            if (mainForm.Renderer.Context == null || FoundDevices == null)            //if there's no graphics context, bail out
            {
                return(null);
            }

            DeviceEntry chosenDev = null;

            //first try to find a device with the same type and ID as the one in the config
            foreach (DeviceEntry dev in FoundDevices)
            {
                if (dev.EngineType == mainForm.Config.EngineType && dev.ID == mainForm.Config.DeviceID)
                {
                    chosenDev = dev;
                }
            }

            //if no match was found, just pick the best device
            if (chosenDev == null)
            {
                chosenDev = GetBestDevice();
            }

            //ok, if still no device is found, then we are in trouble
            if (chosenDev == null)
            {
                Exception cpuEx = null;
                try{
                    CPUDeviceEntry.CheckSupport();
                }
                catch (Exception ex) {
                    cpuEx = ex;
                }
                throw new NoDevicesFoundException("No compatable devices were found.", cpuEx);
            }

            return(chosenDev);
        }