dbghelp: Restructure internal PDB information.
[wine.git] / dlls / ddraw / utils.c
blobc07fbe6967a1cbfac46ee6040fcc85abd7c44216
1 /*
2 * DirectDraw helper functions
4 * Copyright (c) 1997-2000 Marcus Meissner
5 * Copyright (c) 1998 Lionel Ulmer
6 * Copyright (c) 2000 TransGaming Technologies Inc.
7 * Copyright (c) 2006 Stefan Dösinger
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
27 #include "ddraw_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
31 static void DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf);
33 /*****************************************************************************
34 * PixelFormat_WineD3DtoDD
36 * Converts an wined3d format ID into a DDPIXELFORMAT structure
38 * Params:
39 * DDPixelFormat: Address of the structure to write the pixel format to
40 * WineD3DFormat: Source format
42 *****************************************************************************/
43 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, enum wined3d_format_id WineD3DFormat)
45 DWORD Size = DDPixelFormat->dwSize;
46 TRACE("Converting wined3d format %#x to DDRAW.\n", WineD3DFormat);
48 if(Size==0) return;
50 memset(DDPixelFormat, 0x00, Size);
51 DDPixelFormat->dwSize = Size;
52 switch(WineD3DFormat)
54 case WINED3DFMT_B8G8R8_UNORM:
55 DDPixelFormat->dwFlags = DDPF_RGB;
56 DDPixelFormat->dwFourCC = 0;
57 DDPixelFormat->u1.dwRGBBitCount = 24;
58 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
59 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
60 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
61 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
62 break;
64 case WINED3DFMT_B8G8R8A8_UNORM:
65 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
66 DDPixelFormat->dwFourCC = 0;
67 DDPixelFormat->u1.dwRGBBitCount = 32;
68 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
69 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
70 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
71 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xff000000;
72 break;
74 case WINED3DFMT_B8G8R8X8_UNORM:
75 DDPixelFormat->dwFlags = DDPF_RGB;
76 DDPixelFormat->dwFourCC = 0;
77 DDPixelFormat->u1.dwRGBBitCount = 32;
78 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
79 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
80 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
81 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
82 break;
84 case WINED3DFMT_R8G8B8X8_UNORM:
85 DDPixelFormat->dwFlags = DDPF_RGB;
86 DDPixelFormat->dwFourCC = 0;
87 DDPixelFormat->u1.dwRGBBitCount = 32;
88 DDPixelFormat->u2.dwRBitMask = 0x000000ff;
89 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
90 DDPixelFormat->u4.dwBBitMask = 0x00ff0000;
91 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
92 break;
94 case WINED3DFMT_B5G6R5_UNORM:
95 DDPixelFormat->dwFlags = DDPF_RGB;
96 DDPixelFormat->dwFourCC = 0;
97 DDPixelFormat->u1.dwRGBBitCount = 16;
98 DDPixelFormat->u2.dwRBitMask = 0xF800;
99 DDPixelFormat->u3.dwGBitMask = 0x07E0;
100 DDPixelFormat->u4.dwBBitMask = 0x001F;
101 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
102 break;
104 case WINED3DFMT_B5G5R5X1_UNORM:
105 DDPixelFormat->dwFlags = DDPF_RGB;
106 DDPixelFormat->dwFourCC = 0;
107 DDPixelFormat->u1.dwRGBBitCount = 16;
108 DDPixelFormat->u2.dwRBitMask = 0x7C00;
109 DDPixelFormat->u3.dwGBitMask = 0x03E0;
110 DDPixelFormat->u4.dwBBitMask = 0x001F;
111 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
112 break;
114 case WINED3DFMT_B5G5R5A1_UNORM:
115 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
116 DDPixelFormat->dwFourCC = 0;
117 DDPixelFormat->u1.dwRGBBitCount = 16;
118 DDPixelFormat->u2.dwRBitMask = 0x7C00;
119 DDPixelFormat->u3.dwGBitMask = 0x03E0;
120 DDPixelFormat->u4.dwBBitMask = 0x001F;
121 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x8000;
122 break;
124 case WINED3DFMT_B4G4R4A4_UNORM:
125 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
126 DDPixelFormat->dwFourCC = 0;
127 DDPixelFormat->u1.dwRGBBitCount = 16;
128 DDPixelFormat->u2.dwRBitMask = 0x0F00;
129 DDPixelFormat->u3.dwGBitMask = 0x00F0;
130 DDPixelFormat->u4.dwBBitMask = 0x000F;
131 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
132 break;
134 case WINED3DFMT_B2G3R3_UNORM:
135 DDPixelFormat->dwFlags = DDPF_RGB;
136 DDPixelFormat->dwFourCC = 0;
137 DDPixelFormat->u1.dwRGBBitCount = 8;
138 DDPixelFormat->u2.dwRBitMask = 0xE0;
139 DDPixelFormat->u3.dwGBitMask = 0x1C;
140 DDPixelFormat->u4.dwBBitMask = 0x03;
141 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
142 break;
144 case WINED3DFMT_P8_UINT:
145 DDPixelFormat->dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
146 DDPixelFormat->dwFourCC = 0;
147 DDPixelFormat->u1.dwRGBBitCount = 8;
148 DDPixelFormat->u2.dwRBitMask = 0x00;
149 DDPixelFormat->u3.dwGBitMask = 0x00;
150 DDPixelFormat->u4.dwBBitMask = 0x00;
151 break;
153 case WINED3DFMT_A8_UNORM:
154 DDPixelFormat->dwFlags = DDPF_ALPHA;
155 DDPixelFormat->dwFourCC = 0;
156 DDPixelFormat->u1.dwAlphaBitDepth = 8;
157 DDPixelFormat->u2.dwRBitMask = 0x0;
158 DDPixelFormat->u3.dwZBitMask = 0x0;
159 DDPixelFormat->u4.dwStencilBitMask = 0x0;
160 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
161 break;
163 case WINED3DFMT_B2G3R3A8_UNORM:
164 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
165 DDPixelFormat->dwFourCC = 0;
166 DDPixelFormat->u1.dwRGBBitCount = 16;
167 DDPixelFormat->u2.dwRBitMask = 0x00E0;
168 DDPixelFormat->u3.dwGBitMask = 0x001C;
169 DDPixelFormat->u4.dwBBitMask = 0x0003;
170 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xFF00;
171 break;
173 case WINED3DFMT_B4G4R4X4_UNORM:
174 DDPixelFormat->dwFlags = DDPF_RGB;
175 DDPixelFormat->dwFourCC = 0;
176 DDPixelFormat->u1.dwRGBBitCount = 16;
177 DDPixelFormat->u2.dwRBitMask = 0x0F00;
178 DDPixelFormat->u3.dwGBitMask = 0x00F0;
179 DDPixelFormat->u4.dwBBitMask = 0x000F;
180 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
181 break;
183 /* How are Z buffer bit depth and Stencil buffer bit depth related?
185 case WINED3DFMT_D16_UNORM:
186 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
187 DDPixelFormat->dwFourCC = 0;
188 DDPixelFormat->u1.dwZBufferBitDepth = 16;
189 DDPixelFormat->u2.dwStencilBitDepth = 0;
190 DDPixelFormat->u3.dwZBitMask = 0x0000FFFF;
191 DDPixelFormat->u4.dwStencilBitMask = 0x0;
192 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
193 break;
195 case WINED3DFMT_D32_UNORM:
196 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
197 DDPixelFormat->dwFourCC = 0;
198 DDPixelFormat->u1.dwZBufferBitDepth = 32;
199 DDPixelFormat->u2.dwStencilBitDepth = 0;
200 DDPixelFormat->u3.dwZBitMask = 0xFFFFFFFF;
201 DDPixelFormat->u4.dwStencilBitMask = 0x0;
202 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
203 break;
205 case WINED3DFMT_S4X4_UINT_D24_UNORM:
206 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
207 DDPixelFormat->dwFourCC = 0;
208 /* Should I set dwZBufferBitDepth to 32 here? */
209 DDPixelFormat->u1.dwZBufferBitDepth = 32;
210 DDPixelFormat->u2.dwStencilBitDepth = 4;
211 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFF;
212 DDPixelFormat->u4.dwStencilBitMask = 0x0F000000;
213 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
214 break;
216 case WINED3DFMT_D24_UNORM_S8_UINT:
217 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
218 DDPixelFormat->dwFourCC = 0;
219 /* Should I set dwZBufferBitDepth to 32 here? */
220 DDPixelFormat->u1.dwZBufferBitDepth = 32;
221 DDPixelFormat->u2.dwStencilBitDepth = 8;
222 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
223 DDPixelFormat->u4.dwStencilBitMask = 0xFF000000;
224 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
225 break;
227 case WINED3DFMT_X8D24_UNORM:
228 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
229 DDPixelFormat->dwFourCC = 0;
230 DDPixelFormat->u1.dwZBufferBitDepth = 32;
231 DDPixelFormat->u2.dwStencilBitDepth = 0;
232 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
233 DDPixelFormat->u4.dwStencilBitMask = 0x00000000;
234 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
235 break;
237 case WINED3DFMT_S1_UINT_D15_UNORM:
238 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
239 DDPixelFormat->dwFourCC = 0;
240 DDPixelFormat->u1.dwZBufferBitDepth = 16;
241 DDPixelFormat->u2.dwStencilBitDepth = 1;
242 DDPixelFormat->u3.dwZBitMask = 0x7fff;
243 DDPixelFormat->u4.dwStencilBitMask = 0x8000;
244 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
245 break;
247 case WINED3DFMT_UYVY:
248 case WINED3DFMT_YUY2:
249 DDPixelFormat->u1.dwYUVBitCount = 16;
250 DDPixelFormat->dwFlags = DDPF_FOURCC;
251 DDPixelFormat->dwFourCC = WineD3DFormat;
252 break;
254 case WINED3DFMT_YV12:
255 DDPixelFormat->u1.dwYUVBitCount = 12;
256 DDPixelFormat->dwFlags = DDPF_FOURCC;
257 DDPixelFormat->dwFourCC = WineD3DFormat;
258 break;
260 case WINED3DFMT_DXT1:
261 case WINED3DFMT_DXT2:
262 case WINED3DFMT_DXT3:
263 case WINED3DFMT_DXT4:
264 case WINED3DFMT_DXT5:
265 case WINED3DFMT_MULTI2_ARGB8:
266 case WINED3DFMT_G8R8_G8B8:
267 case WINED3DFMT_R8G8_B8G8:
268 DDPixelFormat->dwFlags = DDPF_FOURCC;
269 DDPixelFormat->dwFourCC = WineD3DFormat;
270 break;
272 /* Luminance */
273 case WINED3DFMT_L8_UNORM:
274 DDPixelFormat->dwFlags = DDPF_LUMINANCE;
275 DDPixelFormat->dwFourCC = 0;
276 DDPixelFormat->u1.dwLuminanceBitCount = 8;
277 DDPixelFormat->u2.dwLuminanceBitMask = 0xff;
278 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
279 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
280 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
281 break;
283 case WINED3DFMT_L4A4_UNORM:
284 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
285 DDPixelFormat->dwFourCC = 0;
286 DDPixelFormat->u1.dwLuminanceBitCount = 4;
287 DDPixelFormat->u2.dwLuminanceBitMask = 0x0f;
288 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
289 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
290 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xf0;
291 break;
293 case WINED3DFMT_L8A8_UNORM:
294 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
295 DDPixelFormat->dwFourCC = 0;
296 DDPixelFormat->u1.dwLuminanceBitCount = 16;
297 DDPixelFormat->u2.dwLuminanceBitMask = 0x00ff;
298 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
299 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
300 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xff00;
301 break;
303 /* Bump mapping */
304 case WINED3DFMT_R8G8_SNORM:
305 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
306 DDPixelFormat->dwFourCC = 0;
307 DDPixelFormat->u1.dwBumpBitCount = 16;
308 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
309 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
310 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00000000;
311 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
312 break;
314 case WINED3DFMT_R16G16_SNORM:
315 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
316 DDPixelFormat->dwFourCC = 0;
317 DDPixelFormat->u1.dwBumpBitCount = 32;
318 DDPixelFormat->u2.dwBumpDuBitMask = 0x0000ffff;
319 DDPixelFormat->u3.dwBumpDvBitMask = 0xffff0000;
320 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00000000;
321 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
322 break;
324 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
325 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
326 DDPixelFormat->dwFourCC = 0;
327 DDPixelFormat->u1.dwBumpBitCount = 16;
328 DDPixelFormat->u2.dwBumpDuBitMask = 0x0000001f;
329 DDPixelFormat->u3.dwBumpDvBitMask = 0x000003e0;
330 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0000fc00;
331 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
332 break;
334 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
335 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
336 DDPixelFormat->dwFourCC = 0;
337 DDPixelFormat->u1.dwBumpBitCount = 32;
338 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
339 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
340 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00ff0000;
341 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
342 break;
344 default:
345 ERR("Can't translate this Pixelformat %d\n", WineD3DFormat);
348 if(TRACE_ON(ddraw)) {
349 TRACE("Returning: ");
350 DDRAW_dump_pixelformat(DDPixelFormat);
353 /*****************************************************************************
354 * PixelFormat_DD2WineD3D
356 * Reads a DDPIXELFORMAT structure and returns the equivalent wined3d
357 * format ID.
359 * Params:
360 * DDPixelFormat: The source format
362 * Returns:
363 * The wined3d format ID equivalent to the DDraw format
364 * WINED3DFMT_UNKNOWN if a matching format wasn't found
365 *****************************************************************************/
366 enum wined3d_format_id PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat)
368 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
369 if(TRACE_ON(ddraw))
371 DDRAW_dump_pixelformat(DDPixelFormat);
374 if(DDPixelFormat->dwFlags & DDPF_PALETTEINDEXED8)
376 return WINED3DFMT_P8_UINT;
378 else if(DDPixelFormat->dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4) )
380 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
381 return WINED3DFMT_P8_UINT;
383 else if(DDPixelFormat->dwFlags & DDPF_RGB)
385 switch(DDPixelFormat->u1.dwRGBBitCount)
387 case 8:
388 /* This is the only format that can match here */
389 return WINED3DFMT_B2G3R3_UNORM;
391 case 16:
392 /* Read the Color masks */
393 if( (DDPixelFormat->u2.dwRBitMask == 0xF800) &&
394 (DDPixelFormat->u3.dwGBitMask == 0x07E0) &&
395 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
397 return WINED3DFMT_B5G6R5_UNORM;
400 if( (DDPixelFormat->u2.dwRBitMask == 0x7C00) &&
401 (DDPixelFormat->u3.dwGBitMask == 0x03E0) &&
402 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
404 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
405 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0x8000))
406 return WINED3DFMT_B5G5R5A1_UNORM;
407 else
408 return WINED3DFMT_B5G5R5X1_UNORM;
411 if( (DDPixelFormat->u2.dwRBitMask == 0x0F00) &&
412 (DDPixelFormat->u3.dwGBitMask == 0x00F0) &&
413 (DDPixelFormat->u4.dwBBitMask == 0x000F) )
415 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
416 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xF000))
417 return WINED3DFMT_B4G4R4A4_UNORM;
418 else
419 return WINED3DFMT_B4G4R4X4_UNORM;
422 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
423 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF00) &&
424 (DDPixelFormat->u2.dwRBitMask == 0x00E0) &&
425 (DDPixelFormat->u3.dwGBitMask == 0x001C) &&
426 (DDPixelFormat->u4.dwBBitMask == 0x0003) )
428 return WINED3DFMT_B2G3R3A8_UNORM;
430 ERR("16 bit RGB Pixel format does not match\n");
431 return WINED3DFMT_UNKNOWN;
433 case 24:
434 return WINED3DFMT_B8G8R8_UNORM;
436 case 32:
437 /* Read the Color masks */
438 if( (DDPixelFormat->u2.dwRBitMask == 0x00FF0000) &&
439 (DDPixelFormat->u3.dwGBitMask == 0x0000FF00) &&
440 (DDPixelFormat->u4.dwBBitMask == 0x000000FF) )
442 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
443 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF000000))
444 return WINED3DFMT_B8G8R8A8_UNORM;
445 else
446 return WINED3DFMT_B8G8R8X8_UNORM;
449 ERR("32 bit RGB pixel format does not match\n");
451 default:
452 ERR("Invalid dwRGBBitCount in Pixelformat structure\n");
453 return WINED3DFMT_UNKNOWN;
456 else if( (DDPixelFormat->dwFlags & DDPF_ALPHA) )
458 /* Alpha only Pixelformat */
459 switch(DDPixelFormat->u1.dwAlphaBitDepth)
461 case 1:
462 case 2:
463 case 4:
464 ERR("Unsupported Alpha-Only bit depth 0x%x\n", DDPixelFormat->u1.dwAlphaBitDepth);
465 case 8:
466 return WINED3DFMT_A8_UNORM;
468 default:
469 ERR("Invalid AlphaBitDepth in Alpha-Only Pixelformat\n");
470 return WINED3DFMT_UNKNOWN;
473 else if(DDPixelFormat->dwFlags & DDPF_LUMINANCE)
475 /* Luminance-only or luminance-alpha */
476 if(DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS)
478 /* Luminance with Alpha */
479 switch(DDPixelFormat->u1.dwLuminanceBitCount)
481 case 4:
482 if(DDPixelFormat->u1.dwAlphaBitDepth == 4)
483 return WINED3DFMT_L4A4_UNORM;
484 ERR("Unknown Alpha / Luminance bit depth combination\n");
485 return WINED3DFMT_UNKNOWN;
487 case 6:
488 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
489 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
491 case 8:
492 if(DDPixelFormat->u1.dwAlphaBitDepth == 8)
493 return WINED3DFMT_L8A8_UNORM;
494 ERR("Unknown Alpha / Lumincase bit depth combination\n");
495 return WINED3DFMT_UNKNOWN;
498 else
500 /* Luminance-only */
501 switch(DDPixelFormat->u1.dwLuminanceBitCount)
503 case 6:
504 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
505 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
507 case 8:
508 return WINED3DFMT_L8_UNORM;
510 default:
511 ERR("Unknown luminance-only bit depth 0x%x\n", DDPixelFormat->u1.dwLuminanceBitCount);
512 return WINED3DFMT_UNKNOWN;
516 else if(DDPixelFormat->dwFlags & DDPF_ZBUFFER)
518 /* Z buffer */
519 if(DDPixelFormat->dwFlags & DDPF_STENCILBUFFER)
521 switch(DDPixelFormat->u1.dwZBufferBitDepth)
523 case 8:
524 FIXME("8 Bits Z+Stencil buffer pixelformat is not supported. Returning WINED3DFMT_UNKNOWN\n");
525 return WINED3DFMT_UNKNOWN;
527 case 15:
528 FIXME("15 bit depth buffer not handled yet, assuming 16 bit\n");
529 case 16:
530 if(DDPixelFormat->u2.dwStencilBitDepth == 1)
531 return WINED3DFMT_S1_UINT_D15_UNORM;
533 FIXME("Don't know how to handle a 16 bit Z buffer with %d bit stencil buffer pixelformat\n", DDPixelFormat->u2.dwStencilBitDepth);
534 return WINED3DFMT_UNKNOWN;
536 case 24:
537 FIXME("Don't know how to handle a 24 bit depth buffer with stencil bits\n");
538 return WINED3DFMT_D24_UNORM_S8_UINT;
540 case 32:
541 if(DDPixelFormat->u2.dwStencilBitDepth == 8)
542 return WINED3DFMT_D24_UNORM_S8_UINT;
543 else
544 return WINED3DFMT_S4X4_UINT_D24_UNORM;
546 default:
547 ERR("Unknown Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
548 return WINED3DFMT_UNKNOWN;
551 else
553 switch(DDPixelFormat->u1.dwZBufferBitDepth)
555 case 8:
556 ERR("8 Bit Z buffers are not supported. Trying a 16 Bit one\n");
557 return WINED3DFMT_D16_UNORM;
559 case 16:
560 return WINED3DFMT_D16_UNORM;
562 case 24:
563 FIXME("24 Bit depth buffer, treating like a 32 bit one\n");
564 case 32:
565 if(DDPixelFormat->u3.dwZBitMask == 0x00FFFFFF) {
566 return WINED3DFMT_X8D24_UNORM;
567 } else if(DDPixelFormat->u3.dwZBitMask == 0xFFFFFFFF) {
568 return WINED3DFMT_D32_UNORM;
570 FIXME("Unhandled 32 bit depth buffer bitmasks, returning WINED3DFMT_D24X8\n");
571 return WINED3DFMT_X8D24_UNORM; /* That's most likely to make games happy */
573 default:
574 ERR("Unsupported Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
575 return WINED3DFMT_UNKNOWN;
579 else if(DDPixelFormat->dwFlags & DDPF_FOURCC)
581 return DDPixelFormat->dwFourCC;
583 else if(DDPixelFormat->dwFlags & DDPF_BUMPDUDV)
585 if( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
586 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
587 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
588 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00000000) )
590 return WINED3DFMT_R8G8_SNORM;
592 else if ( (DDPixelFormat->u1.dwBumpBitCount == 32 ) &&
593 (DDPixelFormat->u2.dwBumpDuBitMask == 0x0000ffff) &&
594 (DDPixelFormat->u3.dwBumpDvBitMask == 0xffff0000) &&
595 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00000000) )
597 return WINED3DFMT_R16G16_SNORM;
599 else if ( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
600 (DDPixelFormat->u2.dwBumpDuBitMask == 0x0000001f) &&
601 (DDPixelFormat->u3.dwBumpDvBitMask == 0x000003e0) &&
602 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x0000fc00) )
604 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
606 else if ( (DDPixelFormat->u1.dwBumpBitCount == 32 ) &&
607 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
608 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
609 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00ff0000) )
611 return WINED3DFMT_R8G8_SNORM_L8X8_UNORM;
615 ERR("Unknown Pixelformat!\n");
616 return WINED3DFMT_UNKNOWN;
619 /*****************************************************************************
620 * Various dumping functions.
622 * They write the contents of a specific function to a TRACE.
624 *****************************************************************************/
625 static void
626 DDRAW_dump_DWORD(const void *in)
628 TRACE("%d\n", *((const DWORD *) in));
630 static void
631 DDRAW_dump_PTR(const void *in)
633 TRACE("%p\n", *((const void * const*) in));
635 static void
636 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *ddck)
638 TRACE("Low : %d - High : %d\n", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
641 static void DDRAW_dump_flags_nolf(DWORD flags, const flag_info* names,
642 size_t num_names)
644 unsigned int i;
646 for (i=0; i < num_names; i++)
647 if ((flags & names[i].val) || /* standard flag value */
648 ((!flags) && (!names[i].val))) /* zero value only */
649 TRACE("%s ", names[i].name);
652 static void DDRAW_dump_flags(DWORD flags, const flag_info* names, size_t num_names)
654 DDRAW_dump_flags_nolf(flags, names, num_names);
655 TRACE("\n");
658 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in)
660 static const flag_info flags[] = {
661 FE(DDSCAPS_RESERVED1),
662 FE(DDSCAPS_ALPHA),
663 FE(DDSCAPS_BACKBUFFER),
664 FE(DDSCAPS_COMPLEX),
665 FE(DDSCAPS_FLIP),
666 FE(DDSCAPS_FRONTBUFFER),
667 FE(DDSCAPS_OFFSCREENPLAIN),
668 FE(DDSCAPS_OVERLAY),
669 FE(DDSCAPS_PALETTE),
670 FE(DDSCAPS_PRIMARYSURFACE),
671 FE(DDSCAPS_PRIMARYSURFACELEFT),
672 FE(DDSCAPS_SYSTEMMEMORY),
673 FE(DDSCAPS_TEXTURE),
674 FE(DDSCAPS_3DDEVICE),
675 FE(DDSCAPS_VIDEOMEMORY),
676 FE(DDSCAPS_VISIBLE),
677 FE(DDSCAPS_WRITEONLY),
678 FE(DDSCAPS_ZBUFFER),
679 FE(DDSCAPS_OWNDC),
680 FE(DDSCAPS_LIVEVIDEO),
681 FE(DDSCAPS_HWCODEC),
682 FE(DDSCAPS_MODEX),
683 FE(DDSCAPS_MIPMAP),
684 FE(DDSCAPS_RESERVED2),
685 FE(DDSCAPS_ALLOCONLOAD),
686 FE(DDSCAPS_VIDEOPORT),
687 FE(DDSCAPS_LOCALVIDMEM),
688 FE(DDSCAPS_NONLOCALVIDMEM),
689 FE(DDSCAPS_STANDARDVGAMODE),
690 FE(DDSCAPS_OPTIMIZED)
692 static const flag_info flags2[] = {
693 FE(DDSCAPS2_HARDWAREDEINTERLACE),
694 FE(DDSCAPS2_HINTDYNAMIC),
695 FE(DDSCAPS2_HINTSTATIC),
696 FE(DDSCAPS2_TEXTUREMANAGE),
697 FE(DDSCAPS2_RESERVED1),
698 FE(DDSCAPS2_RESERVED2),
699 FE(DDSCAPS2_OPAQUE),
700 FE(DDSCAPS2_HINTANTIALIASING),
701 FE(DDSCAPS2_CUBEMAP),
702 FE(DDSCAPS2_CUBEMAP_POSITIVEX),
703 FE(DDSCAPS2_CUBEMAP_NEGATIVEX),
704 FE(DDSCAPS2_CUBEMAP_POSITIVEY),
705 FE(DDSCAPS2_CUBEMAP_NEGATIVEY),
706 FE(DDSCAPS2_CUBEMAP_POSITIVEZ),
707 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ),
708 FE(DDSCAPS2_MIPMAPSUBLEVEL),
709 FE(DDSCAPS2_D3DTEXTUREMANAGE),
710 FE(DDSCAPS2_DONOTPERSIST),
711 FE(DDSCAPS2_STEREOSURFACELEFT)
714 DDRAW_dump_flags_nolf(in->dwCaps, flags, sizeof(flags)/sizeof(flags[0]));
715 DDRAW_dump_flags(in->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
718 static void
719 DDRAW_dump_DDSCAPS(const DDSCAPS *in)
721 DDSCAPS2 in_bis;
723 in_bis.dwCaps = in->dwCaps;
724 in_bis.dwCaps2 = 0;
725 in_bis.dwCaps3 = 0;
726 in_bis.dwCaps4 = 0;
728 DDRAW_dump_DDSCAPS2(&in_bis);
731 static void
732 DDRAW_dump_pixelformat_flag(DWORD flagmask)
734 static const flag_info flags[] =
736 FE(DDPF_ALPHAPIXELS),
737 FE(DDPF_ALPHA),
738 FE(DDPF_FOURCC),
739 FE(DDPF_PALETTEINDEXED4),
740 FE(DDPF_PALETTEINDEXEDTO8),
741 FE(DDPF_PALETTEINDEXED8),
742 FE(DDPF_RGB),
743 FE(DDPF_COMPRESSED),
744 FE(DDPF_RGBTOYUV),
745 FE(DDPF_YUV),
746 FE(DDPF_ZBUFFER),
747 FE(DDPF_PALETTEINDEXED1),
748 FE(DDPF_PALETTEINDEXED2),
749 FE(DDPF_ZPIXELS)
752 DDRAW_dump_flags_nolf(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
755 static void
756 DDRAW_dump_members(DWORD flags,
757 const void* data,
758 const member_info* mems,
759 size_t num_mems)
761 unsigned int i;
763 for (i=0; i < num_mems; i++)
765 if (mems[i].val & flags)
767 TRACE(" - %s : ", mems[i].name);
768 mems[i].func((const char *)data + mems[i].offset);
773 static void
774 DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf)
776 TRACE("( ");
777 DDRAW_dump_pixelformat_flag(pf->dwFlags);
778 if (pf->dwFlags & DDPF_FOURCC)
780 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
781 (unsigned char)( pf->dwFourCC &0xff),
782 (unsigned char)((pf->dwFourCC>> 8)&0xff),
783 (unsigned char)((pf->dwFourCC>>16)&0xff),
784 (unsigned char)((pf->dwFourCC>>24)&0xff),
785 pf->dwFourCC,
786 pf->u1.dwYUVBitCount
789 if (pf->dwFlags & DDPF_RGB)
791 const char *cmd;
792 TRACE(", RGB bits: %d, ", pf->u1.dwRGBBitCount);
793 switch (pf->u1.dwRGBBitCount)
795 case 4: cmd = "%1lx"; break;
796 case 8: cmd = "%02lx"; break;
797 case 16: cmd = "%04lx"; break;
798 case 24: cmd = "%06lx"; break;
799 case 32: cmd = "%08lx"; break;
800 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
802 TRACE(" R "); TRACE(cmd, pf->u2.dwRBitMask);
803 TRACE(" G "); TRACE(cmd, pf->u3.dwGBitMask);
804 TRACE(" B "); TRACE(cmd, pf->u4.dwBBitMask);
805 if (pf->dwFlags & DDPF_ALPHAPIXELS)
807 TRACE(" A "); TRACE(cmd, pf->u5.dwRGBAlphaBitMask);
809 if (pf->dwFlags & DDPF_ZPIXELS)
811 TRACE(" Z "); TRACE(cmd, pf->u5.dwRGBZBitMask);
814 if (pf->dwFlags & DDPF_ZBUFFER)
816 TRACE(", Z bits : %d", pf->u1.dwZBufferBitDepth);
818 if (pf->dwFlags & DDPF_ALPHA)
820 TRACE(", Alpha bits : %d", pf->u1.dwAlphaBitDepth);
822 if (pf->dwFlags & DDPF_BUMPDUDV)
824 const char *cmd = "%08lx";
825 TRACE(", Bump bits: %d, ", pf->u1.dwBumpBitCount);
826 TRACE(" U "); TRACE(cmd, pf->u2.dwBumpDuBitMask);
827 TRACE(" V "); TRACE(cmd, pf->u3.dwBumpDvBitMask);
828 TRACE(" L "); TRACE(cmd, pf->u4.dwBumpLuminanceBitMask);
830 TRACE(")\n");
833 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd)
835 #define STRUCT DDSURFACEDESC2
836 static const member_info members[] =
838 ME(DDSD_HEIGHT, DDRAW_dump_DWORD, dwHeight),
839 ME(DDSD_WIDTH, DDRAW_dump_DWORD, dwWidth),
840 ME(DDSD_PITCH, DDRAW_dump_DWORD, u1 /* lPitch */),
841 ME(DDSD_LINEARSIZE, DDRAW_dump_DWORD, u1 /* dwLinearSize */),
842 ME(DDSD_BACKBUFFERCOUNT, DDRAW_dump_DWORD, dwBackBufferCount),
843 ME(DDSD_MIPMAPCOUNT, DDRAW_dump_DWORD, u2 /* dwMipMapCount */),
844 ME(DDSD_ZBUFFERBITDEPTH, DDRAW_dump_DWORD, u2 /* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
845 ME(DDSD_REFRESHRATE, DDRAW_dump_DWORD, u2 /* dwRefreshRate */),
846 ME(DDSD_ALPHABITDEPTH, DDRAW_dump_DWORD, dwAlphaBitDepth),
847 ME(DDSD_LPSURFACE, DDRAW_dump_PTR, lpSurface),
848 ME(DDSD_CKDESTOVERLAY, DDRAW_dump_DDCOLORKEY, u3 /* ddckCKDestOverlay */),
849 ME(DDSD_CKDESTBLT, DDRAW_dump_DDCOLORKEY, ddckCKDestBlt),
850 ME(DDSD_CKSRCOVERLAY, DDRAW_dump_DDCOLORKEY, ddckCKSrcOverlay),
851 ME(DDSD_CKSRCBLT, DDRAW_dump_DDCOLORKEY, ddckCKSrcBlt),
852 ME(DDSD_PIXELFORMAT, DDRAW_dump_pixelformat, u4 /* ddpfPixelFormat */)
854 static const member_info members_caps[] =
856 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS, ddsCaps)
858 static const member_info members_caps2[] =
860 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS2, ddsCaps)
862 #undef STRUCT
864 if (NULL == lpddsd)
866 TRACE("(null)\n");
868 else
870 if (lpddsd->dwSize >= sizeof(DDSURFACEDESC2))
872 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps2, 1);
874 else
876 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps, 1);
878 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members,
879 sizeof(members)/sizeof(members[0]));
883 void
884 dump_D3DMATRIX(const D3DMATRIX *mat)
886 TRACE(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
887 TRACE(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
888 TRACE(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
889 TRACE(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
892 DWORD
893 get_flexible_vertex_size(DWORD d3dvtVertexType)
895 DWORD size = 0;
896 DWORD i;
898 if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
899 if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
900 if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
901 if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD);
902 switch (d3dvtVertexType & D3DFVF_POSITION_MASK)
904 case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
905 case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
906 case D3DFVF_XYZB1: size += 4 * sizeof(D3DVALUE); break;
907 case D3DFVF_XYZB2: size += 5 * sizeof(D3DVALUE); break;
908 case D3DFVF_XYZB3: size += 6 * sizeof(D3DVALUE); break;
909 case D3DFVF_XYZB4: size += 7 * sizeof(D3DVALUE); break;
910 case D3DFVF_XYZB5: size += 8 * sizeof(D3DVALUE); break;
911 default: ERR("Unexpected position mask\n");
913 for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++)
915 size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE);
918 return size;
921 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
923 /* 2 adds three additional caps fields to the end. Both versions
924 * are unversioned. */
925 pOut->dwCaps = pIn->dwCaps;
926 pOut->dwCaps2 = 0;
927 pOut->dwCaps3 = 0;
928 pOut->dwCaps4 = 0;
931 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, DDDEVICEIDENTIFIER* pOut)
933 /* 2 adds a dwWHQLLevel field to the end. Both structures are
934 * unversioned. */
935 memcpy(pOut, pIn, sizeof(*pOut));
938 void DDRAW_dump_cooperativelevel(DWORD cooplevel)
940 static const flag_info flags[] =
942 FE(DDSCL_FULLSCREEN),
943 FE(DDSCL_ALLOWREBOOT),
944 FE(DDSCL_NOWINDOWCHANGES),
945 FE(DDSCL_NORMAL),
946 FE(DDSCL_ALLOWMODEX),
947 FE(DDSCL_EXCLUSIVE),
948 FE(DDSCL_SETFOCUSWINDOW),
949 FE(DDSCL_SETDEVICEWINDOW),
950 FE(DDSCL_CREATEDEVICEWINDOW)
953 if (TRACE_ON(ddraw))
955 TRACE(" - ");
956 DDRAW_dump_flags(cooplevel, flags, sizeof(flags)/sizeof(flags[0]));
960 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps)
962 static const flag_info flags1[] =
964 FE(DDCAPS_3D),
965 FE(DDCAPS_ALIGNBOUNDARYDEST),
966 FE(DDCAPS_ALIGNSIZEDEST),
967 FE(DDCAPS_ALIGNBOUNDARYSRC),
968 FE(DDCAPS_ALIGNSIZESRC),
969 FE(DDCAPS_ALIGNSTRIDE),
970 FE(DDCAPS_BLT),
971 FE(DDCAPS_BLTQUEUE),
972 FE(DDCAPS_BLTFOURCC),
973 FE(DDCAPS_BLTSTRETCH),
974 FE(DDCAPS_GDI),
975 FE(DDCAPS_OVERLAY),
976 FE(DDCAPS_OVERLAYCANTCLIP),
977 FE(DDCAPS_OVERLAYFOURCC),
978 FE(DDCAPS_OVERLAYSTRETCH),
979 FE(DDCAPS_PALETTE),
980 FE(DDCAPS_PALETTEVSYNC),
981 FE(DDCAPS_READSCANLINE),
982 FE(DDCAPS_STEREOVIEW),
983 FE(DDCAPS_VBI),
984 FE(DDCAPS_ZBLTS),
985 FE(DDCAPS_ZOVERLAYS),
986 FE(DDCAPS_COLORKEY),
987 FE(DDCAPS_ALPHA),
988 FE(DDCAPS_COLORKEYHWASSIST),
989 FE(DDCAPS_NOHARDWARE),
990 FE(DDCAPS_BLTCOLORFILL),
991 FE(DDCAPS_BANKSWITCHED),
992 FE(DDCAPS_BLTDEPTHFILL),
993 FE(DDCAPS_CANCLIP),
994 FE(DDCAPS_CANCLIPSTRETCHED),
995 FE(DDCAPS_CANBLTSYSMEM)
997 static const flag_info flags2[] =
999 FE(DDCAPS2_CERTIFIED),
1000 FE(DDCAPS2_NO2DDURING3DSCENE),
1001 FE(DDCAPS2_VIDEOPORT),
1002 FE(DDCAPS2_AUTOFLIPOVERLAY),
1003 FE(DDCAPS2_CANBOBINTERLEAVED),
1004 FE(DDCAPS2_CANBOBNONINTERLEAVED),
1005 FE(DDCAPS2_COLORCONTROLOVERLAY),
1006 FE(DDCAPS2_COLORCONTROLPRIMARY),
1007 FE(DDCAPS2_CANDROPZ16BIT),
1008 FE(DDCAPS2_NONLOCALVIDMEM),
1009 FE(DDCAPS2_NONLOCALVIDMEMCAPS),
1010 FE(DDCAPS2_NOPAGELOCKREQUIRED),
1011 FE(DDCAPS2_WIDESURFACES),
1012 FE(DDCAPS2_CANFLIPODDEVEN),
1013 FE(DDCAPS2_CANBOBHARDWARE),
1014 FE(DDCAPS2_COPYFOURCC),
1015 FE(DDCAPS2_PRIMARYGAMMA),
1016 FE(DDCAPS2_CANRENDERWINDOWED),
1017 FE(DDCAPS2_CANCALIBRATEGAMMA),
1018 FE(DDCAPS2_FLIPINTERVAL),
1019 FE(DDCAPS2_FLIPNOVSYNC),
1020 FE(DDCAPS2_CANMANAGETEXTURE),
1021 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM),
1022 FE(DDCAPS2_STEREO),
1023 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL)
1025 static const flag_info flags3[] =
1027 FE(DDCKEYCAPS_DESTBLT),
1028 FE(DDCKEYCAPS_DESTBLTCLRSPACE),
1029 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV),
1030 FE(DDCKEYCAPS_DESTBLTYUV),
1031 FE(DDCKEYCAPS_DESTOVERLAY),
1032 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE),
1033 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV),
1034 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE),
1035 FE(DDCKEYCAPS_DESTOVERLAYYUV),
1036 FE(DDCKEYCAPS_SRCBLT),
1037 FE(DDCKEYCAPS_SRCBLTCLRSPACE),
1038 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV),
1039 FE(DDCKEYCAPS_SRCBLTYUV),
1040 FE(DDCKEYCAPS_SRCOVERLAY),
1041 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE),
1042 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV),
1043 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE),
1044 FE(DDCKEYCAPS_SRCOVERLAYYUV),
1045 FE(DDCKEYCAPS_NOCOSTOVERLAY)
1047 static const flag_info flags4[] =
1049 FE(DDFXCAPS_BLTALPHA),
1050 FE(DDFXCAPS_OVERLAYALPHA),
1051 FE(DDFXCAPS_BLTARITHSTRETCHYN),
1052 FE(DDFXCAPS_BLTARITHSTRETCHY),
1053 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT),
1054 FE(DDFXCAPS_BLTMIRRORUPDOWN),
1055 FE(DDFXCAPS_BLTROTATION),
1056 FE(DDFXCAPS_BLTROTATION90),
1057 FE(DDFXCAPS_BLTSHRINKX),
1058 FE(DDFXCAPS_BLTSHRINKXN),
1059 FE(DDFXCAPS_BLTSHRINKY),
1060 FE(DDFXCAPS_BLTSHRINKYN),
1061 FE(DDFXCAPS_BLTSTRETCHX),
1062 FE(DDFXCAPS_BLTSTRETCHXN),
1063 FE(DDFXCAPS_BLTSTRETCHY),
1064 FE(DDFXCAPS_BLTSTRETCHYN),
1065 FE(DDFXCAPS_OVERLAYARITHSTRETCHY),
1066 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN),
1067 FE(DDFXCAPS_OVERLAYSHRINKX),
1068 FE(DDFXCAPS_OVERLAYSHRINKXN),
1069 FE(DDFXCAPS_OVERLAYSHRINKY),
1070 FE(DDFXCAPS_OVERLAYSHRINKYN),
1071 FE(DDFXCAPS_OVERLAYSTRETCHX),
1072 FE(DDFXCAPS_OVERLAYSTRETCHXN),
1073 FE(DDFXCAPS_OVERLAYSTRETCHY),
1074 FE(DDFXCAPS_OVERLAYSTRETCHYN),
1075 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT),
1076 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN)
1078 static const flag_info flags5[] =
1080 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND),
1081 FE(DDFXALPHACAPS_BLTALPHAPIXELS),
1082 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG),
1083 FE(DDFXALPHACAPS_BLTALPHASURFACES),
1084 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG),
1085 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND),
1086 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS),
1087 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG),
1088 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES),
1089 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG)
1091 static const flag_info flags6[] =
1093 FE(DDPCAPS_4BIT),
1094 FE(DDPCAPS_8BITENTRIES),
1095 FE(DDPCAPS_8BIT),
1096 FE(DDPCAPS_INITIALIZE),
1097 FE(DDPCAPS_PRIMARYSURFACE),
1098 FE(DDPCAPS_PRIMARYSURFACELEFT),
1099 FE(DDPCAPS_ALLOW256),
1100 FE(DDPCAPS_VSYNC),
1101 FE(DDPCAPS_1BIT),
1102 FE(DDPCAPS_2BIT),
1103 FE(DDPCAPS_ALPHA),
1105 static const flag_info flags7[] =
1107 FE(DDSVCAPS_RESERVED1),
1108 FE(DDSVCAPS_RESERVED2),
1109 FE(DDSVCAPS_RESERVED3),
1110 FE(DDSVCAPS_RESERVED4),
1111 FE(DDSVCAPS_STEREOSEQUENTIAL),
1114 TRACE(" - dwSize : %d\n", lpcaps->dwSize);
1115 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps->dwCaps, flags1, sizeof(flags1)/sizeof(flags1[0]));
1116 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
1117 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps->dwCKeyCaps, flags3, sizeof(flags3)/sizeof(flags3[0]));
1118 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps->dwFXCaps, flags4, sizeof(flags4)/sizeof(flags4[0]));
1119 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps->dwFXAlphaCaps, flags5, sizeof(flags5)/sizeof(flags5[0]));
1120 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps->dwPalCaps, flags6, sizeof(flags6)/sizeof(flags6[0]));
1121 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps->dwSVCaps, flags7, sizeof(flags7)/sizeof(flags7[0]));
1122 TRACE("...\n");
1123 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps->dwNumFourCCCodes);
1124 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps->dwCurrVisibleOverlays);
1125 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps->dwMinOverlayStretch);
1126 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps->dwMaxOverlayStretch);
1127 TRACE("...\n");
1128 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps->ddsCaps);
1131 /*****************************************************************************
1132 * multiply_matrix
1134 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1136 * Params:
1137 * dest: Pointer to the destination matrix
1138 * src1: Pointer to the first source matrix
1139 * src2: Pointer to the second source matrix
1141 *****************************************************************************/
1142 void
1143 multiply_matrix(D3DMATRIX *dest,
1144 const D3DMATRIX *src1,
1145 const D3DMATRIX *src2)
1147 D3DMATRIX temp;
1149 /* Now do the multiplication 'by hand'.
1150 I know that all this could be optimised, but this will be done later :-) */
1151 temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
1152 temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
1153 temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
1154 temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
1156 temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
1157 temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
1158 temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
1159 temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
1161 temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
1162 temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
1163 temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
1164 temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
1166 temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
1167 temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
1168 temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
1169 temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
1171 /* And copy the new matrix in the good storage.. */
1172 memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
1175 HRESULT
1176 hr_ddraw_from_wined3d(HRESULT hr)
1178 switch(hr)
1180 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
1181 default: return hr;