示例#1
0
 public void EndD3D()
 {
     renderTarget.Dispose();
     device.Dispose();
     context.Dispose();
     renderTarget = null;
     device       = null;
     context      = null;
 }
示例#2
0
        /// <summary>
        /// <p>Creates a Microsoft DirectX Video Acceleration High Definition (DXVA-HD) device.</p>
        /// </summary>
        /// <param name="d3DDeviceRef"><dd> <p>A reference to the <strong><see cref="SharpDX.Direct3D9.DeviceEx"/></strong> interface of a Direct3D 9 device.</p> </dd></param>
        /// <param name="contentDescRef"><dd> <p>A reference to a <strong><see cref="SharpDX.MediaFoundation.DirectX.ContentDescription"/></strong> structure that describes the video content. The driver uses this information as a hint when it creates the device.</p> </dd></param>
        /// <param name="usage"><dd> <p>A member of the <strong><see cref="SharpDX.MediaFoundation.DirectX.DeviceUsage"/></strong> enumeration, describing how the device will be used. The value indicates the desired trade-off between speed and video quality. The driver uses this flag as a hint when it creates the device.</p> </dd></param>
        /// <param name="pluginRef"><dd> <p>A reference to an initialization function for a software device. Set this reference if you are using a software plug-in device. Otherwise, set this parameter to <strong><c>null</c></strong>. If the value is <strong><c>null</c></strong>, the driver creates the DXVA-HD device.</p> <p>The function reference type is <strong>PDXVAHDSW_Plugin</strong>.</p> </dd></param>
        /// <param name="deviceOut"><dd> <p>Receives a reference to the <strong><see cref="SharpDX.MediaFoundation.DirectX.HDDevice"/></strong> interface. The caller must release the interface.</p> </dd></param>
        /// <returns><p>The method returns an <strong><see cref="SharpDX.Result"/></strong>. Possible values include, but are not limited to, those in the following table.</p><table> <tr><th>Return code</th><th>Description</th></tr> <tr><td> <dl> <dt><strong><see cref="SharpDX.Result.Ok"/></strong></dt> </dl> </td><td> <p>The method succeeded.</p> </td></tr> <tr><td> <dl> <dt><strong>E_NOINTERFACE</strong></dt> </dl> </td><td> <p>The Direct3D device does not support DXVA-HD.</p> </td></tr> </table><p>?</p></returns>
        /// <remarks>
        /// <p> Use the <strong><see cref="SharpDX.MediaFoundation.DirectX.HDDevice"/></strong> interface to get the device capabilities, create the video processor, and allocate video surfaces. </p>
        /// </remarks>
        /// <include file='..\..\Documentation\CodeComments.xml' path="/comments/comment[@id='DXVAHD_CreateDevice']/*"/>
        /// <msdn-id>dd318412</msdn-id>
        /// <unmanaged>HRESULT DXVAHD_CreateDevice([In] IDirect3DDevice9Ex* pD3DDevice,[In] const DXVAHD_CONTENT_DESC* pContentDesc,[In] DXVAHD_DEVICE_USAGE Usage,[In, Optional] __function__stdcall* pPlugin,[Out, Fast] IDXVAHD_Device** ppDevice)</unmanaged>
        /// <unmanaged-short>DXVAHD_CreateDevice</unmanaged-short>
        public static void CreateDevice(SharpDX.Direct3D9.DeviceEx d3DDeviceRef, ref SharpDX.MediaFoundation.DirectX.ContentDescription contentDescRef, SharpDX.MediaFoundation.DirectX.DeviceUsage usage, SharpDX.FunctionCallback pluginRef, SharpDX.MediaFoundation.DirectX.HDDevice deviceOut)
        {
            unsafe {
                IntPtr         deviceOut_ = IntPtr.Zero;
                SharpDX.Result __result__;

                fixed(void *contentDescRef_ = &contentDescRef)
                __result__ =
                    DXVAHD_CreateDevice_((void *)((d3DDeviceRef == null)?IntPtr.Zero:d3DDeviceRef.NativePointer), contentDescRef_, unchecked ((int)usage), pluginRef, &deviceOut_);

                ((SharpDX.MediaFoundation.DirectX.HDDevice)deviceOut).NativePointer = deviceOut_;
                __result__.CheckError();
            }
        }
