Ejemplo n.º 1
0
        static void EnumerateDevices(AdapterInfo9 info, List <Format> adapterFormats)
        {
            DeviceType[] deviceTypes = { DeviceType.Hardware, DeviceType.Reference };

            foreach (DeviceType deviceType in deviceTypes)
            {
                if (MinimumSettings != null && MinimumSettings.DeviceType != deviceType)
                {
                    continue;
                }

                DeviceInfo9 deviceInfo = new DeviceInfo9();
                deviceInfo.DeviceType = deviceType;
                try
                {
                    deviceInfo.Capabilities = GraphicsDeviceManager.Direct3D9Object.GetDeviceCaps(info.AdapterOrdinal, deviceInfo.DeviceType);

                    EnumerateSettingsCombos(info, deviceInfo, adapterFormats);

                    if (deviceInfo.DeviceSettings.Count > 0)
                    {
                        info.Devices.Add(deviceInfo);
                    }
                }
                catch (Direct3D9Exception)
                {
                    // #23681 2010.11.17 yyagi: GetDeviceCaps()で例外が発生するモニタに対しては、enumerateをスキップする。
                }
            }
        }
Ejemplo n.º 2
0
        static void EnumerateSettingsCombos(AdapterInfo9 adapterInfo, DeviceInfo9 deviceInfo, List<Format> adapterFormats)
        {
            Format[] backBufferFormats = { Format.A8R8G8B8, Format.X8R8G8B8, Format.A2R10G10B10,
                Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5 };

            foreach (Format adapterFormat in adapterFormats)
            {
                foreach (Format backBufferFormat in backBufferFormats)
                {
                    for (int windowed = 0; windowed < 2; windowed++)
                    {
                        if (windowed == 0 && adapterInfo.DisplayModes.Count == 0)
                            continue;

                        if (!GraphicsDeviceManager.Direct3D9Object.CheckDeviceType(adapterInfo.AdapterOrdinal, deviceInfo.DeviceType,
                            adapterFormat, backBufferFormat, (windowed == 1)))
                            continue;

                        if (!GraphicsDeviceManager.Direct3D9Object.CheckDeviceFormat(adapterInfo.AdapterOrdinal,
                            deviceInfo.DeviceType, adapterFormat, Usage.QueryPostPixelShaderBlending,
                            ResourceType.Texture, backBufferFormat))
                            continue;

                        SettingsCombo9 combo = new SettingsCombo9();
                        combo.AdapterOrdinal = adapterInfo.AdapterOrdinal;
                        combo.DeviceType = deviceInfo.DeviceType;
                        combo.AdapterFormat = adapterFormat;
                        combo.BackBufferFormat = backBufferFormat;
                        combo.Windowed = (windowed == 1);
                        combo.AdapterInfo = adapterInfo;
                        combo.DeviceInfo = deviceInfo;

                        BuildDepthStencilFormatList(combo);
                        BuildMultisampleTypeList(combo);

                        if (combo.MultisampleTypes.Count == 0)
                            continue;

                        BuildPresentIntervalList(combo);

                        if (MinimumSettings != null)
                        {
                            if (MinimumSettings.BackBufferFormat != Format.Unknown &&
                                MinimumSettings.BackBufferFormat != backBufferFormat)
                                continue;

                            if (MinimumSettings.DepthStencilFormat != Format.Unknown &&
                                !combo.DepthStencilFormats.Contains(MinimumSettings.DepthStencilFormat))
                                continue;

                            if (!combo.MultisampleTypes.Contains(MinimumSettings.MultisampleType))
                                continue;
                        }

                        deviceInfo.DeviceSettings.Add(combo);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        int GetAdapterOrdinal(IntPtr screen)
        {
            AdapterInfo9 adapter = null;

            foreach (AdapterInfo9 a in Enumeration9.Adapters)
            {
                if (Direct3D9Object.GetAdapterMonitor(a.AdapterOrdinal) == screen)
                {
                    adapter = a;
                    break;
                }
            }

            if (adapter != null)
            {
                return(adapter.AdapterOrdinal);
            }

            return(-1);
        }
Ejemplo n.º 4
0
        public static void Enumerate()
        {
            HasEnumerated = true;
            Adapters      = new List <AdapterInfo9>();
            List <Format> adapterFormats = new List <Format>();

            Format[] allowedAdapterFormats = { Format.X8R8G8B8, Format.X1R5G5B5, Format.R5G6B5,
                                               Format.A2R10G10B10 };

            foreach (AdapterInformation adapter in GraphicsDeviceManager.Direct3D9Object.Adapters)                      //
            {
                AdapterInfo9 info = new AdapterInfo9();
                info.AdapterOrdinal = adapter.Adapter;
                info.Details        = adapter.Details;

                adapterFormats.Clear();
                foreach (Format adapterFormat in allowedAdapterFormats)
                {
                    foreach (DisplayMode displayMode in adapter.GetDisplayModes(adapterFormat))
                    {
                        if (MinimumSettings != null)
                        {
                            if (displayMode.Width < MinimumSettings.BackBufferWidth ||
                                displayMode.Height < MinimumSettings.BackBufferHeight ||
                                displayMode.RefreshRate < MinimumSettings.RefreshRate)
                            {
                                continue;
                            }
                        }

                        info.DisplayModes.Add(displayMode);

                        if (!adapterFormats.Contains(displayMode.Format))
                        {
                            adapterFormats.Add(displayMode.Format);
                        }
                    }
                }

                if (!adapterFormats.Contains(adapter.CurrentDisplayMode.Format))
                {
                    adapterFormats.Add(adapter.CurrentDisplayMode.Format);
                }

                info.DisplayModes.Sort(DisplayModeComparer9.Comparer);

                EnumerateDevices(info, adapterFormats);

                if (info.Devices.Count > 0)
                {
                    Adapters.Add(info);
                }
            }

            bool unique = true;

            foreach (AdapterInfo9 adapter1 in Adapters)
            {
                foreach (AdapterInfo9 adapter2 in Adapters)
                {
                    if (adapter1 == adapter2)
                    {
                        continue;
                    }
                    if (adapter1.Details.Description == adapter2.Details.Description)
                    {
                        unique = false;
                        break;
                    }
                }

                if (!unique)
                {
                    break;
                }
            }

            foreach (AdapterInfo9 info in Adapters)
            {
                info.Description = info.Details.Description;
                if (!unique)
                {
                    info.Description += " " + info.AdapterOrdinal.ToString(CultureInfo.CurrentCulture);
                }
            }
        }