advapi32: Make rpcrt4 a delayed import to work around circular dependencies with...
[wine/testsucceed.git] / dlls / d3d10core / utils.c
blob206efdfa7b8697ac20ef5c1693653e5113fca3fc
1 /*
2 * Copyright 2008 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 #define WINE_D3D10_TO_STR(x) case x: return #x
29 const char *debug_d3d10_primitive_topology(D3D10_PRIMITIVE_TOPOLOGY topology)
31 switch (topology)
33 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED);
34 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST);
35 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_LINELIST);
36 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP);
37 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
38 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
39 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ);
40 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ);
41 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ);
42 WINE_D3D10_TO_STR(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ);
43 default:
44 FIXME("Unrecognized D3D10_PRIMITIVE_TOPOLOGY %#x\n", topology);
45 return "unrecognized";
49 const char *debug_dxgi_format(DXGI_FORMAT format)
51 switch(format)
53 WINE_D3D10_TO_STR(DXGI_FORMAT_UNKNOWN);
54 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32A32_TYPELESS);
55 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32A32_FLOAT);
56 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32A32_UINT);
57 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32A32_SINT);
58 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32_TYPELESS);
59 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32_FLOAT);
60 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32_UINT);
61 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32B32_SINT);
62 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_TYPELESS);
63 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_FLOAT);
64 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_UNORM);
65 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_UINT);
66 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_SNORM);
67 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16B16A16_SINT);
68 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32_TYPELESS);
69 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32_FLOAT);
70 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32_UINT);
71 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G32_SINT);
72 WINE_D3D10_TO_STR(DXGI_FORMAT_R32G8X24_TYPELESS);
73 WINE_D3D10_TO_STR(DXGI_FORMAT_D32_FLOAT_S8X24_UINT);
74 WINE_D3D10_TO_STR(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS);
75 WINE_D3D10_TO_STR(DXGI_FORMAT_X32_TYPELESS_G8X24_UINT);
76 WINE_D3D10_TO_STR(DXGI_FORMAT_R10G10B10A2_TYPELESS);
77 WINE_D3D10_TO_STR(DXGI_FORMAT_R10G10B10A2_UNORM);
78 WINE_D3D10_TO_STR(DXGI_FORMAT_R10G10B10A2_UINT);
79 WINE_D3D10_TO_STR(DXGI_FORMAT_R11G11B10_FLOAT);
80 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_TYPELESS);
81 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_UNORM);
82 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
83 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_UINT);
84 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_SNORM);
85 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8B8A8_SINT);
86 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_TYPELESS);
87 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_FLOAT);
88 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_UNORM);
89 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_UINT);
90 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_SNORM);
91 WINE_D3D10_TO_STR(DXGI_FORMAT_R16G16_SINT);
92 WINE_D3D10_TO_STR(DXGI_FORMAT_R32_TYPELESS);
93 WINE_D3D10_TO_STR(DXGI_FORMAT_D32_FLOAT);
94 WINE_D3D10_TO_STR(DXGI_FORMAT_R32_FLOAT);
95 WINE_D3D10_TO_STR(DXGI_FORMAT_R32_UINT);
96 WINE_D3D10_TO_STR(DXGI_FORMAT_R32_SINT);
97 WINE_D3D10_TO_STR(DXGI_FORMAT_R24G8_TYPELESS);
98 WINE_D3D10_TO_STR(DXGI_FORMAT_D24_UNORM_S8_UINT);
99 WINE_D3D10_TO_STR(DXGI_FORMAT_R24_UNORM_X8_TYPELESS);
100 WINE_D3D10_TO_STR(DXGI_FORMAT_X24_TYPELESS_G8_UINT);
101 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_TYPELESS);
102 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_UNORM);
103 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_UINT);
104 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_SNORM);
105 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_SINT);
106 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_TYPELESS);
107 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_FLOAT);
108 WINE_D3D10_TO_STR(DXGI_FORMAT_D16_UNORM);
109 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_UNORM);
110 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_UINT);
111 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_SNORM);
112 WINE_D3D10_TO_STR(DXGI_FORMAT_R16_SINT);
113 WINE_D3D10_TO_STR(DXGI_FORMAT_R8_TYPELESS);
114 WINE_D3D10_TO_STR(DXGI_FORMAT_R8_UNORM);
115 WINE_D3D10_TO_STR(DXGI_FORMAT_R8_UINT);
116 WINE_D3D10_TO_STR(DXGI_FORMAT_R8_SNORM);
117 WINE_D3D10_TO_STR(DXGI_FORMAT_R8_SINT);
118 WINE_D3D10_TO_STR(DXGI_FORMAT_A8_UNORM);
119 WINE_D3D10_TO_STR(DXGI_FORMAT_R1_UNORM);
120 WINE_D3D10_TO_STR(DXGI_FORMAT_R9G9B9E5_SHAREDEXP);
121 WINE_D3D10_TO_STR(DXGI_FORMAT_R8G8_B8G8_UNORM);
122 WINE_D3D10_TO_STR(DXGI_FORMAT_G8R8_G8B8_UNORM);
123 WINE_D3D10_TO_STR(DXGI_FORMAT_BC1_TYPELESS);
124 WINE_D3D10_TO_STR(DXGI_FORMAT_BC1_UNORM);
125 WINE_D3D10_TO_STR(DXGI_FORMAT_BC1_UNORM_SRGB);
126 WINE_D3D10_TO_STR(DXGI_FORMAT_BC2_TYPELESS);
127 WINE_D3D10_TO_STR(DXGI_FORMAT_BC2_UNORM);
128 WINE_D3D10_TO_STR(DXGI_FORMAT_BC2_UNORM_SRGB);
129 WINE_D3D10_TO_STR(DXGI_FORMAT_BC3_TYPELESS);
130 WINE_D3D10_TO_STR(DXGI_FORMAT_BC3_UNORM);
131 WINE_D3D10_TO_STR(DXGI_FORMAT_BC3_UNORM_SRGB);
132 WINE_D3D10_TO_STR(DXGI_FORMAT_BC4_TYPELESS);
133 WINE_D3D10_TO_STR(DXGI_FORMAT_BC4_UNORM);
134 WINE_D3D10_TO_STR(DXGI_FORMAT_BC4_SNORM);
135 WINE_D3D10_TO_STR(DXGI_FORMAT_BC5_TYPELESS);
136 WINE_D3D10_TO_STR(DXGI_FORMAT_BC5_UNORM);
137 WINE_D3D10_TO_STR(DXGI_FORMAT_BC5_SNORM);
138 WINE_D3D10_TO_STR(DXGI_FORMAT_B5G6R5_UNORM);
139 WINE_D3D10_TO_STR(DXGI_FORMAT_B5G5R5A1_UNORM);
140 WINE_D3D10_TO_STR(DXGI_FORMAT_B8G8R8A8_UNORM);
141 WINE_D3D10_TO_STR(DXGI_FORMAT_B8G8R8X8_UNORM);
142 default:
143 FIXME("Unrecognized DXGI_FORMAT %#x\n", format);
144 return "unrecognized";
148 #undef WINE_D3D10_TO_STR
150 DXGI_FORMAT dxgi_format_from_wined3dformat(WINED3DFORMAT format)
152 switch(format)
154 case WINED3DFMT_UNKNOWN: return DXGI_FORMAT_UNKNOWN;
155 case WINED3DFMT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_TYPELESS;
156 case WINED3DFMT_R32G32B32A32_FLOAT: return DXGI_FORMAT_R32G32B32A32_FLOAT;
157 case WINED3DFMT_R32G32B32A32_UINT: return DXGI_FORMAT_R32G32B32A32_UINT;
158 case WINED3DFMT_R32G32B32A32_SINT: return DXGI_FORMAT_R32G32B32A32_SINT;
159 case WINED3DFMT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_TYPELESS;
160 case WINED3DFMT_R32G32B32_FLOAT: return DXGI_FORMAT_R32G32B32_FLOAT;
161 case WINED3DFMT_R32G32B32_UINT: return DXGI_FORMAT_R32G32B32_UINT;
162 case WINED3DFMT_R32G32B32_SINT: return DXGI_FORMAT_R32G32B32_SINT;
163 case WINED3DFMT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_TYPELESS;
164 case WINED3DFMT_R16G16B16A16_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT;
165 case WINED3DFMT_R16G16B16A16_UNORM: return DXGI_FORMAT_R16G16B16A16_UNORM;
166 case WINED3DFMT_R16G16B16A16_UINT: return DXGI_FORMAT_R16G16B16A16_UINT;
167 case WINED3DFMT_R16G16B16A16_SNORM: return DXGI_FORMAT_R16G16B16A16_SNORM;
168 case WINED3DFMT_R16G16B16A16_SINT: return DXGI_FORMAT_R16G16B16A16_SINT;
169 case WINED3DFMT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_TYPELESS;
170 case WINED3DFMT_R32G32_FLOAT: return DXGI_FORMAT_R32G32_FLOAT;
171 case WINED3DFMT_R32G32_UINT: return DXGI_FORMAT_R32G32_UINT;
172 case WINED3DFMT_R32G32_SINT: return DXGI_FORMAT_R32G32_SINT;
173 case WINED3DFMT_R32G8X24_TYPELESS: return DXGI_FORMAT_R32G8X24_TYPELESS;
174 case WINED3DFMT_D32_FLOAT_S8X24_UINT: return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
175 case WINED3DFMT_R32_FLOAT_X8X24_TYPELESS: return DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS;
176 case WINED3DFMT_X32_TYPELESS_G8X24_UINT: return DXGI_FORMAT_X32_TYPELESS_G8X24_UINT;
177 case WINED3DFMT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_TYPELESS;
178 case WINED3DFMT_R10G10B10A2_UNORM: return DXGI_FORMAT_R10G10B10A2_UNORM;
179 case WINED3DFMT_R10G10B10A2_UINT: return DXGI_FORMAT_R10G10B10A2_UINT;
180 case WINED3DFMT_R11G11B10_FLOAT: return DXGI_FORMAT_R11G11B10_FLOAT;
181 case WINED3DFMT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_TYPELESS;
182 case WINED3DFMT_R8G8B8A8_UNORM: return DXGI_FORMAT_R8G8B8A8_UNORM;
183 case WINED3DFMT_R8G8B8A8_UNORM_SRGB: return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
184 case WINED3DFMT_R8G8B8A8_UINT: return DXGI_FORMAT_R8G8B8A8_UINT;
185 case WINED3DFMT_R8G8B8A8_SNORM: return DXGI_FORMAT_R8G8B8A8_SNORM;
186 case WINED3DFMT_R8G8B8A8_SINT: return DXGI_FORMAT_R8G8B8A8_SINT;
187 case WINED3DFMT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_TYPELESS;
188 case WINED3DFMT_R16G16_FLOAT: return DXGI_FORMAT_R16G16_FLOAT;
189 case WINED3DFMT_R16G16_UNORM: return DXGI_FORMAT_R16G16_UNORM;
190 case WINED3DFMT_R16G16_UINT: return DXGI_FORMAT_R16G16_UINT;
191 case WINED3DFMT_R16G16_SNORM: return DXGI_FORMAT_R16G16_SNORM;
192 case WINED3DFMT_R16G16_SINT: return DXGI_FORMAT_R16G16_SINT;
193 case WINED3DFMT_R32_TYPELESS: return DXGI_FORMAT_R32_TYPELESS;
194 case WINED3DFMT_D32_FLOAT: return DXGI_FORMAT_D32_FLOAT;
195 case WINED3DFMT_R32_FLOAT: return DXGI_FORMAT_R32_FLOAT;
196 case WINED3DFMT_R32_UINT: return DXGI_FORMAT_R32_UINT;
197 case WINED3DFMT_R32_SINT: return DXGI_FORMAT_R32_SINT;
198 case WINED3DFMT_R24G8_TYPELESS: return DXGI_FORMAT_R24G8_TYPELESS;
199 case WINED3DFMT_D24_UNORM_S8_UINT: return DXGI_FORMAT_D24_UNORM_S8_UINT;
200 case WINED3DFMT_R24_UNORM_X8_TYPELESS: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
201 case WINED3DFMT_X24_TYPELESS_G8_UINT: return DXGI_FORMAT_X24_TYPELESS_G8_UINT;
202 case WINED3DFMT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_TYPELESS;
203 case WINED3DFMT_R8G8_UNORM: return DXGI_FORMAT_R8G8_UNORM;
204 case WINED3DFMT_R8G8_UINT: return DXGI_FORMAT_R8G8_UINT;
205 case WINED3DFMT_R8G8_SNORM: return DXGI_FORMAT_R8G8_SNORM;
206 case WINED3DFMT_R8G8_SINT: return DXGI_FORMAT_R8G8_SINT;
207 case WINED3DFMT_R16_TYPELESS: return DXGI_FORMAT_R16_TYPELESS;
208 case WINED3DFMT_R16_FLOAT: return DXGI_FORMAT_R16_FLOAT;
209 case WINED3DFMT_D16_UNORM: return DXGI_FORMAT_D16_UNORM;
210 case WINED3DFMT_R16_UNORM: return DXGI_FORMAT_R16_UNORM;
211 case WINED3DFMT_R16_UINT: return DXGI_FORMAT_R16_UINT;
212 case WINED3DFMT_R16_SNORM: return DXGI_FORMAT_R16_SNORM;
213 case WINED3DFMT_R16_SINT: return DXGI_FORMAT_R16_SINT;
214 case WINED3DFMT_R8_TYPELESS: return DXGI_FORMAT_R8_TYPELESS;
215 case WINED3DFMT_R8_UNORM: return DXGI_FORMAT_R8_UNORM;
216 case WINED3DFMT_R8_UINT: return DXGI_FORMAT_R8_UINT;
217 case WINED3DFMT_R8_SNORM: return DXGI_FORMAT_R8_SNORM;
218 case WINED3DFMT_R8_SINT: return DXGI_FORMAT_R8_SINT;
219 case WINED3DFMT_A8_UNORM: return DXGI_FORMAT_A8_UNORM;
220 case WINED3DFMT_R1_UNORM: return DXGI_FORMAT_R1_UNORM;
221 case WINED3DFMT_R9G9B9E5_SHAREDEXP: return DXGI_FORMAT_R9G9B9E5_SHAREDEXP;
222 case WINED3DFMT_R8G8_B8G8_UNORM: return DXGI_FORMAT_R8G8_B8G8_UNORM;
223 case WINED3DFMT_G8R8_G8B8_UNORM: return DXGI_FORMAT_G8R8_G8B8_UNORM;
224 case WINED3DFMT_BC1_TYPELESS: return DXGI_FORMAT_BC1_TYPELESS;
225 case WINED3DFMT_BC1_UNORM: return DXGI_FORMAT_BC1_UNORM;
226 case WINED3DFMT_BC1_UNORM_SRGB: return DXGI_FORMAT_BC1_UNORM_SRGB;
227 case WINED3DFMT_BC2_TYPELESS: return DXGI_FORMAT_BC2_TYPELESS;
228 case WINED3DFMT_BC2_UNORM: return DXGI_FORMAT_BC2_UNORM;
229 case WINED3DFMT_BC2_UNORM_SRGB: return DXGI_FORMAT_BC2_UNORM_SRGB;
230 case WINED3DFMT_BC3_TYPELESS: return DXGI_FORMAT_BC3_TYPELESS;
231 case WINED3DFMT_BC3_UNORM: return DXGI_FORMAT_BC3_UNORM;
232 case WINED3DFMT_BC3_UNORM_SRGB: return DXGI_FORMAT_BC3_UNORM_SRGB;
233 case WINED3DFMT_BC4_TYPELESS: return DXGI_FORMAT_BC4_TYPELESS;
234 case WINED3DFMT_BC4_UNORM: return DXGI_FORMAT_BC4_UNORM;
235 case WINED3DFMT_BC4_SNORM: return DXGI_FORMAT_BC4_SNORM;
236 case WINED3DFMT_BC5_TYPELESS: return DXGI_FORMAT_BC5_TYPELESS;
237 case WINED3DFMT_BC5_UNORM: return DXGI_FORMAT_BC5_UNORM;
238 case WINED3DFMT_BC5_SNORM: return DXGI_FORMAT_BC5_SNORM;
239 case WINED3DFMT_B5G6R5_UNORM: return DXGI_FORMAT_B5G6R5_UNORM;
240 case WINED3DFMT_B5G5R5A1_UNORM: return DXGI_FORMAT_B5G5R5A1_UNORM;
241 case WINED3DFMT_B8G8R8A8_UNORM: return DXGI_FORMAT_B8G8R8A8_UNORM;
242 case WINED3DFMT_B8G8R8X8_UNORM: return DXGI_FORMAT_B8G8R8X8_UNORM;
243 default:
244 FIXME("Unhandled WINED3DFORMAT %#x\n", format);
245 return WINED3DFMT_UNKNOWN;
249 WINED3DFORMAT wined3dformat_from_dxgi_format(DXGI_FORMAT format)
251 switch(format)
253 case DXGI_FORMAT_UNKNOWN: return WINED3DFMT_UNKNOWN;
254 case DXGI_FORMAT_R32G32B32A32_TYPELESS: return WINED3DFMT_R32G32B32A32_TYPELESS;
255 case DXGI_FORMAT_R32G32B32A32_FLOAT: return WINED3DFMT_R32G32B32A32_FLOAT;
256 case DXGI_FORMAT_R32G32B32A32_UINT: return WINED3DFMT_R32G32B32A32_UINT;
257 case DXGI_FORMAT_R32G32B32A32_SINT: return WINED3DFMT_R32G32B32A32_SINT;
258 case DXGI_FORMAT_R32G32B32_TYPELESS: return WINED3DFMT_R32G32B32_TYPELESS;
259 case DXGI_FORMAT_R32G32B32_FLOAT: return WINED3DFMT_R32G32B32_FLOAT;
260 case DXGI_FORMAT_R32G32B32_UINT: return WINED3DFMT_R32G32B32_UINT;
261 case DXGI_FORMAT_R32G32B32_SINT: return WINED3DFMT_R32G32B32_SINT;
262 case DXGI_FORMAT_R16G16B16A16_TYPELESS: return WINED3DFMT_R16G16B16A16_TYPELESS;
263 case DXGI_FORMAT_R16G16B16A16_FLOAT: return WINED3DFMT_R16G16B16A16_FLOAT;
264 case DXGI_FORMAT_R16G16B16A16_UNORM: return WINED3DFMT_R16G16B16A16_UNORM;
265 case DXGI_FORMAT_R16G16B16A16_UINT: return WINED3DFMT_R16G16B16A16_UINT;
266 case DXGI_FORMAT_R16G16B16A16_SNORM: return WINED3DFMT_R16G16B16A16_SNORM;
267 case DXGI_FORMAT_R16G16B16A16_SINT: return WINED3DFMT_R16G16B16A16_SINT;
268 case DXGI_FORMAT_R32G32_TYPELESS: return WINED3DFMT_R32G32_TYPELESS;
269 case DXGI_FORMAT_R32G32_FLOAT: return WINED3DFMT_R32G32_FLOAT;
270 case DXGI_FORMAT_R32G32_UINT: return WINED3DFMT_R32G32_UINT;
271 case DXGI_FORMAT_R32G32_SINT: return WINED3DFMT_R32G32_SINT;
272 case DXGI_FORMAT_R32G8X24_TYPELESS: return WINED3DFMT_R32G8X24_TYPELESS;
273 case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: return WINED3DFMT_D32_FLOAT_S8X24_UINT;
274 case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: return WINED3DFMT_R32_FLOAT_X8X24_TYPELESS;
275 case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: return WINED3DFMT_X32_TYPELESS_G8X24_UINT;
276 case DXGI_FORMAT_R10G10B10A2_TYPELESS: return WINED3DFMT_R10G10B10A2_TYPELESS;
277 case DXGI_FORMAT_R10G10B10A2_UNORM: return WINED3DFMT_R10G10B10A2_UNORM;
278 case DXGI_FORMAT_R10G10B10A2_UINT: return WINED3DFMT_R10G10B10A2_UINT;
279 case DXGI_FORMAT_R11G11B10_FLOAT: return WINED3DFMT_R11G11B10_FLOAT;
280 case DXGI_FORMAT_R8G8B8A8_TYPELESS: return WINED3DFMT_R8G8B8A8_TYPELESS;
281 case DXGI_FORMAT_R8G8B8A8_UNORM: return WINED3DFMT_R8G8B8A8_UNORM;
282 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return WINED3DFMT_R8G8B8A8_UNORM_SRGB;
283 case DXGI_FORMAT_R8G8B8A8_UINT: return WINED3DFMT_R8G8B8A8_UINT;
284 case DXGI_FORMAT_R8G8B8A8_SNORM: return WINED3DFMT_R8G8B8A8_SNORM;
285 case DXGI_FORMAT_R8G8B8A8_SINT: return WINED3DFMT_R8G8B8A8_SINT;
286 case DXGI_FORMAT_R16G16_TYPELESS: return WINED3DFMT_R16G16_TYPELESS;
287 case DXGI_FORMAT_R16G16_FLOAT: return WINED3DFMT_R16G16_FLOAT;
288 case DXGI_FORMAT_R16G16_UNORM: return WINED3DFMT_R16G16_UNORM;
289 case DXGI_FORMAT_R16G16_UINT: return WINED3DFMT_R16G16_UINT;
290 case DXGI_FORMAT_R16G16_SNORM: return WINED3DFMT_R16G16_SNORM;
291 case DXGI_FORMAT_R16G16_SINT: return WINED3DFMT_R16G16_SINT;
292 case DXGI_FORMAT_R32_TYPELESS: return WINED3DFMT_R32_TYPELESS;
293 case DXGI_FORMAT_D32_FLOAT: return WINED3DFMT_D32_FLOAT;
294 case DXGI_FORMAT_R32_FLOAT: return WINED3DFMT_R32_FLOAT;
295 case DXGI_FORMAT_R32_UINT: return WINED3DFMT_R32_UINT;
296 case DXGI_FORMAT_R32_SINT: return WINED3DFMT_R32_SINT;
297 case DXGI_FORMAT_R24G8_TYPELESS: return WINED3DFMT_R24G8_TYPELESS;
298 case DXGI_FORMAT_D24_UNORM_S8_UINT: return WINED3DFMT_D24_UNORM_S8_UINT;
299 case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: return WINED3DFMT_R24_UNORM_X8_TYPELESS;
300 case DXGI_FORMAT_X24_TYPELESS_G8_UINT: return WINED3DFMT_X24_TYPELESS_G8_UINT;
301 case DXGI_FORMAT_R8G8_TYPELESS: return WINED3DFMT_R8G8_TYPELESS;
302 case DXGI_FORMAT_R8G8_UNORM: return WINED3DFMT_R8G8_UNORM;
303 case DXGI_FORMAT_R8G8_UINT: return WINED3DFMT_R8G8_UINT;
304 case DXGI_FORMAT_R8G8_SNORM: return WINED3DFMT_R8G8_SNORM;
305 case DXGI_FORMAT_R8G8_SINT: return WINED3DFMT_R8G8_SINT;
306 case DXGI_FORMAT_R16_TYPELESS: return WINED3DFMT_R16_TYPELESS;
307 case DXGI_FORMAT_R16_FLOAT: return WINED3DFMT_R16_FLOAT;
308 case DXGI_FORMAT_D16_UNORM: return WINED3DFMT_D16_UNORM;
309 case DXGI_FORMAT_R16_UNORM: return WINED3DFMT_R16_UNORM;
310 case DXGI_FORMAT_R16_UINT: return WINED3DFMT_R16_UINT;
311 case DXGI_FORMAT_R16_SNORM: return WINED3DFMT_R16_SNORM;
312 case DXGI_FORMAT_R16_SINT: return WINED3DFMT_R16_SINT;
313 case DXGI_FORMAT_R8_TYPELESS: return WINED3DFMT_R8_TYPELESS;
314 case DXGI_FORMAT_R8_UNORM: return WINED3DFMT_R8_UNORM;
315 case DXGI_FORMAT_R8_UINT: return WINED3DFMT_R8_UINT;
316 case DXGI_FORMAT_R8_SNORM: return WINED3DFMT_R8_SNORM;
317 case DXGI_FORMAT_R8_SINT: return WINED3DFMT_R8_SINT;
318 case DXGI_FORMAT_A8_UNORM: return WINED3DFMT_A8_UNORM;
319 case DXGI_FORMAT_R1_UNORM: return WINED3DFMT_R1_UNORM;
320 case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: return WINED3DFMT_R9G9B9E5_SHAREDEXP;
321 case DXGI_FORMAT_R8G8_B8G8_UNORM: return WINED3DFMT_R8G8_B8G8_UNORM;
322 case DXGI_FORMAT_G8R8_G8B8_UNORM: return WINED3DFMT_G8R8_G8B8_UNORM;
323 case DXGI_FORMAT_BC1_TYPELESS: return WINED3DFMT_BC1_TYPELESS;
324 case DXGI_FORMAT_BC1_UNORM: return WINED3DFMT_BC1_UNORM;
325 case DXGI_FORMAT_BC1_UNORM_SRGB: return WINED3DFMT_BC1_UNORM_SRGB;
326 case DXGI_FORMAT_BC2_TYPELESS: return WINED3DFMT_BC2_TYPELESS;
327 case DXGI_FORMAT_BC2_UNORM: return WINED3DFMT_BC2_UNORM;
328 case DXGI_FORMAT_BC2_UNORM_SRGB: return WINED3DFMT_BC2_UNORM_SRGB;
329 case DXGI_FORMAT_BC3_TYPELESS: return WINED3DFMT_BC3_TYPELESS;
330 case DXGI_FORMAT_BC3_UNORM: return WINED3DFMT_BC3_UNORM;
331 case DXGI_FORMAT_BC3_UNORM_SRGB: return WINED3DFMT_BC3_UNORM_SRGB;
332 case DXGI_FORMAT_BC4_TYPELESS: return WINED3DFMT_BC4_TYPELESS;
333 case DXGI_FORMAT_BC4_UNORM: return WINED3DFMT_BC4_UNORM;
334 case DXGI_FORMAT_BC4_SNORM: return WINED3DFMT_BC4_SNORM;
335 case DXGI_FORMAT_BC5_TYPELESS: return WINED3DFMT_BC5_TYPELESS;
336 case DXGI_FORMAT_BC5_UNORM: return WINED3DFMT_BC5_UNORM;
337 case DXGI_FORMAT_BC5_SNORM: return WINED3DFMT_BC5_SNORM;
338 case DXGI_FORMAT_B5G6R5_UNORM: return WINED3DFMT_B5G6R5_UNORM;
339 case DXGI_FORMAT_B5G5R5A1_UNORM: return WINED3DFMT_B5G5R5A1_UNORM;
340 case DXGI_FORMAT_B8G8R8A8_UNORM: return WINED3DFMT_B8G8R8A8_UNORM;
341 case DXGI_FORMAT_B8G8R8X8_UNORM: return WINED3DFMT_B8G8R8X8_UNORM;
342 default:
343 FIXME("Unhandled DXGI_FORMAT %#x\n", format);
344 return WINED3DFMT_UNKNOWN;
348 void skip_dword_unknown(const char **ptr, unsigned int count)
350 unsigned int i;
351 DWORD d;
353 FIXME("Skipping %u unknown DWORDs:\n", count);
354 for (i = 0; i < count; ++i)
356 read_dword(ptr, &d);
357 FIXME("\t0x%08x\n", d);
361 HRESULT parse_dxbc(const char *data, SIZE_T data_size,
362 HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx)
364 const char *ptr = data;
365 HRESULT hr = S_OK;
366 DWORD chunk_count;
367 DWORD total_size;
368 unsigned int i;
369 DWORD tag;
371 read_dword(&ptr, &tag);
372 TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
374 if (tag != TAG_DXBC)
376 WARN("Wrong tag.\n");
377 return E_FAIL;
380 /* checksum? */
381 skip_dword_unknown(&ptr, 4);
383 skip_dword_unknown(&ptr, 1);
385 read_dword(&ptr, &total_size);
386 TRACE("total size: %#x\n", total_size);
388 read_dword(&ptr, &chunk_count);
389 TRACE("chunk count: %#x\n", chunk_count);
391 for (i = 0; i < chunk_count; ++i)
393 DWORD chunk_tag, chunk_size;
394 const char *chunk_ptr;
395 DWORD chunk_offset;
397 read_dword(&ptr, &chunk_offset);
398 TRACE("chunk %u at offset %#x\n", i, chunk_offset);
400 chunk_ptr = data + chunk_offset;
402 read_dword(&chunk_ptr, &chunk_tag);
403 read_dword(&chunk_ptr, &chunk_size);
405 hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
406 if (FAILED(hr)) break;
409 return hr;