Example #1
0
        /// <summary>
        /// <p> Creates a device that uses Direct3D 11 functionality in Direct3D 12, specifying a pre-existing D3D12 device to use for D3D11 interop. </p>
        /// </summary>
        /// <param name="deviceRef"><dd>  <p> Specifies a pre-existing D3D12 device to use for D3D11 interop. May not be <c>null</c>. </p> </dd></param>
        /// <param name="flags"><dd>  <p> Any of those documented for <strong>D3D11CreateDeviceAndSwapChain</strong>. Specifies which runtime layers to enable (see the <strong><see cref="SharpDX.Direct3D11.DeviceCreationFlags"/></strong> enumeration); values can be bitwise OR'd together. <em>Flags</em> must be compatible with device flags, and its <em>NodeMask</em> must be a subset of the <em>NodeMask</em> provided to the present API. </p> </dd></param>
        /// <param name="featureLevelsRef"><dd>  <p> An array of any of the following: </p> <ul> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_12_1"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_12_0"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_1"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_0"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_10_1"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_10_0"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_9_3"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_9_2"/></li> <li><see cref="SharpDX.Direct3D.FeatureLevel.Level_9_1"/></li> </ul> <p> The first feature level which is less than or equal to the D3D12 device's feature level will be used to perform D3D11 validation. Creation will fail if no acceptable feature levels are provided. Providing <c>null</c> will default to the D3D12 device's feature level. </p> </dd></param>
        /// <param name="featureLevels"><dd>  <p> The size of the feature levels array, in bytes. </p> </dd></param>
        /// <param name="commandQueuesOut"><dd>  <p> An array of unique queues for D3D11On12 to use. Valid queue types: 3D command queue. </p> </dd></param>
        /// <param name="numQueues"><dd>  <p> The size of the command queue array, in bytes. </p> </dd></param>
        /// <param name="nodeMask"><dd>  <p> Which node of the D3D12 device to use. Only 1 bit may be set. </p> </dd></param>
        /// <param name="deviceOut"><dd>  <p> Pointer to the returned <strong><see cref="SharpDX.Direct3D11.Device"/></strong>. May be <c>null</c>. </p> </dd></param>
        /// <param name="immediateContextOut"><dd>  <p> A reference to the returned <strong><see cref="SharpDX.Direct3D11.DeviceContext"/></strong>. May be <c>null</c>. </p> </dd></param>
        /// <param name="chosenFeatureLevelRef"><dd>  <p> A reference to the returned feature level. May be <c>null</c>. </p> </dd></param>
        /// <returns><p> This method returns one of the Direct3D 12 Return Codes that are documented for <strong><see cref="SharpDX.Direct3D11.D3D11.CreateDevice"/></strong>. See Direct3D 12 Return Codes. </p><p> This method returns <strong><see cref="SharpDX.DXGI.ResultCode.SdkComponentMissing"/></strong> if you specify <strong><see cref="SharpDX.Direct3D11.DeviceCreationFlags.Debug"/></strong> in <em>Flags</em> and the incorrect version of the debug layer is installed on your computer. Install the latest Windows SDK to get the correct version. </p></returns>
        /// <remarks>
        /// <p> The function signature PFN_D3D11ON12_CREATE_DEVICE is provided as a typedef, so that you can use dynamic linking techniques (GetProcAddress) instead of statically linking. </p>
        /// </remarks>
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='D3D11On12CreateDevice']/*"/>
        /// <msdn-id>dn933209</msdn-id>
        /// <unmanaged>HRESULT D3D11On12CreateDevice([In] IUnknown* pDevice,[In] D3D11_CREATE_DEVICE_FLAG Flags,[In, Buffer, Optional] const D3D_FEATURE_LEVEL* pFeatureLevels,[In] unsigned int FeatureLevels,[In, Buffer, Optional] const IUnknown** ppCommandQueues,[In] unsigned int NumQueues,[In] unsigned int NodeMask,[Out] ID3D11Device** ppDevice,[Out, Optional] ID3D11DeviceContext** ppImmediateContext,[Out, Optional] D3D_FEATURE_LEVEL* pChosenFeatureLevel)</unmanaged>
        /// <unmanaged-short>D3D11On12CreateDevice</unmanaged-short>
        public static void On12CreateDevice(SharpDX.ComObject deviceRef, SharpDX.Direct3D11.DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevelsRef, int featureLevels, SharpDX.ComObject[] commandQueuesOut, int numQueues, int nodeMask, out SharpDX.Direct3D11.Device deviceOut, out SharpDX.Direct3D11.DeviceContext immediateContextOut, out SharpDX.Direct3D.FeatureLevel chosenFeatureLevelRef)
        {
            unsafe {
                SharpDX.Direct3D.FeatureLevel[] featureLevelsRef__ = featureLevelsRef;
                IntPtr *commandQueuesOut_ = (IntPtr *)0;
                if (commandQueuesOut != null)
                {
                    IntPtr *commandQueuesOut__ = stackalloc IntPtr[commandQueuesOut.Length];
                    commandQueuesOut_ = commandQueuesOut__;
                    for (int i = 0; i < commandQueuesOut.Length; i++)
                    {
                        commandQueuesOut_[i] = (commandQueuesOut[i] == null)? IntPtr.Zero : commandQueuesOut[i].NativePointer;
                    }
                }
                IntPtr         deviceOut_           = IntPtr.Zero;
                IntPtr         immediateContextOut_ = IntPtr.Zero;
                SharpDX.Result __result__;

                fixed(void *featureLevelsRef_ = featureLevelsRef__)
                fixed(void *chosenFeatureLevelRef_ = &chosenFeatureLevelRef)
                __result__ =
                    D3D11On12CreateDevice_((void *)((deviceRef == null)?IntPtr.Zero:deviceRef.NativePointer), unchecked ((int)flags), featureLevelsRef_, featureLevels, commandQueuesOut_, numQueues, nodeMask, &deviceOut_, &immediateContextOut_, chosenFeatureLevelRef_);

                deviceOut           = (deviceOut_ == IntPtr.Zero)?null:new SharpDX.Direct3D11.Device(deviceOut_);
                immediateContextOut = (immediateContextOut_ == IntPtr.Zero)?null:new SharpDX.Direct3D11.DeviceContext(immediateContextOut_);
                __result__.CheckError();
            }
        }
Example #2
0
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Map GraphicsProfile to D3D11 FeatureLevel
            SharpDX.Direct3D.FeatureLevel[] levels = graphicsProfiles.ToFeatureLevel();
            creationFlags = (SharpDX.Direct3D11.DeviceCreationFlags)deviceCreationFlags;

            // Create Device D3D11 with feature Level based on profile
            nativeDevice        = new SharpDX.Direct3D11.Device(Adapter.NativeAdapter, creationFlags, levels);
            nativeDeviceContext = nativeDevice.ImmediateContext;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(this, nativeDeviceContext, "ImmediateContext");
            }

            InitializeStages();

            // Create the input layout manager
            if (InputLayoutManager == null)
            {
                InputLayoutManager = new InputLayoutManager(this).DisposeBy(this);
            }
        }
Example #3
0
        [Conditional("DEBUG")]          // DEBUG 時のみ実行する。
        private void _ApplyDebugFlags(ref SharpDX.Direct3D11.DeviceCreationFlags dx11flag, ref SharpDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw)
        {
            Debug.Print("デバイスはデバッグモードで作成されました。");

            //dx11flag = dx11flag | DeviceCreationFlags.Debug;
            dx10flag_for2DDraw = dx10flag_for2DDraw | SharpDX.Direct3D10.DeviceCreationFlags.BgraSupport;
        }
Example #4
0
 private static D3DRenderContext CreateDefaultD3dRenderContext(Window window)
 {
     SharpDX.Direct3D11.DeviceCreationFlags flags = SharpDX.Direct3D11.DeviceCreationFlags.None;
     if (s_allowDebugContexts)
     {
         flags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
     }
     return(new D3DRenderContext(window, flags));
 }
        public static D3DRenderContext CreateDefaultD3DRenderContext(ref RenderContextCreateInfo contextCI, Sdl2Window window)
        {
            SharpDX.Direct3D11.DeviceCreationFlags flags = SharpDX.Direct3D11.DeviceCreationFlags.None;
            if (contextCI.DebugContext)
            {
                flags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
            }

            return(new D3DRenderContext(window, flags));
        }
Example #6
0
        public static GraphicsDevice CreateDefaultD3D11GraphicsDevice(ref GraphicsDeviceCreateInfo deviceCI, Sdl2Window window)
        {
            SharpDX.Direct3D11.DeviceCreationFlags flags = SharpDX.Direct3D11.DeviceCreationFlags.None;
            if (deviceCI.DebugDevice)
            {
                flags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
            }

            return(Hacks.CreateD3D11(window.Handle, window.Width, window.Height));
        }
Example #7
0
        private static D3DRenderContext CreateDefaultD3dRenderContext(Window window)
        {
            SharpDX.Direct3D11.DeviceCreationFlags flags = SharpDX.Direct3D11.DeviceCreationFlags.None;
#if DEBUG
            if (Preferences.Instance.AllowDirect3DDebugDevice)
            {
                flags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
            }
#endif
            return(new D3DRenderContext(window, flags));
        }
Example #8
0
        /// <summary>
        ///     初期化する。
        /// </summary>
        /// <param name="control">
        ///		デバイスコンテキストを適用するコントロール。
        ///	</param>
        public void Load(bool 機能レベル11が必須 = false, SharpDX.Direct3D11.DeviceCreationFlags dx11flag = SharpDX.Direct3D11.DeviceCreationFlags.None, SharpDX.Direct3D10.DeviceCreationFlags dx10flag_for2DDraw = SharpDX.Direct3D10.DeviceCreationFlags.BgraSupport)
        {
            this._ApplyDebugFlags(ref dx11flag, ref dx10flag_for2DDraw);

            this.DXGIFactory = new SharpDX.DXGI.Factory2();

            this.Adapter = DXGIFactory.GetAdapter1(0);

            #region " D3D11 デバイスを作成する。(機能レベルは 11.0 または 10.1) "
            //----------------
            try
            {
                // 機能レベル 11.x の D3D11 デバイスを作成する。
                D3DDevice = new SharpDX.Direct3D11.Device(
                    Adapter,
                    dx11flag,
                    new[] {
                    SharpDX.Direct3D.FeatureLevel.Level_11_0
                });
            }
            catch (SharpDX.SharpDXException)
            {
                if (機能レベル11が必須)
                {
                    throw new NotSupportedException("DX11がサポートされていません。DX10.1で初期化するにはLoadの第一引数をfalseにして下さい。");
                }

                try
                {
                    // 機能レベル 10.x の D3D11 デバイスを作成する。
                    D3DDevice = new SharpDX.Direct3D11.Device(
                        Adapter,
                        dx11flag,
                        new[] {
                        SharpDX.Direct3D.FeatureLevel.Level_10_0
                    });
                }
                catch (SharpDX.SharpDXException)
                {
                    throw new NotSupportedException("DX11,DX10.1での初期化を試みましたが、両方ともサポートされていません。");
                }
            }
            //----------------
            #endregion

            this.DeviceFeatureLevel = D3DDevice.FeatureLevel;

            this.D3DDeviceContext = D3DDevice.ImmediateContext;             // 注: COM参照カウンタが増える。

            エフェクト.初期化する(this);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="cFlags"></param>
 /// <param name="minLevel"></param>
 /// <returns></returns>
 public static SharpDX.Direct3D11.Device Create11(
     SharpDX.Direct3D11.DeviceCreationFlags cFlags = SharpDX.Direct3D11.DeviceCreationFlags.None,
     SharpDX.Direct3D.FeatureLevel minLevel        = SharpDX.Direct3D.FeatureLevel.Level_9_1)
 {
     using (var dg = new DisposeGroup())
     {
         var ada = GetBestAdapter(dg);
         if (ada == null)
         {
             return(null);
         }
         var level = SharpDX.Direct3D11.Device.GetSupportedFeatureLevel(ada);
         if (level < minLevel)
         {
             return(null);
         }
         return(new SharpDX.Direct3D11.Device(ada, cFlags, level));
     }
 }
Example #10
0
        /// <summary>
        /// <p> Creates a device that uses Direct3D 11 functionality in Direct3D 12, specifying a pre-existing D3D12 device to use for D3D11 interop. </p>
        /// </summary>
        /// <param name = "deviceRef"><dd>  <p> Specifies a pre-existing D3D12 device to use for D3D11 interop. May not be <c>null</c>. </p> </dd></param>
        /// <param name = "flags"><dd>  <p> One or more bitwise OR'ed flags from <strong><see cref = "SharpDX.Direct3D11.DeviceCreationFlags"/></strong>. These are the same flags as those used by <strong>D3D11CreateDeviceAndSwapChain</strong>. Specifies which runtime layers to enable. <em>Flags</em> must be compatible with device flags, and its <em>NodeMask</em> must be a subset of the <em>NodeMask</em> provided to the present API. </p> </dd></param>
        /// <param name = "featureLevelsRef"><dd>  <p> An array of any of the following: </p> <ul> <li>D3D_FEATURE_LEVEL_12_1</li> <li>D3D_FEATURE_LEVEL_12_0</li> <li>D3D_FEATURE_LEVEL_11_1</li> <li>D3D_FEATURE_LEVEL_11_0</li> <li>D3D_FEATURE_LEVEL_10_1</li> <li>D3D_FEATURE_LEVEL_10_0</li> <li>D3D_FEATURE_LEVEL_9_3</li> <li>D3D_FEATURE_LEVEL_9_2</li> <li>D3D_FEATURE_LEVEL_9_1</li> </ul> <p> The first feature level which is less than or equal to the D3D12 device's feature level will be used to perform D3D11 validation. Creation will fail if no acceptable feature levels are provided. Providing <c>null</c> will default to the D3D12 device's feature level. </p> </dd></param>
        /// <param name = "featureLevels"><dd>  <p> The size of the feature levels array, in bytes. </p> </dd></param>
        /// <param name = "commandQueuesOut"><dd>  <p> An array of unique queues for D3D11On12 to use. Valid queue types: 3D command queue. </p> </dd></param>
        /// <param name = "numQueues"><dd>  <p> The size of the command queue array, in bytes. </p> </dd></param>
        /// <param name = "nodeMask"><dd>  <p> Which node of the D3D12 device to use. Only 1 bit may be set. </p> </dd></param>
        /// <param name = "deviceOut"><dd>  <p> Pointer to the returned <strong><see cref = "SharpDX.Direct3D11.Device"/></strong>. May be <c>null</c>. </p> </dd></param>
        /// <param name = "immediateContextOut"><dd>  <p> A reference to the returned <strong><see cref = "SharpDX.Direct3D11.DeviceContext"/></strong>. May be <c>null</c>. </p> </dd></param>
        /// <param name = "chosenFeatureLevelRef"><dd>  <p> A reference to the returned feature level. May be <c>null</c>. </p> </dd></param>
        /// <returns><p> This method returns one of the Direct3D 12 Return Codes that are documented for <strong>D3D11CreateDevice</strong>. See Direct3D 12 Return Codes. </p><p> This method returns <strong><see cref = "SdkComponentMissing"/></strong> if you specify <strong>D3D11_CREATE_DEVICE_DEBUG</strong> in <em>Flags</em> and the incorrect version of the debug layer is installed on your computer. Install the latest Windows SDK to get the correct version. </p></returns>
        /// <remarks>
        /// <p> The function signature PFN_D3D11ON12_CREATE_DEVICE is provided as a typedef, so that you can use dynamic linking techniques (GetProcAddress) instead of statically linking. </p>
        /// </remarks>
        /// <doc-id>dn933209</doc-id>
        /// <unmanaged>HRESULT D3D11On12CreateDevice([In] IUnknown* pDevice,[In] unsigned int Flags,[In, Buffer, Optional] const D3D_FEATURE_LEVEL* pFeatureLevels,[In] unsigned int FeatureLevels,[In, Buffer, Optional] const IUnknown** ppCommandQueues,[In] unsigned int NumQueues,[In] unsigned int NodeMask,[Out] ID3D11Device** ppDevice,[Out, Optional] ID3D11DeviceContext** ppImmediateContext,[Out, Optional] D3D_FEATURE_LEVEL* pChosenFeatureLevel)</unmanaged>
        /// <unmanaged-short>D3D11On12CreateDevice</unmanaged-short>
        public static unsafe void On12CreateDevice(SharpDX.IUnknown deviceRef, SharpDX.Direct3D11.DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevelsRef, System.Int32 featureLevels, SharpDX.IUnknown[] commandQueuesOut, System.Int32 numQueues, System.Int32 nodeMask, out SharpDX.Direct3D11.Device deviceOut, out SharpDX.Direct3D11.DeviceContext immediateContextOut, out SharpDX.Direct3D.FeatureLevel chosenFeatureLevelRef)
        {
            System.IntPtr  deviceRef_ = System.IntPtr.Zero;
            System.IntPtr *commandQueuesOut_;
            commandQueuesOut_ = (System.IntPtr *) 0;
            if (commandQueuesOut != null)
            {
                System.IntPtr *_commandQueuesOut = stackalloc System.IntPtr[commandQueuesOut.Length];
                commandQueuesOut_ = _commandQueuesOut;
            }

            System.IntPtr  deviceOut_           = System.IntPtr.Zero;
            System.IntPtr  immediateContextOut_ = System.IntPtr.Zero;
            SharpDX.Result __result__;
            deviceRef_ = SharpDX.CppObject.ToCallbackPtr <SharpDX.IUnknown>(deviceRef);
            if (commandQueuesOut != null)
            {
                for (int i = 0; i < commandQueuesOut.Length; ++i)
                {
                    (commandQueuesOut_)[i] = SharpDX.CppObject.ToCallbackPtr <SharpDX.IUnknown>(commandQueuesOut[i]);
                }
                fixed(void *chosenFeatureLevelRef_ = &chosenFeatureLevelRef)
                fixed(void *featureLevelsRef_ = featureLevelsRef)
                __result__ = D3D11On12CreateDevice_((void *)deviceRef_, unchecked ((System.Int32)flags), featureLevelsRef_, featureLevels, (void *)commandQueuesOut_, numQueues, nodeMask, &deviceOut_, &immediateContextOut_, chosenFeatureLevelRef_);

                if (deviceOut_ != System.IntPtr.Zero)
                {
                    deviceOut = new SharpDX.Direct3D11.Device(deviceOut_);
                }
                else
                {
                    deviceOut = null;
                }
                if (immediateContextOut_ != System.IntPtr.Zero)
                    immediateContextOut = new SharpDX.Direct3D11.DeviceContext(immediateContextOut_); }
                else
                {
                    immediateContextOut = null;
                }
                __result__.CheckError();
        }
Example #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class using the default GraphicsAdapter
        /// and the Level10 <see cref="GraphicsProfile" />.
        /// </summary>
        /// <param name="device">The device.</param>
        private GraphicsDevice(GraphicsDevice device)
        {
            RootDevice           = device;
            Adapter              = device.Adapter;
            creationFlags        = device.creationFlags;
            Features             = device.Features;
            sharedDataPerDevice  = device.sharedDataPerDevice;
            InputLayoutManager   = device.InputLayoutManager;
            nativeDevice         = device.NativeDevice;
            nativeDeviceContext  = new SharpDX.Direct3D11.DeviceContext(NativeDevice).DisposeBy(this);
            nativeDeviceProfiler = SharpDX.ComObject.QueryInterfaceOrNull <SharpDX.Direct3D11.UserDefinedAnnotation>(nativeDeviceContext.NativePointer);
            isDeferred           = true;
            IsDebugMode          = device.IsDebugMode;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(device, nativeDeviceContext, "DeferredContext");
            }
            NeedWorkAroundForUpdateSubResource = !Features.HasDriverCommandLists;

            primitiveQuad = new PrimitiveQuad(this).DisposeBy(this);

            InitializeStages();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class using the default GraphicsAdapter
        /// and the Level10 <see cref="GraphicsProfile" />.
        /// </summary>
        /// <param name="device">The device.</param>
        private GraphicsDevice(GraphicsDevice device)
        {
            RootDevice = device;
            Adapter = device.Adapter;
            creationFlags = device.creationFlags;
            Features = device.Features;
            sharedDataPerDevice = device.sharedDataPerDevice;
            InputLayoutManager = device.InputLayoutManager;
            nativeDevice = device.NativeDevice;
            nativeDeviceContext = new SharpDX.Direct3D11.DeviceContext(NativeDevice).DisposeBy(this);
            nativeDeviceProfiler = SharpDX.ComObject.QueryInterfaceOrNull<SharpDX.Direct3D11.UserDefinedAnnotation>(nativeDeviceContext.NativePointer);
            isDeferred = true;
            IsDebugMode = device.IsDebugMode;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(device, nativeDeviceContext, "DeferredContext");
            }
            NeedWorkAroundForUpdateSubResource = !Features.HasDriverCommandLists;

            primitiveQuad = new PrimitiveQuad(this).DisposeBy(this);

            InitializeStages();
        }
Example #13
0
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            rendererName = Adapter.NativeAdapter.Description.Description;

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Map GraphicsProfile to D3D11 FeatureLevel
            creationFlags = (SharpDX.Direct3D11.DeviceCreationFlags)deviceCreationFlags;

            // Default fallback
            if (graphicsProfiles.Length == 0)
            {
                graphicsProfiles = new[] { GraphicsProfile.Level_11_0, GraphicsProfile.Level_10_1, GraphicsProfile.Level_10_0, GraphicsProfile.Level_9_3, GraphicsProfile.Level_9_2, GraphicsProfile.Level_9_1 }
            }
            ;

            // Create Device D3D11 with feature Level based on profile
            for (int index = 0; index < graphicsProfiles.Length; index++)
            {
                var graphicsProfile = graphicsProfiles[index];
                try
                {
                    // D3D12 supports only feature level 11+
                    var level = graphicsProfile.ToFeatureLevel();

                    // INTEL workaround: it seems Intel driver doesn't support properly feature level 9.x. Fallback to 10.
                    if (Adapter.VendorId == 0x8086)
                    {
                        if (level < SharpDX.Direct3D.FeatureLevel.Level_10_0)
                        {
                            level = SharpDX.Direct3D.FeatureLevel.Level_10_0;
                        }
                    }

                    nativeDevice = new SharpDX.Direct3D11.Device(Adapter.NativeAdapter, creationFlags, level);

                    // INTEL workaround: force ShaderProfile to be 10+ as well
                    if (Adapter.VendorId == 0x8086)
                    {
                        if (graphicsProfile < GraphicsProfile.Level_10_0 && (!ShaderProfile.HasValue || ShaderProfile.Value < GraphicsProfile.Level_10_0))
                        {
                            ShaderProfile = GraphicsProfile.Level_10_0;
                        }
                    }

                    RequestedProfile = graphicsProfile;
                    break;
                }
                catch (Exception)
                {
                    if (index == graphicsProfiles.Length - 1)
                    {
                        throw;
                    }
                }
            }

            nativeDeviceContext = nativeDevice.ImmediateContext;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(this, nativeDeviceContext, "ImmediateContext");
            }
        }
Example #14
0
        /// <summary>
        /// <p>Creates a device that represents the display adapter.</p>
        /// </summary>
        /// <param name = "adapterRef"><dd>  <p> A reference to the video adapter to use when creating a device. Pass <strong><c>null</c></strong> to use the default adapter, which is the first adapter that is enumerated by <strong>IDXGIFactory1::EnumAdapters</strong>. </p> <strong>Note</strong>?? Do not mix the use of DXGI 1.0 (<strong><see cref = "SharpDX.DXGI.Factory"/></strong>) and DXGI 1.1 (<strong><see cref = "SharpDX.DXGI.Factory1"/></strong>) in an application. Use <strong><see cref = "SharpDX.DXGI.Factory"/></strong> or <strong><see cref = "SharpDX.DXGI.Factory1"/></strong>, but not both in an application.  ? </dd></param>
        /// <param name = "driverType"><dd>  <p> The <strong><see cref = "SharpDX.Direct3D.DriverType"/></strong>, which represents the driver type to create. </p> </dd></param>
        /// <param name = "software"><dd>  <p> A handle to a DLL that implements a software rasterizer. If <em>DriverType</em> is <em>D3D_DRIVER_TYPE_SOFTWARE</em>, <em>Software</em> must not be <strong><c>null</c></strong>. Get the handle by calling LoadLibrary, LoadLibraryEx , or GetModuleHandle. </p> </dd></param>
        /// <param name = "flags"><dd>  <p> The runtime layers to enable (see <strong><see cref = "SharpDX.Direct3D11.DeviceCreationFlags"/></strong>); values can be bitwise OR'd together. </p> </dd></param>
        /// <param name = "featureLevelsRef"><dd>  <p> A reference to an array of <strong><see cref = "SharpDX.Direct3D.FeatureLevel"/></strong>s, which determine the order of feature levels to attempt to create. If <em>pFeatureLevels</em> is set to <strong><c>null</c></strong>, this function uses the following array of feature levels: </p>  <pre>{ D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3, D3D_FEATURE_LEVEL_9_2, D3D_FEATURE_LEVEL_9_1,};</pre>  <strong>Note</strong>?? If the Direct3D 11.1 runtime is present on the computer and <em>pFeatureLevels</em> is set to <strong><c>null</c></strong>, this function won't create a <strong>D3D_FEATURE_LEVEL_11_1</strong> device. To create a <strong>D3D_FEATURE_LEVEL_11_1</strong> device, you must explicitly provide a <strong><see cref = "SharpDX.Direct3D.FeatureLevel"/></strong> array that includes <strong>D3D_FEATURE_LEVEL_11_1</strong>. If you provide a <strong><see cref = "SharpDX.Direct3D.FeatureLevel"/></strong> array that contains <strong>D3D_FEATURE_LEVEL_11_1</strong> on a computer that doesn't have the Direct3D 11.1 runtime installed, this function immediately fails with E_INVALIDARG.  ? </dd></param>
        /// <param name = "featureLevels"><dd>  <p> The number of elements in <em>pFeatureLevels</em>. </p> </dd></param>
        /// <param name = "sDKVersion"><dd>  <p> The SDK version; use <em><see cref = "SdkVersion"/></em>. </p> </dd></param>
        /// <param name = "deviceOut"><dd>  <p> Returns the address of a reference to an <strong><see cref = "SharpDX.Direct3D11.Device"/></strong> object that represents the device created. If this parameter is <strong><c>null</c></strong>, no <see cref = "SharpDX.Direct3D11.Device"/> will be returned. </p> </dd></param>
        /// <param name = "featureLevelRef"><dd>  <p> If successful, returns the first <strong><see cref = "SharpDX.Direct3D.FeatureLevel"/></strong> from the <em>pFeatureLevels</em> array which succeeded. Supply <strong><c>null</c></strong> as an input if you don't need to determine which feature level is supported. </p> </dd></param>
        /// <param name = "immediateContextOut"><dd>  <p> Returns the address of a reference to an <strong><see cref = "SharpDX.Direct3D11.DeviceContext"/></strong> object that represents the device context. If this parameter is <strong><c>null</c></strong>, no <see cref = "SharpDX.Direct3D11.DeviceContext"/> will be returned. </p> </dd></param>
        /// <returns><p> This method can return one of the Direct3D 11 Return Codes. </p><p> This method returns E_INVALIDARG if you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value and the <em>DriverType</em> parameter to the D3D_DRIVER_TYPE_HARDWARE value. </p><p> This method returns <strong><see cref = "SdkComponentMissing"/></strong> if you specify <strong>D3D11_CREATE_DEVICE_DEBUG</strong> in <em>Flags</em> and the incorrect version of the debug layer is installed on your computer. Install the latest Windows SDK to get the correct version. </p></returns>
        /// <remarks>
        /// <p> This entry-point is supported by the Direct3D 11 runtime, which is available on Windows 7, Windows Server 2008 R2, and as an update to Windows Vista (KB971644). </p><p> To create a Direct3D 11.1 device (<strong><see cref = "SharpDX.Direct3D11.Device1"/></strong>), which is available on Windows?8, Windows Server?2012, and Windows?7 and Windows Server?2008?R2 with the Platform Update for Windows 7 installed, you first create a <strong><see cref = "SharpDX.Direct3D11.Device"/></strong> with this function, and then call the <strong>QueryInterface</strong> method on the <strong><see cref = "SharpDX.Direct3D11.Device"/></strong> object to obtain the <strong><see cref = "SharpDX.Direct3D11.Device1"/></strong> interface. </p><p> To create a Direct3D 11.2 device (<strong><see cref = "SharpDX.Direct3D11.Device2"/></strong>), which is available on Windows?8.1 and Windows Server?2012?R2, you first create a <strong><see cref = "SharpDX.Direct3D11.Device"/></strong> with this function, and then call the <strong>QueryInterface</strong> method on the <strong><see cref = "SharpDX.Direct3D11.Device"/></strong> object to obtain the <strong><see cref = "SharpDX.Direct3D11.Device2"/></strong> interface. </p><p> Set <em>ppDevice</em> and <em>ppImmediateContext</em> to <strong><c>null</c></strong> to determine which feature level is supported by looking at <em>pFeatureLevel</em> without creating a device. </p><p> For an example, see How To: Create a Device and Immediate Context; to create a device and a swap chain at the same time, use <strong>D3D11CreateDeviceAndSwapChain</strong>. </p><p> If you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value, you must also set the <em>DriverType</em> parameter to the D3D_DRIVER_TYPE_UNKNOWN value. If you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value and the <em>DriverType</em> parameter to the D3D_DRIVER_TYPE_HARDWARE value, <strong>D3D11CreateDevice</strong> returns an <strong><see cref = "SharpDX.Result"/></strong> of E_INVALIDARG. </p><table> <tr><td> <p>Differences between Direct3D 10 and Direct3D 11:</p> <p> In Direct3D 10, the presence of <em>pAdapter</em> dictated which adapter to use and the <em>DriverType</em> could mismatch what the adapter was. </p> <p> In Direct3D 11, if you are trying to create a hardware or a software device, set <em>pAdapter</em> != <strong><c>null</c></strong> which constrains the other inputs to be: </p> <ul> <li><em>DriverType</em> must be D3D_DRIVER_TYPE_UNKNOWN </li> <li><em>Software</em> must be <strong><c>null</c></strong>. </li> </ul> <p> On the other hand, if <em>pAdapter</em> == <strong><c>null</c></strong>, the <em>DriverType</em> cannot be set to D3D_DRIVER_TYPE_UNKNOWN; it can be set to either: </p> <ul> <li> If <em>DriverType</em> == D3D_DRIVER_TYPE_SOFTWARE,  <em>Software</em> cannot be <strong><c>null</c></strong>. </li> <li> If <em>DriverType</em> == D3D_DRIVER_TYPE_HARDWARE, the adapter used will be the default adapter, which is the first adapter that is enumerated by <strong>IDXGIFactory1::EnumAdapters</strong> </li> </ul> </td></tr> </table><p>?</p><p> The function signature PFN_D3D11_CREATE_DEVICE is provided as a typedef, so that you can use dynamic linking techniques (GetProcAddress) instead of statically linking. </p><p><strong>Windows?Phone?8: </strong> This API is supported. </p><p><strong>Windows Phone 8.1: </strong> This API is supported. </p>
        /// </remarks>
        /// <doc-id>ff476082</doc-id>
        /// <unmanaged>HRESULT D3D11CreateDevice([In, Optional] IDXGIAdapter* pAdapter,[In] D3D_DRIVER_TYPE DriverType,[In] HINSTANCE Software,[In] unsigned int Flags,[In, Buffer, Optional] const D3D_FEATURE_LEVEL* pFeatureLevels,[In] unsigned int FeatureLevels,[In] unsigned int SDKVersion,[Out, Fast] ID3D11Device** ppDevice,[Out, Optional] D3D_FEATURE_LEVEL* pFeatureLevel,[Out, Optional] ID3D11DeviceContext** ppImmediateContext)</unmanaged>
        /// <unmanaged-short>D3D11CreateDevice</unmanaged-short>
        public static unsafe SharpDX.Result CreateDevice(SharpDX.DXGI.Adapter adapterRef, SharpDX.Direct3D.DriverType driverType, System.IntPtr software, SharpDX.Direct3D11.DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevelsRef, System.Int32 featureLevels, System.Int32 sDKVersion, SharpDX.Direct3D11.Device deviceOut, out SharpDX.Direct3D.FeatureLevel featureLevelRef, out SharpDX.Direct3D11.DeviceContext immediateContextOut)
        {
            System.IntPtr  adapterRef_          = System.IntPtr.Zero;
            System.IntPtr  deviceOut_           = System.IntPtr.Zero;
            System.IntPtr  immediateContextOut_ = System.IntPtr.Zero;
            SharpDX.Result __result__;
            adapterRef_ = SharpDX.CppObject.ToCallbackPtr <SharpDX.DXGI.Adapter>(adapterRef);

            fixed(void *featureLevelRef_ = &featureLevelRef)
            fixed(void *featureLevelsRef_ = featureLevelsRef)
            __result__ = D3D11CreateDevice_((void *)adapterRef_, unchecked ((System.Int32)driverType), (void *)software, unchecked ((System.Int32)flags), featureLevelsRef_, featureLevels, sDKVersion, &deviceOut_, featureLevelRef_, &immediateContextOut_);

            (deviceOut).NativePointer = deviceOut_;
            if (immediateContextOut_ != System.IntPtr.Zero)
            {
                immediateContextOut = new SharpDX.Direct3D11.DeviceContext(immediateContextOut_);
            }
            else
            {
                immediateContextOut = null;
            }
            return(__result__);
        }
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Map GraphicsProfile to D3D11 FeatureLevel
            SharpDX.Direct3D.FeatureLevel[] levels = graphicsProfiles.ToFeatureLevel();
            creationFlags = (SharpDX.Direct3D11.DeviceCreationFlags)deviceCreationFlags;

            // Create Device D3D11 with feature Level based on profile
            nativeDevice = new SharpDX.Direct3D11.Device(Adapter.NativeAdapter, creationFlags, levels);
            nativeDeviceContext = nativeDevice.ImmediateContext;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(this, nativeDeviceContext, "ImmediateContext");
            }

            InitializeStages();

            // Create the input layout manager
            if (InputLayoutManager == null)
                InputLayoutManager = new InputLayoutManager(this).DisposeBy(this);
        }
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            rendererName = Adapter.NativeAdapter.Description.Description;

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Map GraphicsProfile to D3D11 FeatureLevel
            creationFlags = (SharpDX.Direct3D11.DeviceCreationFlags)deviceCreationFlags;

            // Default fallback
            if (graphicsProfiles.Length == 0)
                graphicsProfiles = new[] { GraphicsProfile.Level_11_0, GraphicsProfile.Level_10_1, GraphicsProfile.Level_10_0, GraphicsProfile.Level_9_3, GraphicsProfile.Level_9_2, GraphicsProfile.Level_9_1 };

            // Create Device D3D11 with feature Level based on profile
            for (int index = 0; index < graphicsProfiles.Length; index++)
            {
                var graphicsProfile = graphicsProfiles[index];
                try
                {
                    // D3D12 supports only feature level 11+
                    var level = graphicsProfile.ToFeatureLevel();

                    // INTEL workaround: it seems Intel driver doesn't support properly feature level 9.x. Fallback to 10.
                    if (Adapter.VendorId == 0x8086)
                    {
                        if (level < SharpDX.Direct3D.FeatureLevel.Level_10_0)
                            level = SharpDX.Direct3D.FeatureLevel.Level_10_0;
                    }

                    nativeDevice = new SharpDX.Direct3D11.Device(Adapter.NativeAdapter, creationFlags, level);

                    // INTEL workaround: force ShaderProfile to be 10+ as well
                    if (Adapter.VendorId == 0x8086)
                    {
                        if (graphicsProfile < GraphicsProfile.Level_10_0 && (!ShaderProfile.HasValue || ShaderProfile.Value < GraphicsProfile.Level_10_0))
                            ShaderProfile = GraphicsProfile.Level_10_0;
                    }

                    RequestedProfile = graphicsProfile;
                    break;
                }
                catch (Exception)
                {
                    if (index == graphicsProfiles.Length - 1)
                        throw;
                }
            }

            nativeDeviceContext = nativeDevice.ImmediateContext;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(this, nativeDeviceContext, "ImmediateContext");
            }
        }
Example #17
0
        /// <summary>
        /// <p>Creates a device that represents the display adapter.</p>
        /// </summary>
        /// <param name="adapterRef"><dd>  <p>A reference to the video adapter to use when creating a device. Pass <strong><c>null</c></strong> to use the default adapter, which is the first adapter that is enumerated by <strong>IDXGIFactory1::EnumAdapters</strong>. </p> <p><strong>Note</strong>??Do not mix the use of DXGI 1.0 (<strong><see cref="SharpDX.DXGI.Factory"/></strong>) and DXGI 1.1 (<strong><see cref="SharpDX.DXGI.Factory1"/></strong>) in an application. Use <strong><see cref="SharpDX.DXGI.Factory"/></strong> or <strong><see cref="SharpDX.DXGI.Factory1"/></strong>, but not both in an application.</p> </dd></param>
        /// <param name="driverType"><dd>  <p>The <strong><see cref="SharpDX.Direct3D.DriverType"/></strong>, which represents the driver type to create.</p> </dd></param>
        /// <param name="software"><dd>  <p>A handle to a DLL that implements a software rasterizer.  If <em>DriverType</em> is <em><see cref="SharpDX.Direct3D.DriverType.Software"/></em>,  <em>Software</em> must not be <strong><c>null</c></strong>. Get the handle by  calling LoadLibrary,  LoadLibraryEx ,  or GetModuleHandle.</p> </dd></param>
        /// <param name="flags"><dd>  <p>The runtime layers to enable (see <strong><see cref="SharpDX.Direct3D11.DeviceCreationFlags"/></strong>);  values can be bitwise OR'd together.</p> </dd></param>
        /// <param name="featureLevelsRef"><dd>  <p>A reference to an array of <strong><see cref="SharpDX.Direct3D.FeatureLevel"/></strong>s, which determine the order of feature levels to attempt to create.  If <em>pFeatureLevels</em> is set to <strong><c>null</c></strong>,  this function uses the following array of feature levels:</p>  <pre> { <see cref="SharpDX.Direct3D.FeatureLevel.Level_11_0"/>, <see cref="SharpDX.Direct3D.FeatureLevel.Level_10_1"/>, <see cref="SharpDX.Direct3D.FeatureLevel.Level_10_0"/>, <see cref="SharpDX.Direct3D.FeatureLevel.Level_9_3"/>, <see cref="SharpDX.Direct3D.FeatureLevel.Level_9_2"/>, <see cref="SharpDX.Direct3D.FeatureLevel.Level_9_1"/>,}; </pre>  <p><strong>Note</strong>??If the Direct3D 11.1 runtime is present on the computer and <em>pFeatureLevels</em> is set to <strong><c>null</c></strong>, this function won't create a <strong><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_1"/></strong> device. To create a <strong><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_1"/></strong> device, you must explicitly provide a <strong><see cref="SharpDX.Direct3D.FeatureLevel"/></strong> array that includes <strong><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_1"/></strong>. If you provide a <strong><see cref="SharpDX.Direct3D.FeatureLevel"/></strong> array that contains <strong><see cref="SharpDX.Direct3D.FeatureLevel.Level_11_1"/></strong> on a computer that doesn't have the Direct3D 11.1 runtime installed, this function immediately fails with E_INVALIDARG.</p> </dd></param>
        /// <param name="featureLevels"><dd>  <p>The number of elements in <em>pFeatureLevels</em>.</p> </dd></param>
        /// <param name="sDKVersion"><dd>  <p>The SDK version; use <em><see cref="SharpDX.Direct3D11.D3D11.SdkVersion"/></em>.</p> </dd></param>
        /// <param name="deviceOut"><dd>  <p>Returns the address of a reference to an <strong><see cref="SharpDX.Direct3D11.Device"/></strong> object that represents the device created.</p> </dd></param>
        /// <param name="featureLevelRef"><dd>  <p>If successful, returns the first <strong><see cref="SharpDX.Direct3D.FeatureLevel"/></strong> from the <em>pFeatureLevels</em> array which succeeded. Otherwise, returns 0.</p> </dd></param>
        /// <param name="immediateContextOut"><dd>  <p>Returns the address of a reference to an <strong><see cref="SharpDX.Direct3D11.DeviceContext"/></strong> object that represents the device context.</p> </dd></param>
        /// <returns><p>This method can return one of the Direct3D 11 Return Codes.</p><p>This method returns E_INVALIDARG if you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value and the <em>DriverType</em> parameter to the <see cref="SharpDX.Direct3D.DriverType.Hardware"/> value.</p></returns>
        /// <remarks>
        /// <p>This entry-point is supported by the Direct3D 11 runtime, which is available on Windows 7, Windows Server 2008 R2, and as an update to  Windows Vista (KB971644).</p><p>To create a Direct3D 11.1 device (<strong><see cref="SharpDX.Direct3D11.Device1"/></strong>), which is available on Windows?8, Windows Server?2012, and Windows?7 and Windows Server?2008?R2 with the Platform Update for Windows 7 installed, you first create a <strong><see cref="SharpDX.Direct3D11.Device"/></strong> with this function, and then call the <strong>QueryInterface</strong> method on the <strong><see cref="SharpDX.Direct3D11.Device"/></strong> object to obtain the <strong><see cref="SharpDX.Direct3D11.Device1"/></strong> interface.
        /// </p><p>To create a Direct3D 11.2 device (<strong><see cref="SharpDX.Direct3D11.Device2"/></strong>), which is available on Windows?8.1 and Windows Server?2012?R2, you first create a <strong><see cref="SharpDX.Direct3D11.Device"/></strong> with this function, and then call the <strong>QueryInterface</strong> method on the <strong><see cref="SharpDX.Direct3D11.Device"/></strong> object to obtain the <strong><see cref="SharpDX.Direct3D11.Device2"/></strong> interface.
        /// </p><p>Set <em>ppDevice</em> and <em>ppImmediateContext</em> to <strong><c>null</c></strong> to determine which feature level is supported by looking  at pFeatureLevel without creating a device.</p><p>For an example, see How To: Create a Device and Immediate Context; to create a device and a swap chain at the same time,  use <strong>D3D11CreateDeviceAndSwapChain</strong>.</p><p>If you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value, you must also set the <em>DriverType</em> parameter to the <see cref="SharpDX.Direct3D.DriverType.Unknown"/> value. If you set the <em>pAdapter</em> parameter to a non-<strong><c>null</c></strong> value and the <em>DriverType</em> parameter to the <see cref="SharpDX.Direct3D.DriverType.Hardware"/> value, <strong><see cref="SharpDX.Direct3D11.D3D11.CreateDevice"/></strong> returns an <strong><see cref="SharpDX.Result"/></strong> of E_INVALIDARG.</p><table> <tr><td> <p>Differences between Direct3D 10 and Direct3D 11:</p> <p>In Direct3D 10, the presence of <em>pAdapter</em> dictated which adapter to use and the <em>DriverType</em> could  mismatch what the adapter was.</p> <p>In Direct3D 11, if you are trying to create a hardware or a software device, set <em>pAdapter</em> != <strong><c>null</c></strong> which constrains  the other inputs to be:</p> <ul> <li><em>DriverType</em> must be <see cref="SharpDX.Direct3D.DriverType.Unknown"/></li> <li><em>Software</em> must be <strong><c>null</c></strong>.</li> </ul> <p>On the other hand, if <em>pAdapter</em> == <strong><c>null</c></strong>, the <em>DriverType</em> cannot be set to <see cref="SharpDX.Direct3D.DriverType.Unknown"/>; it can be set to either:</p> <ul> <li>If <em>DriverType</em> == <see cref="SharpDX.Direct3D.DriverType.Software"/>,  <em>Software</em> cannot be <strong><c>null</c></strong>.</li> <li>If <em>DriverType</em> == <see cref="SharpDX.Direct3D.DriverType.Hardware"/>, the adapter used will be the default adapter, which is the first adapter that is enumerated by <strong>IDXGIFactory1::EnumAdapters</strong> </li> </ul> </td></tr> </table><p>?</p><p><strong>Windows?Phone?8:</strong> This API is supported.</p><p><strong>Windows Phone 8.1:</strong> This API is supported.</p>
        /// </remarks>
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='D3D11CreateDevice']/*"/>
        /// <msdn-id>ff476082</msdn-id>
        /// <unmanaged>HRESULT D3D11CreateDevice([In, Optional] IDXGIAdapter* pAdapter,[In] D3D_DRIVER_TYPE DriverType,[In] HINSTANCE Software,[In] D3D11_CREATE_DEVICE_FLAG Flags,[In, Buffer, Optional] const D3D_FEATURE_LEVEL* pFeatureLevels,[In] unsigned int FeatureLevels,[In] unsigned int SDKVersion,[Out, Fast] ID3D11Device** ppDevice,[Out, Optional] D3D_FEATURE_LEVEL* pFeatureLevel,[Out, Optional] ID3D11DeviceContext** ppImmediateContext)</unmanaged>
        /// <unmanaged-short>D3D11CreateDevice</unmanaged-short>
        public static SharpDX.Result CreateDevice(SharpDX.DXGI.Adapter adapterRef, SharpDX.Direct3D.DriverType driverType, System.IntPtr software, SharpDX.Direct3D11.DeviceCreationFlags flags, SharpDX.Direct3D.FeatureLevel[] featureLevelsRef, int featureLevels, int sDKVersion, SharpDX.Direct3D11.Device deviceOut, out SharpDX.Direct3D.FeatureLevel featureLevelRef, out SharpDX.Direct3D11.DeviceContext immediateContextOut)
        {
            unsafe {
                SharpDX.Direct3D.FeatureLevel[] featureLevelsRef__ = featureLevelsRef;
                IntPtr         deviceOut_           = IntPtr.Zero;
                IntPtr         immediateContextOut_ = IntPtr.Zero;
                SharpDX.Result __result__;

                fixed(void *featureLevelsRef_ = featureLevelsRef__)
                fixed(void *featureLevelRef_ = &featureLevelRef)
                __result__ =
                    D3D11CreateDevice_((void *)((adapterRef == null)?IntPtr.Zero:adapterRef.NativePointer), unchecked ((int)driverType), (void *)software, unchecked ((int)flags), featureLevelsRef_, featureLevels, sDKVersion, &deviceOut_, featureLevelRef_, &immediateContextOut_);

                ((SharpDX.Direct3D11.Device)deviceOut).NativePointer = deviceOut_;
                immediateContextOut = (immediateContextOut_ == IntPtr.Zero)?null:new SharpDX.Direct3D11.DeviceContext(immediateContextOut_);
                return(__result__);
            }
        }