/// <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);
     }
 }
        protected void EnumerateDevices(GraphicsAdapterInfo adapterInfo, ArrayList adapterFormatList)
        {
            DeviceType[] devTypeArray = new DeviceType[]
            { DeviceType.Hardware, DeviceType.Software, DeviceType.Reference };

            foreach (DeviceType devType in devTypeArray)
            {
                GraphicsDeviceInfo deviceInfo = new GraphicsDeviceInfo();
                deviceInfo.AdapterOrdinal = adapterInfo.AdapterOrdinal;
                deviceInfo.DevType        = devType;
                try
                {
                    deviceInfo.Caps = Manager.GetDeviceCaps(adapterInfo.AdapterOrdinal, devType);
                }
                catch (DirectXException)
                {
                    continue;
                }

                // Get info for each devicecombo on this device
                EnumerateDeviceCombos(deviceInfo, adapterFormatList);

                // If at least one devicecombo for this device is found,
                // add the deviceInfo to the list
                if (deviceInfo.DeviceComboList.Count == 0)
                {
                    continue;
                }
                adapterInfo.DeviceInfoList.Add(deviceInfo);
            }
        }
Ejemplo n.º 4
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);
        }
      }
    }
Ejemplo n.º 5
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);
   }
 }
Ejemplo n.º 6
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);
          }
        }
      }
    }
Ejemplo n.º 7
0
    protected void EnumerateDevices(GraphicsAdapterInfo adapterInfo, ArrayList adapterFormatList)
    {
      DeviceType[] devTypeArray = new DeviceType[]
                                    {DeviceType.Hardware, DeviceType.Software, DeviceType.Reference};

      foreach (DeviceType devType in devTypeArray)
      {
        GraphicsDeviceInfo deviceInfo = new GraphicsDeviceInfo();
        deviceInfo.AdapterOrdinal = adapterInfo.AdapterOrdinal;
        deviceInfo.DevType = devType;
        try
        {
          deviceInfo.Caps = Manager.GetDeviceCaps(adapterInfo.AdapterOrdinal, devType);
        }
        catch (DirectXException)
        {
          continue;
        }

        // Get info for each devicecombo on this device
        EnumerateDeviceCombos(deviceInfo, adapterFormatList);

        // If at least one devicecombo for this device is found, 
        // add the deviceInfo to the list
        if (deviceInfo.DeviceComboList.Count == 0)
        {
          continue;
        }
        adapterInfo.DeviceInfoList.Add(deviceInfo);
      }
    }
        /// <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);
                    }
                }
            }
        }