Beispiel #1
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__);
            }
        }
Beispiel #2
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__);
        }