コード例 #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)
        {
            DepthFormat[] depthStencilFormatArray =
            {
                DepthFormat.D16,
                DepthFormat.D15S1,
                DepthFormat.D24X8,
                DepthFormat.D24S8,
                DepthFormat.D24X4S4,
                DepthFormat.D32,
            };

            foreach (DepthFormat depthStencilFmt in depthStencilFormatArray)
            {
                if (D3DUtil.GetDepthBits(depthStencilFmt) < AppMinDepthBits)
                {
                    continue;
                }
                if (D3DUtil.GetStencilBits(depthStencilFmt) < AppMinStencilBits)
                {
                    continue;
                }
                if (Manager.CheckDeviceFormat(deviceCombo.AdapterOrdinal, deviceCombo.DevType, deviceCombo.AdapterFormat,
                                              Usage.DepthStencil, ResourceType.Surface, depthStencilFmt))
                {
                    if (Manager.CheckDepthStencilMatch(deviceCombo.AdapterOrdinal, deviceCombo.DevType,
                                                       deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat, depthStencilFmt))
                    {
                        deviceCombo.DepthStencilFormatList.Add(depthStencilFmt);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Enumerates available D3D adapters, devices, modes, etc.
        /// </summary>
        public void Enumerate()
        {
            foreach (AdapterInformation ai in Manager.Adapters)
            {
                ArrayList           adapterFormatList = new ArrayList();
                GraphicsAdapterInfo adapterInfo       = new GraphicsAdapterInfo();
                adapterInfo.AdapterOrdinal = ai.Adapter;
                adapterInfo.AdapterDetails = ai.Information;

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

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

                // 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.DeviceInfoList.Count == 0)
                {
                    continue;
                }
                AdapterInfoList.Add(adapterInfo);
            }
        }
コード例 #3
0
        /// <summary>
        /// Enumerates DeviceCombos for a particular device
        /// </summary>
        protected void EnumerateDeviceCombos(GraphicsDeviceInfo deviceInfo, ArrayList adapterFormatList)
        {
            Format[] backBufferFormatArray = new Format[]
            {
                Format.A8R8G8B8, Format.X8R8G8B8, Format.A2R10G10B10,
                Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5,
            };
            bool[] isWindowedArray = new bool[] { false, true };

            // See which adapter formats are supported by this device
            foreach (Format adapterFormat in adapterFormatList)
            {
                foreach (Format backBufferFormat in backBufferFormatArray)
                {
                    if (D3DUtil.GetAlphaChannelBits(backBufferFormat) < AppMinAlphaChannelBits)
                    {
                        continue;
                    }
                    foreach (bool isWindowed in isWindowedArray)
                    {
                        if (!isWindowed && AppRequiresWindowed)
                        {
                            continue;
                        }
                        if (isWindowed && AppRequiresFullscreen)
                        {
                            continue;
                        }
                        if (
                            !Manager.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();
                        deviceCombo.AdapterOrdinal   = deviceInfo.AdapterOrdinal;
                        deviceCombo.DevType          = deviceInfo.DevType;
                        deviceCombo.AdapterFormat    = adapterFormat;
                        deviceCombo.BackBufferFormat = backBufferFormat;
                        deviceCombo.IsWindowed       = isWindowed;
                        if (AppUsesDepthBuffer)
                        {
                            BuildDepthStencilFormatList(deviceCombo);
                            if (deviceCombo.DepthStencilFormatList.Count == 0)
                            {
                                continue;
                            }
                        }
                        BuildMultiSampleTypeList(deviceCombo);
                        if (deviceCombo.MultiSampleTypeList.Count == 0)
                        {
                            continue;
                        }
                        BuildDepthStencilMultiSampleConflictList(deviceCombo);
                        BuildVertexProcessingTypeList(deviceInfo, deviceCombo);
                        if (deviceCombo.VertexProcessingTypeList.Count == 0)
                        {
                            continue;
                        }
                        BuildPresentIntervalList(deviceInfo, deviceCombo);
                        if (deviceCombo.PresentIntervalList.Count == 0)
                        {
                            continue;
                        }

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