1 /*
2  * Copyright © Microsoft Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef D3D12_FORMATS_H
25 #define D3D12_FORMATS_H
26 
27 #include "d3d12_common.h"
28 
29 #include <directx/dxgiformat.h>
30 #include <directx/dxgicommon.h>
31 
32 #include "pipe/p_format.h"
33 #include "pipe/p_defines.h"
34 #include "pipe/p_video_enums.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 DXGI_FORMAT
41 d3d12_get_format(enum pipe_format format);
42 
43 DXGI_FORMAT
44 d3d12_get_typeless_format(enum pipe_format format);
45 
46 /* These two are only used for importing external resources without a provided template */
47 enum pipe_format
48 d3d12_get_pipe_format(DXGI_FORMAT format);
49 
50 enum pipe_format
51 d3d12_get_default_pipe_format(DXGI_FORMAT format);
52 
53 DXGI_FORMAT
54 d3d12_get_resource_srv_format(enum pipe_format f, enum pipe_texture_target target);
55 
56 DXGI_FORMAT
57 d3d12_get_resource_rt_format(enum pipe_format f);
58 
59 unsigned
60 d3d12_non_opaque_plane_count(DXGI_FORMAT f);
61 
62 struct d3d12_format_info {
63    const enum pipe_swizzle *swizzle;
64    int plane_slice;
65 };
66 
67 struct d3d12_format_info
68 d3d12_get_format_info(enum pipe_format resource_format, enum pipe_format format, enum pipe_texture_target);
69 
70 enum pipe_format
71 d3d12_emulated_vtx_format(enum pipe_format fmt);
72 
73 unsigned
74 d3d12_get_format_start_plane(enum pipe_format fmt);
75 
76 unsigned
77 d3d12_get_format_num_planes(enum pipe_format fmt);
78 
79 DXGI_FORMAT
80 d3d12_convert_pipe_video_profile_to_dxgi_format(enum pipe_video_profile profile);
81 
82 DXGI_COLOR_SPACE_TYPE
83 d3d12_convert_from_legacy_color_space(bool rgb, uint32_t bits_per_element, bool studio_rgb, bool p709, bool studio_yuv);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif
90