示例#3
0
            public D3D9()
            {
                var presentparams = new SharpDX.Direct3D9.PresentParameters
                {
                    Windowed             = true,
                    SwapEffect           = SharpDX.Direct3D9.SwapEffect.Discard,
                    DeviceWindowHandle   = GetDesktopWindow(),
                    PresentationInterval = SharpDX.Direct3D9.PresentInterval.Default
                };

                const SharpDX.Direct3D9.CreateFlags deviceFlags = SharpDX.Direct3D9.CreateFlags.HardwareVertexProcessing | SharpDX.Direct3D9.CreateFlags.Multithreaded | SharpDX.Direct3D9.CreateFlags.FpuPreserve;

                direct3d = new SharpDX.Direct3D9.Direct3DEx();
                device   = new SharpDX.Direct3D9.DeviceEx(direct3d, 0, SharpDX.Direct3D9.DeviceType.Hardware, IntPtr.Zero, deviceFlags, presentparams);
            }
示例#4
0
        void StartD3D()
        {
            context = new SharpDX.Direct3D9.Direct3DEx();
            // Ref: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/wpf-and-direct3d9-interoperation
            var presentparams = new SharpDX.Direct3D9.PresentParameters {
                Windowed   = true,
                SwapEffect = SharpDX.Direct3D9.SwapEffect.Discard,
                //DeviceWindowHandle = GetDesktopWindow(),
                PresentationInterval = SharpDX.Direct3D9.PresentInterval.Default,
                BackBufferHeight     = 1,
                BackBufferWidth      = 1,
                BackBufferFormat     = SharpDX.Direct3D9.Format.Unknown
            };

            device = new SharpDX.Direct3D9.DeviceEx(context, this.adapterIndex,
                                                    SharpDX.Direct3D9.DeviceType.Hardware, IntPtr.Zero,
                                                    SharpDX.Direct3D9.CreateFlags.HardwareVertexProcessing
                                                    | SharpDX.Direct3D9.CreateFlags.Multithreaded
                                                    | SharpDX.Direct3D9.CreateFlags.FpuPreserve,
                                                    presentparams);
        }
示例#5
0
 /// <summary>
 /// <p><strong>Applies to: </strong>desktop apps only</p><p>Creates a Microsoft DirectX Video Acceleration High Definition (DXVA-HD) device.</p>
 /// </summary>
 /// <param name="device"><dd> <p>A reference to the <strong><see cref="SharpDX.Direct3D9.DeviceEx"/></strong> interface of a Direct3D 9 device.</p> </dd></param>
 /// <param name="contentDescription"><dd> <p>A reference to a <strong><see cref="SharpDX.MediaFoundation.DirectX.ContentDescription"/></strong> structure that describes the video content. The driver uses this information as a hint when it creates the device.</p> </dd></param>
 /// <param name="usage"><dd> <p>A member of the <strong><see cref="SharpDX.MediaFoundation.DirectX.DeviceUsage"/></strong> enumeration, describing how the device will be used. The value indicates the desired trade-off between speed and video quality. The driver uses this flag as a hint when it creates the device.</p> </dd></param>
 /// <remarks>
 /// <p> Use the <strong><see cref="SharpDX.MediaFoundation.DirectX.HDDevice"/></strong> interface to get the device capabilities, create the video processor, and allocate video surfaces. </p>
 /// </remarks>
 /// <include file='..\Documentation\CodeComments.xml' path="/comments/comment[@id='DXVAHD_CreateDevice']/*"/>
 /// <msdn-id>dd318412</msdn-id>
 /// <unmanaged>HRESULT DXVAHD_CreateDevice([In] IDirect3DDevice9Ex* pD3DDevice,[In] const DXVAHD_CONTENT_DESC* pContentDesc,[In] DXVAHD_DEVICE_USAGE Usage,[In, Optional] __function__stdcall* pPlugin,[Out, Fast] IDXVAHD_Device** ppDevice)</unmanaged>
 /// <unmanaged-short>DXVAHD_CreateDevice</unmanaged-short>
 public HDDevice(SharpDX.Direct3D9.DeviceEx device, ContentDescription contentDescription, DeviceUsage usage)
 {
     DXVAFactory.CreateDevice(device, ref contentDescription, usage, null, this);
 }