1 /**************************************************************************
3 * Copyright 2010 Luca Barbieri
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 #include <d3d1xstutil.h>
29 /* D3D has to keep binary compatibility, so these tables will always work
30 * However, Gallium -> D3D conversion must use .[PIPE_xxx] = D3D11_xxx syntax */
32 pipe_format dxgi_to_pipe_format
[DXGI_FORMAT_COUNT
] =
35 PIPE_FORMAT_R32G32B32A32_FLOAT
, /* TYPELESS */
36 PIPE_FORMAT_R32G32B32A32_FLOAT
,
37 PIPE_FORMAT_R32G32B32A32_USCALED
,
38 PIPE_FORMAT_R32G32B32A32_SSCALED
,
39 PIPE_FORMAT_R32G32B32_FLOAT
, /* TYPELESS */
40 PIPE_FORMAT_R32G32B32_FLOAT
,
41 PIPE_FORMAT_R32G32B32_USCALED
,
42 PIPE_FORMAT_R32G32B32_SSCALED
,
43 PIPE_FORMAT_R16G16B16A16_FLOAT
, /* TYPELESS */
44 PIPE_FORMAT_R16G16B16A16_FLOAT
,
45 PIPE_FORMAT_R16G16B16A16_UNORM
,
46 PIPE_FORMAT_R16G16B16A16_USCALED
,
47 PIPE_FORMAT_R16G16B16A16_SNORM
,
48 PIPE_FORMAT_R16G16B16A16_SSCALED
,
49 PIPE_FORMAT_R32G32_FLOAT
, /* TYPELESS */
50 PIPE_FORMAT_R32G32_FLOAT
,
51 PIPE_FORMAT_R32G32_USCALED
,
52 PIPE_FORMAT_R32G32_SSCALED
,
53 PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED
, /* PIPE_FORMAT_R32G8X24_FLOAT_TYPELESS */
54 PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED
,
55 PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED
, /* PIPE_FORMAT_R32_FLOAT_X8X24_TYPELESS */
56 PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED
, /* PIPE_FORMAT_X32_TYPELESS_G8X24_USCALED */
57 PIPE_FORMAT_R10G10B10A2_UNORM
, /* TYPELESS */
58 PIPE_FORMAT_R10G10B10A2_UNORM
,
59 PIPE_FORMAT_R10G10B10A2_USCALED
,
60 PIPE_FORMAT_R11G11B10_FLOAT
,
61 PIPE_FORMAT_R8G8B8A8_UNORM
, /* TYPELESS */
62 PIPE_FORMAT_R8G8B8A8_UNORM
,
63 PIPE_FORMAT_R8G8B8A8_SRGB
,
64 PIPE_FORMAT_R8G8B8A8_USCALED
,
65 PIPE_FORMAT_R8G8B8A8_SNORM
,
66 PIPE_FORMAT_R8G8B8A8_SSCALED
,
67 PIPE_FORMAT_R16G16_FLOAT
, /* TYPELESS */
68 PIPE_FORMAT_R16G16_FLOAT
,
69 PIPE_FORMAT_R16G16_UNORM
,
70 PIPE_FORMAT_R16G16_USCALED
,
71 PIPE_FORMAT_R16G16_SNORM
,
72 PIPE_FORMAT_R16G16_SSCALED
,
73 PIPE_FORMAT_R32_FLOAT
, /* TYPELESS */
74 PIPE_FORMAT_Z32_FLOAT
,
75 PIPE_FORMAT_R32_FLOAT
,
76 PIPE_FORMAT_R32_USCALED
,
77 PIPE_FORMAT_R32_SSCALED
,
78 PIPE_FORMAT_Z24_UNORM_S8_USCALED
, /* PIPE_FORMAT_R24G8_TYPELESS */
79 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
80 PIPE_FORMAT_Z24X8_UNORM
, /* PIPE_FORMAT_R24_UNORM_X8_TYPELESS */
81 PIPE_FORMAT_Z24_UNORM_S8_USCALED
, /* PIPE_FORMAT_X24_TYPELESS_G8_USCALED */
82 PIPE_FORMAT_R8G8_UNORM
, /* TYPELESS */
83 PIPE_FORMAT_R8G8_UNORM
,
84 PIPE_FORMAT_R8G8_USCALED
,
85 PIPE_FORMAT_R8G8_SNORM
,
86 PIPE_FORMAT_R8G8_SSCALED
,
87 PIPE_FORMAT_R16_FLOAT
, /* TYPELESS */
88 PIPE_FORMAT_R16_FLOAT
,
89 PIPE_FORMAT_Z16_UNORM
,
90 PIPE_FORMAT_R16_UNORM
,
91 PIPE_FORMAT_R16_USCALED
,
92 PIPE_FORMAT_R16_SNORM
,
93 PIPE_FORMAT_R16_SSCALED
,
94 PIPE_FORMAT_R8_UNORM
, /* TYPELESS */
96 PIPE_FORMAT_R8_USCALED
,
98 PIPE_FORMAT_R8_SSCALED
,
100 PIPE_FORMAT_R1_UNORM
,
101 PIPE_FORMAT_R9G9B9E5_FLOAT
,
102 PIPE_FORMAT_R8G8_B8G8_UNORM
,
103 PIPE_FORMAT_G8R8_G8B8_UNORM
,
104 PIPE_FORMAT_DXT1_RGBA
, /* TYPELESS */
105 PIPE_FORMAT_DXT1_RGBA
,
106 PIPE_FORMAT_DXT1_SRGBA
,
107 PIPE_FORMAT_DXT3_RGBA
, /* TYPELESS */
108 PIPE_FORMAT_DXT3_RGBA
,
109 PIPE_FORMAT_DXT3_SRGBA
,
110 PIPE_FORMAT_DXT5_RGBA
, /* TYPELESS */
111 PIPE_FORMAT_DXT5_RGBA
,
112 PIPE_FORMAT_DXT5_SRGBA
,
113 PIPE_FORMAT_RGTC1_UNORM
, /* TYPELESS */
114 PIPE_FORMAT_RGTC1_UNORM
,
115 PIPE_FORMAT_RGTC1_SNORM
,
116 PIPE_FORMAT_RGTC2_UNORM
, /* TYPELESS */
117 PIPE_FORMAT_RGTC2_UNORM
,
118 PIPE_FORMAT_RGTC2_SNORM
,
119 PIPE_FORMAT_B5G6R5_UNORM
,
120 PIPE_FORMAT_B5G5R5A1_UNORM
,
121 PIPE_FORMAT_B8G8R8A8_UNORM
,
122 PIPE_FORMAT_B8G8R8X8_UNORM
,
123 PIPE_FORMAT_R10SG10SB10SA2U_NORM
,
124 PIPE_FORMAT_B8G8R8A8_UNORM
, /* TYPELESS */
125 PIPE_FORMAT_B8G8R8A8_SRGB
,
126 PIPE_FORMAT_B8G8R8X8_UNORM
, /* TYPELESS */
127 PIPE_FORMAT_B8G8R8X8_SRGB
,
128 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC6H_TYPELESS */
129 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC6H_UF16 */
130 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC6H_SF16 */
131 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC7_TYPELESS */
132 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC7_UNORM */
133 PIPE_FORMAT_NONE
, /* PIPE_FORMAT_BC7_UNORM_SRGB */
136 DXGI_FORMAT pipe_to_dxgi_format
[PIPE_FORMAT_COUNT
];
137 static int pipe_to_dxgi_format_initialized
;
138 void init_pipe_to_dxgi_format()
140 if(!pipe_to_dxgi_format_initialized
)
142 for(unsigned i
= 0; i
< DXGI_FORMAT_COUNT
; ++i
)
143 pipe_to_dxgi_format
[dxgi_to_pipe_format
[i
]] = (DXGI_FORMAT
)i
;
144 pipe_to_dxgi_format
[PIPE_FORMAT_NONE
] = DXGI_FORMAT_UNKNOWN
;
145 pipe_to_dxgi_format_initialized
= 1;