/// <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.PresentationIntervals & pi) != (PresentInterval)0)
                {
                    deviceCombo.PresentIntervalList.Add(pi);
                }
            }
        }
 /// <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.AdapterFormat, deviceCombo.BackBufferFormat))
             {
                 deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.PureHardware);
             }
         }
         if (ConfirmDeviceCallback == null ||
             ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Hardware,
                                   deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))
         {
             deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Hardware);
         }
         if (AppUsesMixedVP && (ConfirmDeviceCallback == null ||
                                ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Mixed,
                                                      deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)))
         {
             deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Mixed);
         }
     }
     if (ConfirmDeviceCallback == null ||
         ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Software,
                               deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))
     {
         deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Software);
     }
 }
        /// <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);
                    }
                }
            }
        }
        /// <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);
                    }
                }
            }
        }
        /// <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)
            {
                int result;
                int qualityLevels = 0;
                if (Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType,
                                                       deviceCombo.BackBufferFormat, deviceCombo.IsWindowed, msType,
                                                       out result, out qualityLevels))
                {
                    deviceCombo.MultiSampleTypeList.Add(msType);
                    deviceCombo.MultiSampleQualityList.Add(qualityLevels);
                }
            }
        }
Example #6
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.PresentationIntervals & pi) != (PresentInterval)0)
        {
          deviceCombo.PresentIntervalList.Add(pi);
        }
      }
    }
Example #7
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.AdapterFormat, deviceCombo.BackBufferFormat))
       {
         deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.PureHardware);
       }
     }
     if (ConfirmDeviceCallback == null ||
         ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Hardware,
                               deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))
     {
       deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Hardware);
     }
     if (AppUsesMixedVP && (ConfirmDeviceCallback == null ||
                            ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Mixed,
                                                  deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat)))
     {
       deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Mixed);
     }
   }
   if (ConfirmDeviceCallback == null ||
       ConfirmDeviceCallback(deviceInfo.Caps, VertexProcessingType.Software,
                             deviceCombo.AdapterFormat, deviceCombo.BackBufferFormat))
   {
     deviceCombo.VertexProcessingTypeList.Add(VertexProcessingType.Software);
   }
 }
Example #8
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);
          }
        }
      }
    }
Example #9
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)
      {
        int result;
        int qualityLevels = 0;
        if (Manager.CheckDeviceMultiSampleType(deviceCombo.AdapterOrdinal, deviceCombo.DevType,
                                               deviceCombo.BackBufferFormat, deviceCombo.IsWindowed, msType,
                                               out result, out qualityLevels))
        {
          deviceCombo.MultiSampleTypeList.Add(msType);
          deviceCombo.MultiSampleQualityList.Add(qualityLevels);
        }
      }
    }
Example #10
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);
          }
        }
      }
    }
Example #11
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);
          }
        }
      }
    }
        /// <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);
                    }
                }
            }
        }