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);
34 ID3D11Device
*d3ddevice
; /* D3D device */
35 ID3D11DeviceContext
*d3dcontext
; /* D3D context */
38 /* owned by the vout for VLC_CODEC_D3D11_OPAQUE */
41 ID3D11VideoDecoderOutputView
*decoder
; /* may be NULL for pictures from the pool */
43 ID3D11Texture2D
*texture
[D3D11_MAX_SHADER_VIEW
];
44 ID3D11Resource
*resource
[D3D11_MAX_SHADER_VIEW
];
46 ID3D11DeviceContext
*context
;
48 ID3D11VideoProcessorInputView
*processorInput
; /* when used as processor input */
49 ID3D11VideoProcessorOutputView
*processorOutput
; /* when used as processor output */
50 ID3D11ShaderResourceView
*resourceView
[D3D11_MAX_SHADER_VIEW
];
51 DXGI_FORMAT formatTexture
;
54 #include "../codec/avcodec/va_surface.h"
56 picture_sys_t
*ActivePictureSys(picture_t
*p_pic
);
58 /* index to use for texture/resource that use a known DXGI format
59 * (ie not DXGI_FORMAT_UNKNWON) */
60 #define KNOWN_DXGI_INDEX 0
62 static inline bool is_d3d11_opaque(vlc_fourcc_t chroma
)
64 return chroma
== VLC_CODEC_D3D11_OPAQUE
||
65 chroma
== VLC_CODEC_D3D11_OPAQUE_10B
;
68 void AcquirePictureSys(picture_sys_t
*p_sys
);
70 void ReleasePictureSys(picture_sys_t
*p_sys
);
72 /* map texture planes to resource views */
73 int AllocateShaderView(vlc_object_t
*obj
, ID3D11Device
*d3ddevice
,
74 const d3d_format_t
*format
,
75 ID3D11Texture2D
*p_texture
[D3D11_MAX_SHADER_VIEW
], UINT slice_index
,
76 ID3D11ShaderResourceView
*resourceView
[D3D11_MAX_SHADER_VIEW
]);
78 HRESULT
D3D11_CreateDevice(vlc_object_t
*obj
, HINSTANCE hdecoder_dll
,
80 d3d11_handle_t
*p_hd3d11
);
82 bool isXboxHardware(ID3D11Device
*d3ddev
);
83 bool isNvidiaHardware(ID3D11Device
*d3ddev
);
84 IDXGIAdapter
*D3D11DeviceAdapter(ID3D11Device
*d3ddev
);
86 static inline bool DeviceSupportsFormat(ID3D11Device
*d3ddevice
,
87 DXGI_FORMAT format
, UINT supportFlags
)
90 return SUCCEEDED( ID3D11Device_CheckFormatSupport(d3ddevice
, format
,
92 && ( i_formatSupport
& supportFlags
) == supportFlags
;
95 const d3d_format_t
*FindD3D11Format(ID3D11Device
*d3ddevice
,
96 vlc_fourcc_t i_src_chroma
,
97 uint8_t bits_per_channel
,
101 int AllocateTextures(vlc_object_t
*obj
, d3d11_handle_t
*hd3d11
,
102 const d3d_format_t
*cfg
, const video_format_t
*fmt
,
103 unsigned pool_size
, ID3D11Texture2D
*textures
[]);
105 #endif /* include-guard */