1 /*****************************************************************************
2 * dxgi_fmt.h : DXGI helper calls
3 *****************************************************************************
4 * Copyright © 2015 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_DXGI_FMT_H_
24 #define VLC_VIDEOCHROMA_DXGI_FMT_H_
27 #include <dxgiformat.h>
29 #include <vlc_common.h>
30 #include <vlc_fourcc.h>
32 #define D3D11_MAX_SHADER_VIEW 3
37 DXGI_FORMAT formatTexture
;
39 uint8_t bitsPerChannel
;
40 uint8_t widthDenominator
;
41 uint8_t heightDenominator
;
42 DXGI_FORMAT resourceFormat
[D3D11_MAX_SHADER_VIEW
];
45 extern const char *DxgiFormatToStr(DXGI_FORMAT format
);
46 extern vlc_fourcc_t
DxgiFormatFourcc(DXGI_FORMAT format
);
47 extern const d3d_format_t
*GetRenderFormatList(void);
48 extern void DxgiFormatMask(DXGI_FORMAT format
, video_format_t
*);
50 typedef struct ID3D11Device ID3D11Device
;
51 bool isXboxHardware(ID3D11Device
*d3ddev
);
52 bool isNvidiaHardware(ID3D11Device
*d3ddev
);
53 IDXGIAdapter
*D3D11DeviceAdapter(ID3D11Device
*d3ddev
);
55 static inline bool DeviceSupportsFormat(ID3D11Device
*d3ddevice
,
56 DXGI_FORMAT format
, UINT supportFlags
)
59 return SUCCEEDED( ID3D11Device_CheckFormatSupport(d3ddevice
, format
,
61 && ( i_formatSupport
& supportFlags
) == supportFlags
;
64 static inline const d3d_format_t
*FindD3D11Format(ID3D11Device
*d3ddevice
,
65 vlc_fourcc_t i_src_chroma
,
66 uint8_t bits_per_channel
,
70 supportFlags
|= D3D11_FORMAT_SUPPORT_TEXTURE2D
;
71 for (const d3d_format_t
*output_format
= GetRenderFormatList();
72 output_format
->name
!= NULL
; ++output_format
)
74 if (i_src_chroma
&& i_src_chroma
!= output_format
->fourcc
)
76 if (bits_per_channel
&& bits_per_channel
> output_format
->bitsPerChannel
)
78 if (!allow_opaque
&& (output_format
->fourcc
== VLC_CODEC_D3D11_OPAQUE
||
79 output_format
->fourcc
== VLC_CODEC_D3D11_OPAQUE_10B
))
82 DXGI_FORMAT textureFormat
;
83 if (output_format
->formatTexture
== DXGI_FORMAT_UNKNOWN
)
84 textureFormat
= output_format
->resourceFormat
[0];
86 textureFormat
= output_format
->formatTexture
;
88 if( DeviceSupportsFormat( d3ddevice
, textureFormat
, supportFlags
) )
94 #endif /* include-guard */