Ejemplo n.º 1
0
        /// <summary>
        /// Adds all present intervals that are compatible with the device and app to
        /// the given deviceCombo
        /// </summary>
        public void BuildPresentIntervalList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo)
        {
            PresentInterval[] piArray =
            {
                PresentInterval.Immediate,
                PresentInterval.Default,
                PresentInterval.One,
                PresentInterval.Two,
                PresentInterval.Three,
                PresentInterval.Four,
            };

            foreach (PresentInterval pi in piArray)
            {
                if (deviceCombo.IsWindowed)
                {
                    if (pi == PresentInterval.Two ||
                        pi == PresentInterval.Three ||
                        pi == PresentInterval.Four)
                    {
                        // These intervals are not supported in windowed mode.
                        continue;
                    }
                }
                // Note that PresentInterval.Default is zero, so you
                // can't do a caps check for it -- it is always available.
                if (pi == PresentInterval.Default ||
                    (deviceInfo.Caps.PresentInterval & pi) != (PresentInterval)0)
                {
                    deviceCombo.PresentIntervalList.Add(pi);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds all vertex processing types that are compatible with the device and app to
 /// the given deviceCombo
 /// </summary>
 public void BuildVertexProcessingTypeList(GraphicsDeviceInfo deviceInfo, DeviceCombo deviceCombo)
 {
     if (deviceInfo.Caps.DeviceCaps.SupportsHardwareTransformAndLight)
     {
         if (deviceInfo.Caps.DeviceCaps.SupportsPureDevice)
         {
             if (ConfirmDeviceCallback == null ||
                 ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.PureHardware, deviceCombo.BackBufferFormat))
             {
                 deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.PureHardware);
             }
         }
         if (ConfirmDeviceCallback == null ||
             ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Hardware, deviceCombo.BackBufferFormat))
         {
             deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Hardware);
         }
         if (AppUsesMixedVP && (ConfirmDeviceCallback == null ||
                                ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Mixed, deviceCombo.BackBufferFormat)))
         {
             deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Mixed);
         }
     }
     if (ConfirmDeviceCallback == null ||
         ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Software, deviceCombo.BackBufferFormat))
     {
         deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Software);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds all multisample types that are compatible with the device and app to
        /// the given deviceCombo
        /// </summary>
        public void BuildMultiSampleTypeList(DeviceCombo deviceCombo)
        {
            MultiSampleType[] msTypeArray =
            {
                MultiSampleType.None,
                MultiSampleType.NonMaskable,
                MultiSampleType.TwoSamples,
                MultiSampleType.ThreeSamples,
                MultiSampleType.FourSamples,
                MultiSampleType.FiveSamples,
                MultiSampleType.SixSamples,
                MultiSampleType.SevenSamples,
                MultiSampleType.EightSamples,
                MultiSampleType.NineSamples,
                MultiSampleType.TenSamples,
                MultiSampleType.ElevenSamples,
                MultiSampleType.TwelveSamples,
                MultiSampleType.ThirteenSamples,
                MultiSampleType.FourteenSamples,
                MultiSampleType.FifteenSamples,
                MultiSampleType.SixteenSamples,
            };
            foreach (MultiSampleType msType in msTypeArray)
            {
                if (Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType,
                                                       deviceCombo.BackBufferFormat, deviceCombo.IsWindowed, msType))
                {
                    deviceCombo.MultiSampleTypeList.Add(msType);

                    //deviceCombo.MultiSampleQualityList.Add(qualityLevels);
                }
            }
        }
Ejemplo n.º 4
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 (GraphicsUtility.GetDepthBits(depthStencilFmt) < AppMinDepthBits)
                {
                    continue;
                }
                if (GraphicsUtility.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);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Finds any depthstencil formats that are incompatible with multisample types and
        /// builds a list of them.
        /// </summary>
        public void BuildDepthStencilMultiSampleConflictList(DeviceCombo deviceCombo)
        {
            DepthStencilMultiSampleConflict DSMSConflict;

            foreach (DepthFormat dsFmt in deviceCombo.DepthStencilFormatList)
            {
                foreach (MultiSampleType msType in deviceCombo.MultiSampleTypeList)
                {
                    if (!Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal,
                                                            deviceCombo.DevType, (Format)dsFmt, deviceCombo.IsWindowed, msType))
                    {
                        DSMSConflict = new DepthStencilMultiSampleConflict();
                        DSMSConflict.DepthStencilFormat = dsFmt;
                        DSMSConflict.MultiSampleType    = msType;
                        deviceCombo.DepthStencilMultiSampleConflictList.Add(DSMSConflict);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Enumerates DeviceCombos for a particular device
        /// </summary>
        protected void EnumerateDeviceCombos(GraphicsDeviceInfo deviceInfo, ArrayList adapterFormatList)
        {
            Format[] backBufferFormatArray = new Format[]
            {
                Format.R8G8B8, Format.A8R8G8B8, Format.X8R8G8B8,
                Format.R5G6B5, Format.A1R5G5B5, Format.X1R5G5B5,
                Format.R3G3B2, Format.A8R3G3B2,
                Format.X4R4G4B4, Format.A4R4G4B4,
                Format.A2B10G10R10
            };
            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 (GraphicsUtility.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);
                    }
                }
            }
        }