예제 #1
0
 /// <summary>
 /// Adds all depth/stencil formats that are compatible with the device
 /// and application to the given device combo
 /// </summary>
 private static void BuildDepthStencilFormatList(EnumDeviceSettingsCombo deviceCombo)
 {
     foreach (DepthFormat depthStencil in depthStencilPossibleList)
     {
         if (Manager.CheckDeviceFormat((int)deviceCombo.AdapterOrdinal,
                                       deviceCombo.DeviceType, deviceCombo.AdapterFormat,
                                       Usage.DepthStencil, ResourceType.Surface, depthStencil))
         {
             // This can be used as a depth stencil, make sure it matches
             if (Manager.CheckDepthStencilMatch((int)deviceCombo.AdapterOrdinal,
                                                deviceCombo.DeviceType, deviceCombo.AdapterFormat,
                                                deviceCombo.BackBufferFormat, depthStencil))
             {
                 // Yup, add it
                 deviceCombo.depthStencilFormatList.Add(depthStencil);
             }
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Find any conflicts between the available depth/stencil formats and
 /// multisample types.
 /// </summary>
 private static void BuildConflictList(EnumDeviceSettingsCombo deviceCombo)
 {
     foreach (DepthFormat depthFormat in deviceCombo.depthStencilFormatList)
     {
         foreach (MultiSampleType msType in deviceCombo.multiSampleTypeList)
         {
             // Check this for conflict
             if (!Manager.CheckDeviceMultiSampleType((int)deviceCombo.AdapterOrdinal,
                                                     deviceCombo.DeviceType, (Format)depthFormat,
                                                     deviceCombo.IsWindowed, msType))
             {
                 // Add it to the list
                 EnumDepthStencilMultisampleConflict conflict = new EnumDepthStencilMultisampleConflict();
                 conflict.DepthStencilFormat = depthFormat;
                 conflict.MultisampleType    = msType;
                 deviceCombo.depthStencilConflictList.Add(conflict);
             }
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Adds all multisample types that are compatible with the device and app to
        /// the given device combo
        /// </summary>
        private static void BuildMultiSampleTypeList(EnumDeviceSettingsCombo deviceCombo)
        {
            foreach (MultiSampleType msType in multiSampleTypeList)
            {
                int result, quality;
                // Check this
                if (Manager.CheckDeviceMultiSampleType((int)deviceCombo.AdapterOrdinal,
                                                       deviceCombo.DeviceType, deviceCombo.BackBufferFormat,
                                                       deviceCombo.IsWindowed, msType, out result, out quality))
                {
                    deviceCombo.multiSampleTypeList.Add(msType);
                    if (quality > multisampleQualityMax + 1)
                    {
                        quality = (int)(multisampleQualityMax + 1);
                    }

                    deviceCombo.multiSampleQualityList.Add(quality);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Adds all present intervals that are compatible with the device and app
        /// to the given device combo
        /// </summary>
        private static void BuildPresentIntervalList(EnumDeviceInformation deviceInfo, EnumDeviceSettingsCombo deviceCombo)
        {
            for (int i = 0; i < presentIntervalList.Count; i++)
            {
                PresentInterval pi = (PresentInterval)presentIntervalList[i];
                if (deviceCombo.IsWindowed)
                {
                    if ((pi == PresentInterval.Two) ||
                        (pi == PresentInterval.Three) ||
                        (pi == PresentInterval.Four))
                    {
                        // These intervals are never supported in windowed mode
                        continue;
                    }
                }

                // Not that PresentInterval.Default is zero so you can't do a bitwise
                // check for it, it's always available
                if ((pi == PresentInterval.Default) ||
                    ((deviceInfo.Caps.PresentationIntervals & pi) != 0))
                {
                    deviceCombo.presentIntervalList.Add(pi);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Enumerates device combinations for a particular device.
        /// </summary>
        private static void EnumerateDeviceCombos(EnumAdapterInformation adapterInfo, EnumDeviceInformation deviceInfo,
                                                  ArrayList adapterFormatList)
        {
            // Find out which adapter formats are supported by this device
            foreach (Format adapterFormat in adapterFormatList)
            {
                for (int i = 0; i < backbufferFormatsArray.Length; i++)
                {
                    // Go through each windowed mode
                    for (int windowedIndex = 0; windowedIndex < 2; windowedIndex++)
                    {
                        bool isWindowedIndex = (windowedIndex == 1);
                        if ((!isWindowedIndex) && (adapterInfo.displayModeList.Count == 0))
                        {
                            continue; // Nothing here
                        }
                        if (!Manager.CheckDeviceType((int)adapterInfo.AdapterOrdinal, deviceInfo.DeviceType,
                                                     adapterFormat, backbufferFormatsArray[i], isWindowedIndex))
                        {
                            continue; // Unsupported
                        }
                        // Do we require post pixel shader blending?
                        if (isPostPixelShaderBlendingRequired)
                        {
                            // If the backbuffer format doesn't support Usage.QueryPostPixelShaderBlending
                            // then alpha test, pixel fog, render-target blending, color write enable, and dithering
                            // are not supported.
                            if (!Manager.CheckDeviceFormat((int)adapterInfo.AdapterOrdinal, deviceInfo.DeviceType,
                                                           adapterFormat, Usage.QueryPostPixelShaderBlending,
                                                           ResourceType.Textures, backbufferFormatsArray[i]))
                            {
                                continue; // Unsupported
                            }
                        }

                        // If an application callback function has been provided, make sure this device
                        // is acceptable to the app.
                        if (deviceCreationInterface != null)
                        {
                            if (!deviceCreationInterface.IsDeviceAcceptable(deviceInfo.Caps,
                                                                            adapterFormat, backbufferFormatsArray[i], isWindowedIndex))
                            {
                                continue; // Application doesn't like this device
                            }
                        }

                        // At this point, we have an adapter/device/adapterformat/backbufferformat/iswindowed
                        // DeviceCombo that is supported by the system and acceptable to the app. We still
                        // need to find one or more suitable depth/stencil buffer format,
                        // multisample type, and present interval.

                        EnumDeviceSettingsCombo deviceCombo = new EnumDeviceSettingsCombo();

                        // Store the information
                        deviceCombo.AdapterOrdinal   = adapterInfo.AdapterOrdinal;
                        deviceCombo.DeviceType       = deviceInfo.DeviceType;
                        deviceCombo.AdapterFormat    = adapterFormat;
                        deviceCombo.BackBufferFormat = backbufferFormatsArray[i];
                        deviceCombo.IsWindowed       = isWindowedIndex;

                        // Build the depth stencil format and multisample type list
                        BuildDepthStencilFormatList(deviceCombo);
                        BuildMultiSampleTypeList(deviceCombo);
                        if (deviceCombo.multiSampleTypeList.Count == 0)
                        {
                            // Nothing to do
                            continue;
                        }
                        // Build the conflict and present lists
                        BuildConflictList(deviceCombo);
                        BuildPresentIntervalList(deviceInfo, deviceCombo);

                        deviceCombo.adapterInformation = adapterInfo;
                        deviceCombo.deviceInformation  = deviceInfo;

                        // Add the combo to the list of devices
                        deviceInfo.deviceSettingsList.Add(deviceCombo);
                    }
                }
            }
        }