d3d11: handle VLC_CODEC_D3D11_OPAQUE_10B upload/download
[vlc.git] / modules / video_chroma / d3d9_fmt.h
blobc7242ad525f9ee74e34ae1bd60e8a71ebf71dbc3
1 /*****************************************************************************
2 * d3d9_fmt.h : D3D9 helper calls
3 *****************************************************************************
4 * Copyright © 2017 VLC authors, VideoLAN and VideoLabs
6 * Authors: Steve Lhomme <robux4@gmail.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef VLC_VIDEOCHROMA_D3D9_FMT_H_
24 #define VLC_VIDEOCHROMA_D3D9_FMT_H_
26 #include <vlc_picture.h>
28 #define COBJMACROS
29 #include <d3d9.h>
30 #include <dxva2api.h>
32 #include "dxgi_fmt.h"
34 /* owned by the vout for VLC_CODEC_D3D9_OPAQUE */
35 struct picture_sys_t
37 IDirect3DSurface9 *surface;
38 /* decoder only */
39 IDirectXVideoDecoder *decoder; /* keep a reference while the surface exist */
40 HINSTANCE dxva2_dll;
43 typedef struct
45 HINSTANCE hdll; /* handle of the opened d3d9 dll */
46 union {
47 LPDIRECT3D9 obj;
48 LPDIRECT3D9EX objex;
50 bool use_ex;
51 } d3d9_handle_t;
53 typedef struct
55 /* d3d9_handle_t hd3d; TODO */
56 union
58 LPDIRECT3DDEVICE9 dev;
59 LPDIRECT3DDEVICE9EX devex;
61 bool owner;
63 /* creation parameters */
64 D3DPRESENT_PARAMETERS pp;
65 UINT adapterId;
66 HWND hwnd;
67 D3DCAPS9 caps;
68 } d3d9_device_t;
70 #include "../codec/avcodec/va_surface.h"
72 picture_sys_t *ActivePictureSys(picture_t *p_pic);
74 static inline void AcquirePictureSys(picture_sys_t *p_sys)
76 IDirect3DSurface9_AddRef(p_sys->surface);
77 if (p_sys->decoder)
78 IDirectXVideoDecoder_AddRef(p_sys->decoder);
79 p_sys->dxva2_dll = LoadLibrary(TEXT("DXVA2.DLL"));
82 static inline void ReleasePictureSys(picture_sys_t *p_sys)
84 IDirect3DSurface9_Release(p_sys->surface);
85 if (p_sys->decoder)
86 IDirectXVideoDecoder_Release(p_sys->decoder);
87 FreeLibrary(p_sys->dxva2_dll);
90 HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, HWND,
91 const video_format_t *, d3d9_device_t *out);
92 #define D3D9_CreateDevice(a,b,c,d,e) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d, e )
94 void D3D9_ReleaseDevice(d3d9_device_t *);
95 int D3D9_Create(vlc_object_t *, d3d9_handle_t *);
96 #define D3D9_Create(a,b) D3D9_Create( VLC_OBJECT(a), b )
98 void D3D9_Destroy(d3d9_handle_t *);
100 int D3D9_FillPresentationParameters(d3d9_handle_t *, const video_format_t *, d3d9_device_t *);
102 struct wddm_version
104 int wddm, d3d_features, revision, build;
106 int D3D9CheckDriverVersion(d3d9_handle_t *hd3d, d3d9_device_t *d3d_dev, UINT vendorId,
107 const struct wddm_version *min_ver);
110 #endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */