Beispiel #1
0
        /// <summary>
        /// Adds all depth/stencil formats that are compatible with the device and app to
        /// the given deviceCombo
        /// </summary>
        public void BuildDepthStencilFormatList(DeviceCombo deviceCombo)
        {
            Format[] depthStencilFormatArray =
            {
                Format.D16,
                Format.D15S1,
                Format.D24X8,
                Format.D24S8,
                Format.D24X4S4,
                Format.D32,
            };

            foreach (Format depthStencilFmt in depthStencilFormatArray)
            {
                if (D3DUtil.GetDepthBits(depthStencilFmt) < AppMinDepthBits)
                {
                    continue;
                }
                if (D3DUtil.GetStencilBits(depthStencilFmt) < AppMinStencilBits)
                {
                    continue;
                }
                if (MPDirect3D.Direct3D.CheckDeviceFormat(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat,
                                                          Usage.DepthStencil, ResourceType.Surface, depthStencilFmt))
                {
                    if (MPDirect3D.Direct3D.CheckDepthStencilMatch(deviceCombo.AdapterOrdinal, deviceCombo.DevType,
                                                                   deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat, depthStencilFmt))
                    {
                        deviceCombo.DepthStencilFormats.Add(depthStencilFmt);
                    }
                }
            }
        }
Beispiel #2
0
        public bool AppUsesMixedVP        = false; // whether app can take advantage of mixed vp mode

        /// <summary>
        /// Enumerates available D3D adapters, devices, modes, etc.
        /// </summary>
        public void Enumerate()
        {
            foreach (AdapterInformation ai in MPDirect3D.Direct3D.Adapters)
            {
                ICollection <Format> adapterFormatList = new List <Format>();
                GraphicsAdapterInfo  adapterInfo       = new GraphicsAdapterInfo
                {
                    AdapterOrdinal = ai.Adapter,
                    AdapterDetails = ai.Details
                };

                List <DisplayMode> displayModes = new List <DisplayMode>();
                // Get list of all display modes on this adapter.
                // Also build a temporary list of all display adapter formats.
                foreach (DisplayMode displayMode in ai.GetDisplayModes(Format.X8R8G8B8))
                {
                    if (displayMode.Width < AppMinFullscreenWidth)
                    {
                        continue;
                    }
                    if (displayMode.Height < AppMinFullscreenHeight)
                    {
                        continue;
                    }
                    if (D3DUtil.GetColorChannelBits(displayMode.Format) < AppMinColorChannelBits)
                    {
                        continue;
                    }
                    displayModes.Add(displayMode);
                    if (!adapterFormatList.Contains(displayMode.Format))
                    {
                        adapterFormatList.Add(displayMode.Format);
                    }
                }

                // Sort displaymode list
                DisplayModeComparer dmc = new DisplayModeComparer();
                displayModes.Sort(dmc);
                adapterInfo.DisplayModes = displayModes;

                // Get info for each device on this adapter
                EnumerateDevices(adapterInfo, adapterFormatList);

                // If at least one device on this adapter is available and compatible
                // with the app, add the adapterInfo to the list
                if (adapterInfo.DeviceInfos.Count == 0)
                {
                    continue;
                }
                AdapterInfoList.Add(adapterInfo);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Enumerates DeviceCombos for a particular device
        /// </summary>
        protected void EnumerateDeviceCombos(GraphicsDeviceInfo deviceInfo, ICollection <Format> adapterFormatList)
        {
            Format[] backBufferFormats = new Format[]
            {
                Format.A8R8G8B8, Format.X8R8G8B8, Format.A2R10G10B10,
                Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5,
            };
            bool[] bools = new bool[] { false, true };

            // See which adapter formats are supported by this device
            foreach (Format adapterFormat in adapterFormatList)
            {
                foreach (Format backBufferFormat in backBufferFormats)
                {
                    if (D3DUtil.GetAlphaChannelBits(backBufferFormat) < AppMinAlphaChannelBits)
                    {
                        continue;
                    }
                    foreach (bool isWindowed in bools)
                    {
                        if (!MPDirect3D.Direct3D.CheckDeviceType(deviceInfo.AdapterOrdinal, deviceInfo.DevType,
                                                                 adapterFormat, backBufferFormat, isWindowed))
                        {
                            continue;
                        }

                        // At this point, we have an adapter/device/adapterformat/backbufferformat/iswindowed
                        // DeviceCombo that is supported by the system.  We still need to confirm that it's
                        // compatible with the app, and find one or more suitable depth/stencil buffer format,
                        // multisample type, vertex processing type, and present interval.
                        DeviceCombo deviceCombo = new DeviceCombo
                        {
                            AdapterOrdinal   = deviceInfo.AdapterOrdinal,
                            DevType          = deviceInfo.DevType,
                            AdapterFormat    = adapterFormat,
                            BackBufferFormat = backBufferFormat,
                            IsWindowed       = isWindowed
                        };
                        if (AppUsesDepthBuffer)
                        {
                            BuildDepthStencilFormatList(deviceCombo);
                            if (deviceCombo.DepthStencilFormats.Count == 0)
                            {
                                continue;
                            }
                        }
                        BuildMultisampleTypeList(deviceCombo);
                        if (deviceCombo.MultisampleTypes.Count == 0)
                        {
                            continue;
                        }
                        BuildDepthStencilMultiSampleConflictList(deviceCombo);
                        BuildVertexProcessingTypeList(deviceInfo, deviceCombo);
                        if (deviceCombo.VertexProcessingTypes.Count == 0)
                        {
                            continue;
                        }
                        BuildPresentIntervalList(deviceInfo, deviceCombo);
                        if (deviceCombo.PresentIntervals.Count == 0)
                        {
                            continue;
                        }

                        deviceInfo.DeviceCombos.Add(deviceCombo);
                    }
                }
            }
        }