Esempio n. 1
0
        /// <summary>
        /// Gets the highest supported hardware feature level of the primary adapter.
        /// </summary>
        /// <param name="adapter">The <see cref="IDXGIAdapter"/>.</param>
        /// <returns>The highest supported hardware feature level.</returns>
        public static FeatureLevel GetSupportedFeatureLevel(IDXGIAdapter adapter)
        {
            var                 featureLevel = FeatureLevel.Level_9_1;
            ID3D11Device        device       = null;
            ID3D11DeviceContext context      = null;

            try
            {
                D3D11CreateDevice(
                    adapter,
                    DriverType.Unknown,
                    IntPtr.Zero,
                    0,
                    null, 0,
                    SdkVersion,
                    out device, out featureLevel, out context);
            }
            finally
            {
                context?.Dispose();
                device?.Dispose();
            }

            return(featureLevel);
        }
Esempio n. 2
0
 private void ReleaseDevice()
 {
     if (Device__ != null)
     {
         // Only call Dispose() when it is created by accessing ID3D11DeviceChild.Device.
         if (!shouldNotDisposeDevice)
         {
             Device__.Dispose();
             Device__ = null;
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Check if a feature level is supported by a particular adapter.
        /// </summary>
        /// <param name="adapter">The adapter.</param>
        /// <param name="featureLevel">The feature level.</param>
        /// <returns><c>true</c> if the specified adapter is supporting this feature level; otherwise, <c>false</c>.</returns>
        public static bool IsSupportedFeatureLevel(IDXGIAdapter adapter, FeatureLevel featureLevel)
        {
            ID3D11Device        device  = null;
            ID3D11DeviceContext context = null;

            try
            {
                var result = D3D11CreateDevice(
                    adapter,
                    DriverType.Unknown,
                    IntPtr.Zero,
                    0,
                    new[] { featureLevel }, 1,
                    SdkVersion,
                    out device, out var outputLevel, out context);
                return(result.Success && outputLevel == featureLevel);
            }
            finally
            {
                context?.Dispose();
                device?.Dispose();
            }
        }