// Testing function call - creates DX9 device & present test:
        public bool TestDX(Direct3D d3dh, ref MyAdapterInfo[] infos)
        {
#if !XB1
            bool isAnyGraphicsSupported = false;
            MyLog.Default.WriteLine("MyGraphicTest.TestDX() - START");
            MyLog.Default.IncreaseIndent();

            LogInfoFromWMI();

            bool isAnyGoodGCinWMI = IsAnyGoodGCinList(m_WMIGraphicsCards);
            MyLog.Default.WriteLine("Good graphics in WMI detected: " + isAnyGoodGCinWMI);

            //Check debug runtime
            MyLog.Default.WriteLine("Debug runtime enabled: " + IsDebugRuntimeEnabled);

            PresentParameters newPresentParameters;

            try
            {
                MyLog.Default.WriteLine("Adapter count: " + d3dh.AdapterCount);
                for (int i = 0; i < d3dh.AdapterCount; i++)
                {
                    var info = d3dh.GetAdapterIdentifier(i);
                    MyLog.Default.WriteLine(String.Format("Found adapter: {0} ({1})", info.Description, info.DeviceName));
                }
                MyLog.Default.WriteLine("Adapter count: " + d3dh.AdapterCount);

                // DX:
                newPresentParameters = new PresentParameters();
                newPresentParameters.InitDefaults();
                newPresentParameters.Windowed = true;
                newPresentParameters.AutoDepthStencilFormat = Format.D24S8;
                newPresentParameters.EnableAutoDepthStencil = true;
                newPresentParameters.SwapEffect = SwapEffect.Discard;
                newPresentParameters.PresentFlags = PresentFlags.DiscardDepthStencil;

                m_DXGraphicsCards.Clear();

                // Write adapter information to the LOG file:
                MyLog.Default.WriteLine("Adapters count: " + d3dh.AdapterCount);
                MyLog.Default.WriteLine("Adapter array count: " + d3dh.Adapters.Count);

                for (int adapter = 0; adapter < d3dh.AdapterCount; adapter++)
                {
                    bool adapterSupported = false;

                    var adapterIdentifier = d3dh.GetAdapterIdentifier(adapter);
                    MyLog.Default.WriteLine("Adapter " + adapterIdentifier.Description + ": " + adapterIdentifier.DeviceName);

                    Device d3d = null;
                    Form testForm = null;

                    try
                    {
                        //Create window, because other this fails on some ATIs..
                        testForm = new Form();
                        testForm.ClientSize = new System.Drawing.Size(64, 64);
                        testForm.StartPosition = FormStartPosition.CenterScreen;
                        testForm.FormBorderStyle = FormBorderStyle.None;
                        testForm.BackColor = System.Drawing.Color.Black;
                        testForm.Show();

                        newPresentParameters.DeviceWindowHandle = testForm.Handle;
                        d3d = new Device(d3dh, adapter, DeviceType.Hardware, testForm.Handle, CreateFlags.HardwareVertexProcessing | CreateFlags.FpuPreserve, newPresentParameters);

                        if (d3d == null)
                        {
                            throw new Exception("Cannot create Direct3D Device");
                        }
                        else
                            MyLog.Default.WriteLine("d3d handle ok ");
                    }
                    catch (Exception e)
                    {
                        if (testForm != null)
                            testForm.Close();

                        MyLog.Default.WriteLine("Direct3D Device create fail");
                        MyLog.Default.WriteLine(e.ToString());

                        Write(newPresentParameters, MyLog.Default.WriteLine);
                        continue;
                    }

                    adapterSupported |= !TestCapabilities(d3d, d3dh, adapter);

                    infos[adapter].MaxTextureSize = d3d.Capabilities.MaxTextureWidth;

                    bool Rgba1010102Supported = d3dh.CheckDeviceFormat(adapter, DeviceType.Hardware, Format.X8R8G8B8, Usage.RenderTarget, ResourceType.Surface, Format.A2R10G10B10);
                    MyLog.Default.WriteLine("Rgba1010102Supported: " + Rgba1010102Supported);

                    bool MipmapNonPow2Supported = !d3d.Capabilities.TextureCaps.HasFlag(TextureCaps.Pow2) &&
                        !d3d.Capabilities.TextureCaps.HasFlag(TextureCaps.NonPow2Conditional) &&
                        d3d.Capabilities.TextureCaps.HasFlag(TextureCaps.MipMap);
                    MyLog.Default.WriteLine("MipmapNonPow2Supported: " + MipmapNonPow2Supported);

                    infos[adapter].HDRSupported = Rgba1010102Supported && MipmapNonPow2Supported;
                    MyLog.Default.WriteLine("HDRSupported: " + infos[adapter].HDRSupported);

                    bool QueriesSupported = false;
                    try
                    {
                        MyLog.Default.WriteLine("Create query");
                        Query query = new Query(d3d, QueryType.Event);
                        MyLog.Default.WriteLine("Dispose query");
                        query.Dispose();
                        QueriesSupported = true;
                    }
                    catch
                    {
                        QueriesSupported = false;
                    }

                    //Test sufficient video memory (512MB)
                    bool Has512AvailableVRAM = TestAvailable512VRAM(d3d);

                    //We require queries
                    adapterSupported &= QueriesSupported;

                    infos[adapter].IsDx9Supported = adapterSupported;
                    infos[adapter].Has512MBRam = Has512AvailableVRAM;

                    isAnyGraphicsSupported |= adapterSupported;

                    MyLog.Default.WriteLine("Queries supported: " + QueriesSupported.ToString());

                    m_DXGraphicsCards.Add(adapterIdentifier.VendorId);

                    if (d3d != null)
                    {
                        d3d.Dispose();
                        d3d = null;
                    }

                    if (testForm != null)
                        testForm.Close();
                }
            }
            catch (Exception ex)
            {
                MyLog.Default.WriteLine("Exception throwed by DX test. Source: " + ex.Source);
                MyLog.Default.WriteLine("Message: " + ex.Message);
                MyLog.Default.WriteLine("Inner exception: " + ex.InnerException);
                MyLog.Default.WriteLine("Exception details" + ex.ToString());
            }

            bool isAnyGoodGCinDX = IsAnyGoodGCinList(m_DXGraphicsCards);
            MyLog.Default.WriteLine("Good graphics in DX detected: " + isAnyGoodGCinDX);

            IsBetterGCAvailable = isAnyGoodGCinWMI && !isAnyGoodGCinDX;
            MyLog.Default.WriteLine("Is better graphics available: " + IsBetterGCAvailable);

            MyLog.Default.DecreaseIndent();
            MyLog.Default.WriteLine("MyGraphicTest.TestDX() - END");

            return isAnyGraphicsSupported;
#else // XB1
            System.Diagnostics.Debug.Assert(false, "XB1 TOOD?");
            return false;
#endif // XB1
        }