Exemplo n.º 1
0
 public static extern int DXVAHD_CreateDevice(
     IDirect3DDevice9Ex pD3DDevice,
     DXVAHD_CONTENT_DESC pContentDesc,
     DXVAHD_DEVICE_USAGE Usage,
     PDXVAHDSW_Plugin pPlugin,
     out IDXVAHD_Device ppDevice
     );
Exemplo n.º 2
0
        public void Dispose()
        {
            GC.SuppressFinalize(this);

            SafeRelease(m_pDevice); m_pDevice = null;
            SafeRelease(m_pSurfaceRepaint); m_pSurfaceRepaint = null;
            SafeRelease(m_pDeviceManager); m_pDeviceManager   = null;
            SafeRelease(m_pD3D9); m_pD3D9 = null;
        }
Exemplo n.º 3
0
        protected MFRect m_rcDestRect; // Destination rectangle.

        #endregion Fields

        #region Constructors

        public D3DPresentEngine()
        {
            m_iFrames = 0;
            m_hwnd = IntPtr.Zero;
            m_DeviceResetToken = 0;
            m_pD3D9 = null;
            m_pDevice = null;
            m_pDeviceManager = null;
            m_pSurfaceRepaint = null;

            m_rcDestRect = new MFRect();
            m_DisplayMode = new D3DDISPLAYMODE();

            InitializeD3D();

            CreateD3DDevice();
        }
Exemplo n.º 4
0
        protected IDirect3DSurface9 m_pSurfaceRepaint;       // Surface for repaint requests.

        #endregion

        public D3DPresentEngine()
        {
            m_iFrames = 0;

            m_hwnd             = IntPtr.Zero;
            m_DeviceResetToken = 0;
            m_pD3D9            = null;
            m_pDevice          = null;
            m_pDeviceManager   = null;
            m_pSurfaceRepaint  = null;

            m_rcDestRect  = new MFRect();
            m_DisplayMode = new D3DDISPLAYMODE();

            InitializeD3D();

            CreateD3DDevice();
        }
Exemplo n.º 5
0
        //-----------------------------------------------------------------------------
        // CreateD3DDevice
        //
        // Creates the Direct3D device.
        //-----------------------------------------------------------------------------

        protected void CreateD3DDevice()
        {
            IntPtr    hwnd       = IntPtr.Zero;
            IntPtr    hMonitor   = IntPtr.Zero;
            int       uAdapterID = 0;
            D3DCREATE vp         = 0;

            D3DCAPS9 ddCaps;

            IDirect3DDevice9Ex pDevice = null;

            // Hold the lock because we might be discarding an exisiting device.
            lock (this)
            {
                if ((m_pD3D9 == null) || (m_pDeviceManager == null))
                {
                    throw new COMException("D3DPresentEngine::CreateD3DDevice", (int)HResult.MF_E_NOT_INITIALIZED);
                }

                hwnd = GetDesktopWindow();

                // Note: The presenter creates additional swap chains to present the
                // video frames. Therefore, it does not use the device's implicit
                // swap chain, so the size of the back buffer here is 1 x 1.

                D3DPRESENT_PARAMETERS pp = new D3DPRESENT_PARAMETERS();

                pp.BackBufferWidth      = 1;
                pp.BackBufferHeight     = 1;
                pp.Windowed             = true;
                pp.SwapEffect           = D3DSWAPEFFECT.Copy;
                pp.BackBufferFormat     = D3DFORMAT.Unknown;
                pp.hDeviceWindow        = hwnd;
                pp.Flags                = D3DPRESENTFLAG.Video;
                pp.PresentationInterval = D3DPRESENT_INTERVAL.Default;

                // Find the monitor for this window.
                if (m_hwnd != IntPtr.Zero)
                {
                    hMonitor = MonitorFromWindow(m_hwnd, MonitorFlags.DefaultToNearest);

                    // Find the corresponding adapter.
                    FindAdapter(m_pD3D9 as IDirect3D9, hMonitor, out uAdapterID);
                }

                // Get the device caps for this adapter.
                m_pD3D9.GetDeviceCaps(uAdapterID, D3DDEVTYPE.HAL, out ddCaps);

                if ((ddCaps.DevCaps & D3DDEVCAPS.HWTRANSFORMANDLIGHT) > 0)
                {
                    vp = D3DCREATE.HardwareVertexProcessing;
                }
                else
                {
                    vp = D3DCREATE.SoftwareVertexProcessing;
                }

                // Create the device.
                m_pD3D9.CreateDeviceEx(
                    uAdapterID,
                    D3DDEVTYPE.HAL,
                    pp.hDeviceWindow,
                    vp | D3DCREATE.NoWindowChanges | D3DCREATE.MultiThreaded | D3DCREATE.FPU_PRESERVE,
                    pp,
                    null,
                    out pDevice
                    );

                // Get the adapter display mode.
                m_pD3D9.GetAdapterDisplayMode(uAdapterID, out m_DisplayMode);

                // Reset the D3DDeviceManager with the new device
                m_pDeviceManager.ResetDevice(pDevice, m_DeviceResetToken);

                if (m_pDevice != pDevice)
                {
                    SafeRelease(m_pDevice);

                    m_pDevice = pDevice;
                }

                //SafeRelease(pDevice);
            }
        }
