1 /*****************************************************************************
2 * d3d11_fmt.h : D3D11 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_D3D11_FMT_H_
24 #define VLC_VIDEOCHROMA_D3D11_FMT_H_
30 DEFINE_GUID(GUID_CONTEXT_MUTEX
, 0x472e8835, 0x3f8e, 0x4f93, 0xa0, 0xcb, 0x25, 0x79, 0x77, 0x6c, 0xed, 0x86);
32 /* see https://msdn.microsoft.com/windows/hardware/commercialize/design/compatibility/device-graphics */
35 int wddm
, d3d_features
, revision
, build
;
40 ID3D11Device
*d3ddevice
; /* D3D device */
41 ID3D11DeviceContext
*d3dcontext
; /* D3D context */
43 struct wddm_version WDDM
;
44 D3D_FEATURE_LEVEL feature_level
;
50 HINSTANCE hdll
; /* handle of the opened d3d11 dll */
51 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
52 HINSTANCE dxgidebug_dll
;
57 /* owned by the vout for VLC_CODEC_D3D11_OPAQUE */
60 ID3D11VideoDecoderOutputView
*decoder
; /* may be NULL for pictures from the pool */
62 ID3D11Texture2D
*texture
[D3D11_MAX_SHADER_VIEW
];
63 ID3D11Resource
*resource
[D3D11_MAX_SHADER_VIEW
];
65 ID3D11DeviceContext
*context
;
67 ID3D11VideoProcessorInputView
*processorInput
; /* when used as processor input */
68 ID3D11VideoProcessorOutputView
*processorOutput
; /* when used as processor output */
69 ID3D11ShaderResourceView
*resourceView
[D3D11_MAX_SHADER_VIEW
];
70 DXGI_FORMAT formatTexture
;
73 #include "../codec/avcodec/va_surface.h"
75 picture_sys_t
*ActivePictureSys(picture_t
*p_pic
);
77 /* index to use for texture/resource that use a known DXGI format
78 * (ie not DXGI_FORMAT_UNKNWON) */
79 #define KNOWN_DXGI_INDEX 0
81 static inline bool is_d3d11_opaque(vlc_fourcc_t chroma
)
83 return chroma
== VLC_CODEC_D3D11_OPAQUE
||
84 chroma
== VLC_CODEC_D3D11_OPAQUE_10B
||
85 chroma
== VLC_CODEC_D3D11_OPAQUE_RGBA
||
86 chroma
== VLC_CODEC_D3D11_OPAQUE_BGRA
;
89 void AcquirePictureSys(picture_sys_t
*p_sys
);
91 void ReleasePictureSys(picture_sys_t
*p_sys
);
93 /* map texture planes to resource views */
94 int AllocateShaderView(vlc_object_t
*obj
, ID3D11Device
*d3ddevice
,
95 const d3d_format_t
*format
,
96 ID3D11Texture2D
*p_texture
[D3D11_MAX_SHADER_VIEW
], UINT slice_index
,
97 ID3D11ShaderResourceView
*resourceView
[D3D11_MAX_SHADER_VIEW
]);
99 HRESULT
D3D11_CreateDevice(vlc_object_t
*obj
, d3d11_handle_t
*,
100 bool hw_decoding
, d3d11_device_t
*out
);
101 #define D3D11_CreateDevice(a,b,c,d) D3D11_CreateDevice( VLC_OBJECT(a), b, c, d )
103 void D3D11_ReleaseDevice(d3d11_device_t
*);
105 int D3D11_Create(vlc_object_t
*, d3d11_handle_t
*);
106 #define D3D11_Create(a,b) D3D11_Create( VLC_OBJECT(a), b )
108 void D3D11_Destroy(d3d11_handle_t
*);
110 bool isXboxHardware(ID3D11Device
*d3ddev
);
111 bool CanUseVoutPool(d3d11_device_t
*, UINT slices
);
112 IDXGIAdapter
*D3D11DeviceAdapter(ID3D11Device
*d3ddev
);
113 int D3D11CheckDriverVersion(d3d11_device_t
*, UINT vendorId
,
114 const struct wddm_version
*min_ver
);
115 void D3D11_GetDriverVersion(vlc_object_t
*, d3d11_device_t
*);
116 #define D3D11_GetDriverVersion(a,b) D3D11_GetDriverVersion(VLC_OBJECT(a),b)
118 static inline bool DeviceSupportsFormat(ID3D11Device
*d3ddevice
,
119 DXGI_FORMAT format
, UINT supportFlags
)
121 UINT i_formatSupport
;
122 return SUCCEEDED( ID3D11Device_CheckFormatSupport(d3ddevice
, format
,
124 && ( i_formatSupport
& supportFlags
) == supportFlags
;
127 const d3d_format_t
*FindD3D11Format(ID3D11Device
*d3ddevice
,
128 vlc_fourcc_t i_src_chroma
,
130 uint8_t bits_per_channel
,
134 int AllocateTextures(vlc_object_t
*obj
, d3d11_device_t
*d3d_dev
,
135 const d3d_format_t
*cfg
, const video_format_t
*fmt
,
136 unsigned pool_size
, ID3D11Texture2D
*textures
[]);
139 void D3D11_LogProcessorSupport(vlc_object_t
*, ID3D11VideoProcessorEnumerator
*);
140 #define D3D11_LogProcessorSupport(a,b) D3D11_LogProcessorSupport( VLC_OBJECT(a), b )
143 #endif /* include-guard */