Exemplo n.º 6
0
 public static extern int DXVAHD_CreateDevice(
     IDirect3DDevice9Ex pD3DDevice,
     DXVAHD_CONTENT_DESC pContentDesc,
     DXVAHD_DEVICE_USAGE Usage,
     PDXVAHDSW_Plugin pPlugin,
     out IDXVAHD_Device ppDevice
 );
Exemplo n.º 7
0
        //-----------------------------------------------------------------------------
        // CreateD3DDevice
        //
        // Creates the Direct3D device.
        //-----------------------------------------------------------------------------
        protected void CreateD3DDevice()
        {
            IntPtr hwnd = IntPtr.Zero;
            IntPtr hMonitor = IntPtr.Zero;
            int uAdapterID = 0;
            D3DCREATE vp = 0;

            D3DCAPS9 ddCaps;

            IDirect3DDevice9Ex pDevice = null;

            // Hold the lock because we might be discarding an exisiting device.
            lock (this)
            {
                if ((m_pD3D9 == null) || (m_pDeviceManager == null))
                {
                    throw new COMException("D3DPresentEngine::CreateD3DDevice", MFError.MF_E_NOT_INITIALIZED);
                }

                hwnd = GetDesktopWindow();

                // Note: The presenter creates additional swap chains to present the
                // video frames. Therefore, it does not use the device's implicit
                // swap chain, so the size of the back buffer here is 1 x 1.

                D3DPRESENT_PARAMETERS pp = new D3DPRESENT_PARAMETERS();

                pp.BackBufferWidth = 1;
                pp.BackBufferHeight = 1;
                pp.Windowed = true;
                pp.SwapEffect = D3DSWAPEFFECT.Copy;
                pp.BackBufferFormat = D3DFORMAT.Unknown;
                pp.hDeviceWindow = hwnd;
                pp.Flags = D3DPRESENTFLAG.Video;
                pp.PresentationInterval = D3DPRESENT_INTERVAL.Default;

                // Find the monitor for this window.
                if (m_hwnd != IntPtr.Zero)
                {
                    hMonitor = MonitorFromWindow(m_hwnd, MonitorFlags.DefaultToNearest);

                    // Find the corresponding adapter.
                    FindAdapter(m_pD3D9 as IDirect3D9, hMonitor, out uAdapterID);
                }

                // Get the device caps for this adapter.
                m_pD3D9.GetDeviceCaps(uAdapterID, D3DDEVTYPE.HAL, out ddCaps);

                if ((ddCaps.DevCaps & D3DDEVCAPS.HWTRANSFORMANDLIGHT) > 0)
                {
                    vp = D3DCREATE.HardwareVertexProcessing;
                }
                else
                {
                    vp = D3DCREATE.SoftwareVertexProcessing;
                }

                // Create the device.
                m_pD3D9.CreateDeviceEx(
                    uAdapterID,
                    D3DDEVTYPE.HAL,
                    pp.hDeviceWindow,
                    vp | D3DCREATE.NoWindowChanges | D3DCREATE.MultiThreaded | D3DCREATE.FPU_PRESERVE,
                    pp,
                    null,
                    out pDevice
                    );

                // Get the adapter display mode.
                m_pD3D9.GetAdapterDisplayMode(uAdapterID, out m_DisplayMode);

                // Reset the D3DDeviceManager with the new device
                m_pDeviceManager.ResetDevice(pDevice, m_DeviceResetToken);

                if (m_pDevice != pDevice)
                {
                    SafeRelease(m_pDevice);

                    m_pDevice = pDevice;
                }

                //SafeRelease(pDevice);
            }
        }
Exemplo n.º 8
0
        public void Dispose()
        {
            GC.SuppressFinalize(this);

            SafeRelease(m_pDevice); m_pDevice = null;
            SafeRelease(m_pSurfaceRepaint); m_pSurfaceRepaint = null;
            SafeRelease(m_pDeviceManager); m_pDeviceManager = null;
            SafeRelease(m_pD3D9); m_pD3D9 = null;
        }