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
26 #define NONAMELESSUNION
28 #include "ddraw_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
33 static void DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf);
35 /*****************************************************************************
36 * PixelFormat_WineD3DtoDD
38 * Converts an WINED3DFORMAT value into a DDPIXELFORMAT structure
41 * DDPixelFormat: Address of the structure to write the pixel format to
42 * WineD3DFormat: Source format
44 *****************************************************************************/
46 PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat,
47 WINED3DFORMAT WineD3DFormat)
49 DWORD Size = DDPixelFormat->dwSize;
50 TRACE("Converting WINED3DFORMAT %d to DDRAW\n", WineD3DFormat);
54 memset(DDPixelFormat, 0x00, Size);
55 DDPixelFormat->dwSize = Size;
58 case WINED3DFMT_B8G8R8_UNORM:
59 DDPixelFormat->dwFlags = DDPF_RGB;
60 DDPixelFormat->dwFourCC = 0;
61 DDPixelFormat->u1.dwRGBBitCount = 24;
62 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
63 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
64 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
65 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
68 case WINED3DFMT_B8G8R8A8_UNORM:
69 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
70 DDPixelFormat->dwFourCC = 0;
71 DDPixelFormat->u1.dwRGBBitCount = 32;
72 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
73 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
74 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
75 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xff000000;
78 case WINED3DFMT_B8G8R8X8_UNORM:
79 DDPixelFormat->dwFlags = DDPF_RGB;
80 DDPixelFormat->dwFourCC = 0;
81 DDPixelFormat->u1.dwRGBBitCount = 32;
82 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
83 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
84 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
85 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
88 case WINED3DFMT_R8G8B8X8_UNORM:
89 DDPixelFormat->dwFlags = DDPF_RGB;
90 DDPixelFormat->dwFourCC = 0;
91 DDPixelFormat->u1.dwRGBBitCount = 32;
92 DDPixelFormat->u2.dwRBitMask = 0x000000ff;
93 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
94 DDPixelFormat->u4.dwBBitMask = 0x00ff0000;
95 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
98 case WINED3DFMT_B5G6R5_UNORM:
99 DDPixelFormat->dwFlags = DDPF_RGB;
100 DDPixelFormat->dwFourCC = 0;
101 DDPixelFormat->u1.dwRGBBitCount = 16;
102 DDPixelFormat->u2.dwRBitMask = 0xF800;
103 DDPixelFormat->u3.dwGBitMask = 0x07E0;
104 DDPixelFormat->u4.dwBBitMask = 0x001F;
105 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
108 case WINED3DFMT_B5G5R5X1_UNORM:
109 DDPixelFormat->dwFlags = DDPF_RGB;
110 DDPixelFormat->dwFourCC = 0;
111 DDPixelFormat->u1.dwRGBBitCount = 16;
112 DDPixelFormat->u2.dwRBitMask = 0x7C00;
113 DDPixelFormat->u3.dwGBitMask = 0x03E0;
114 DDPixelFormat->u4.dwBBitMask = 0x001F;
115 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
118 case WINED3DFMT_B5G5R5A1_UNORM:
119 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
120 DDPixelFormat->dwFourCC = 0;
121 DDPixelFormat->u1.dwRGBBitCount = 16;
122 DDPixelFormat->u2.dwRBitMask = 0x7C00;
123 DDPixelFormat->u3.dwGBitMask = 0x03E0;
124 DDPixelFormat->u4.dwBBitMask = 0x001F;
125 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x8000;
128 case WINED3DFMT_B4G4R4A4_UNORM:
129 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
130 DDPixelFormat->dwFourCC = 0;
131 DDPixelFormat->u1.dwRGBBitCount = 16;
132 DDPixelFormat->u2.dwRBitMask = 0x0F00;
133 DDPixelFormat->u3.dwGBitMask = 0x00F0;
134 DDPixelFormat->u4.dwBBitMask = 0x000F;
135 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
138 case WINED3DFMT_B2G3R3_UNORM:
139 DDPixelFormat->dwFlags = DDPF_RGB;
140 DDPixelFormat->dwFourCC = 0;
141 DDPixelFormat->u1.dwRGBBitCount = 8;
142 DDPixelFormat->u2.dwRBitMask = 0xE0;
143 DDPixelFormat->u3.dwGBitMask = 0x1C;
144 DDPixelFormat->u4.dwBBitMask = 0x03;
145 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
148 case WINED3DFMT_P8_UINT:
149 DDPixelFormat->dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
150 DDPixelFormat->dwFourCC = 0;
151 DDPixelFormat->u1.dwRGBBitCount = 8;
152 DDPixelFormat->u2.dwRBitMask = 0x00;
153 DDPixelFormat->u3.dwGBitMask = 0x00;
154 DDPixelFormat->u4.dwBBitMask = 0x00;
157 case WINED3DFMT_A8_UNORM:
158 DDPixelFormat->dwFlags = DDPF_ALPHA;
159 DDPixelFormat->dwFourCC = 0;
160 DDPixelFormat->u1.dwAlphaBitDepth = 8;
161 DDPixelFormat->u2.dwRBitMask = 0x0;
162 DDPixelFormat->u3.dwZBitMask = 0x0;
163 DDPixelFormat->u4.dwStencilBitMask = 0x0;
164 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
167 case WINED3DFMT_B2G3R3A8_UNORM:
168 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
169 DDPixelFormat->dwFourCC = 0;
170 DDPixelFormat->u1.dwRGBBitCount = 16;
171 DDPixelFormat->u2.dwRBitMask = 0x00E0;
172 DDPixelFormat->u3.dwGBitMask = 0x001C;
173 DDPixelFormat->u4.dwBBitMask = 0x0003;
174 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
177 case WINED3DFMT_B4G4R4X4_UNORM:
178 DDPixelFormat->dwFlags = DDPF_RGB;
179 DDPixelFormat->dwFourCC = 0;
180 DDPixelFormat->u1.dwRGBBitCount = 16;
181 DDPixelFormat->u2.dwRBitMask = 0x0F00;
182 DDPixelFormat->u3.dwGBitMask = 0x00F0;
183 DDPixelFormat->u4.dwBBitMask = 0x000F;
184 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
187 /* How are Z buffer bit depth and Stencil buffer bit depth related?
189 case WINED3DFMT_D16_UNORM:
190 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
191 DDPixelFormat->dwFourCC = 0;
192 DDPixelFormat->u1.dwZBufferBitDepth = 16;
193 DDPixelFormat->u2.dwStencilBitDepth = 0;
194 DDPixelFormat->u3.dwZBitMask = 0x0000FFFF;
195 DDPixelFormat->u4.dwStencilBitMask = 0x0;
196 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
199 case WINED3DFMT_D32_UNORM:
200 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
201 DDPixelFormat->dwFourCC = 0;
202 DDPixelFormat->u1.dwZBufferBitDepth = 32;
203 DDPixelFormat->u2.dwStencilBitDepth = 0;
204 DDPixelFormat->u3.dwZBitMask = 0xFFFFFFFF;
205 DDPixelFormat->u4.dwStencilBitMask = 0x0;
206 DDPixelFormat->u5.dwRGBZBitMask = 0x00000000;
209 case WINED3DFMT_S4X4_UINT_D24_UNORM:
210 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
211 DDPixelFormat->dwFourCC = 0;
212 /* Should I set dwZBufferBitDepth to 32 here? */
213 DDPixelFormat->u1.dwZBufferBitDepth = 32;
214 DDPixelFormat->u2.dwStencilBitDepth = 4;
215 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFF;
216 DDPixelFormat->u4.dwStencilBitMask = 0x0F000000;
217 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
220 case WINED3DFMT_D24_UNORM_S8_UINT:
221 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
222 DDPixelFormat->dwFourCC = 0;
223 /* Should I set dwZBufferBitDepth to 32 here? */
224 DDPixelFormat->u1.dwZBufferBitDepth = 32;
225 DDPixelFormat->u2.dwStencilBitDepth = 8;
226 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
227 DDPixelFormat->u4.dwStencilBitMask = 0xFF000000;
228 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
231 case WINED3DFMT_X8D24_UNORM:
232 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
233 DDPixelFormat->dwFourCC = 0;
234 DDPixelFormat->u1.dwZBufferBitDepth = 32;
235 DDPixelFormat->u2.dwStencilBitDepth = 0;
236 DDPixelFormat->u3.dwZBitMask = 0x00FFFFFFFF;
237 DDPixelFormat->u4.dwStencilBitMask = 0x00000000;
238 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
241 case WINED3DFMT_S1_UINT_D15_UNORM:
242 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
243 DDPixelFormat->dwFourCC = 0;
244 DDPixelFormat->u1.dwZBufferBitDepth = 16;
245 DDPixelFormat->u2.dwStencilBitDepth = 1;
246 DDPixelFormat->u3.dwZBitMask = 0x7fff;
247 DDPixelFormat->u4.dwStencilBitMask = 0x8000;
248 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
251 case WINED3DFMT_UYVY:
252 case WINED3DFMT_YUY2:
253 DDPixelFormat->u1.dwYUVBitCount = 16;
254 DDPixelFormat->dwFlags = DDPF_FOURCC;
255 DDPixelFormat->dwFourCC = WineD3DFormat;
258 case WINED3DFMT_YV12:
259 DDPixelFormat->u1.dwYUVBitCount = 12;
260 DDPixelFormat->dwFlags = DDPF_FOURCC;
261 DDPixelFormat->dwFourCC = WineD3DFormat;
264 case WINED3DFMT_DXT1:
265 case WINED3DFMT_DXT2:
266 case WINED3DFMT_DXT3:
267 case WINED3DFMT_DXT4:
268 case WINED3DFMT_DXT5:
269 case WINED3DFMT_MULTI2_ARGB8:
270 case WINED3DFMT_G8R8_G8B8:
271 case WINED3DFMT_R8G8_B8G8:
272 DDPixelFormat->dwFlags = DDPF_FOURCC;
273 DDPixelFormat->dwFourCC = WineD3DFormat;
277 case WINED3DFMT_L8_UNORM:
278 DDPixelFormat->dwFlags = DDPF_LUMINANCE;
279 DDPixelFormat->dwFourCC = 0;
280 DDPixelFormat->u1.dwLuminanceBitCount = 8;
281 DDPixelFormat->u2.dwLuminanceBitMask = 0xff;
282 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
283 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
284 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
287 case WINED3DFMT_L4A4_UNORM:
288 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
289 DDPixelFormat->dwFourCC = 0;
290 DDPixelFormat->u1.dwLuminanceBitCount = 4;
291 DDPixelFormat->u2.dwLuminanceBitMask = 0x0f;
292 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
293 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
294 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xf0;
297 case WINED3DFMT_L8A8_UNORM:
298 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
299 DDPixelFormat->dwFourCC = 0;
300 DDPixelFormat->u1.dwLuminanceBitCount = 16;
301 DDPixelFormat->u2.dwLuminanceBitMask = 0x00ff;
302 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
303 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
304 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xff00;
308 case WINED3DFMT_R8G8_SNORM:
309 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
310 DDPixelFormat->dwFourCC = 0;
311 DDPixelFormat->u1.dwBumpBitCount = 16;
312 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
313 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
314 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00000000;
315 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
318 case WINED3DFMT_R5G5_SNORM_L6_UNORM:
319 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
320 DDPixelFormat->dwFourCC = 0;
321 DDPixelFormat->u1.dwBumpBitCount = 16;
322 DDPixelFormat->u2.dwBumpDuBitMask = 0x0000001f;
323 DDPixelFormat->u3.dwBumpDvBitMask = 0x000003e0;
324 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0000fc00;
325 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
328 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
329 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
330 DDPixelFormat->dwFourCC = 0;
331 DDPixelFormat->u1.dwBumpBitCount = 32;
332 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
333 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
334 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00ff0000;
335 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
339 ERR("Can't translate this Pixelformat %d\n", WineD3DFormat);
342 if(TRACE_ON(ddraw)) {
343 TRACE("Returning: ");
344 DDRAW_dump_pixelformat(DDPixelFormat);
347 /*****************************************************************************
348 * PixelFormat_DD2WineD3D
350 * Reads a DDPIXELFORMAT structure and returns the equal WINED3DFORMAT
353 * DDPixelFormat: The source format
356 * The WINED3DFORMAT equal to the DDraw format
357 * WINED3DFMT_UNKNOWN if a matching format wasn't found
358 *****************************************************************************/
360 PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat)
362 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
365 DDRAW_dump_pixelformat(DDPixelFormat);
368 if(DDPixelFormat->dwFlags & DDPF_PALETTEINDEXED8)
370 return WINED3DFMT_P8_UINT;
372 else if(DDPixelFormat->dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4) )
374 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
375 return WINED3DFMT_P8_UINT;
377 else if(DDPixelFormat->dwFlags & DDPF_RGB)
379 switch(DDPixelFormat->u1.dwRGBBitCount)
382 /* This is the only format that can match here */
383 return WINED3DFMT_B2G3R3_UNORM;
386 /* Read the Color masks */
387 if( (DDPixelFormat->u2.dwRBitMask == 0xF800) &&
388 (DDPixelFormat->u3.dwGBitMask == 0x07E0) &&
389 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
391 return WINED3DFMT_B5G6R5_UNORM;
394 if( (DDPixelFormat->u2.dwRBitMask == 0x7C00) &&
395 (DDPixelFormat->u3.dwGBitMask == 0x03E0) &&
396 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
398 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
399 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0x8000))
400 return WINED3DFMT_B5G5R5A1_UNORM;
402 return WINED3DFMT_B5G5R5X1_UNORM;
405 if( (DDPixelFormat->u2.dwRBitMask == 0x0F00) &&
406 (DDPixelFormat->u3.dwGBitMask == 0x00F0) &&
407 (DDPixelFormat->u4.dwBBitMask == 0x000F) )
409 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
410 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xF000))
411 return WINED3DFMT_B4G4R4A4_UNORM;
413 return WINED3DFMT_B4G4R4X4_UNORM;
416 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
417 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF00) &&
418 (DDPixelFormat->u2.dwRBitMask == 0x00E0) &&
419 (DDPixelFormat->u3.dwGBitMask == 0x001C) &&
420 (DDPixelFormat->u4.dwBBitMask == 0x0003) )
422 return WINED3DFMT_B2G3R3A8_UNORM;
424 ERR("16 bit RGB Pixel format does not match\n");
425 return WINED3DFMT_UNKNOWN;
428 return WINED3DFMT_B8G8R8_UNORM;
431 /* Read the Color masks */
432 if( (DDPixelFormat->u2.dwRBitMask == 0x00FF0000) &&
433 (DDPixelFormat->u3.dwGBitMask == 0x0000FF00) &&
434 (DDPixelFormat->u4.dwBBitMask == 0x000000FF) )
436 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
437 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF000000))
438 return WINED3DFMT_B8G8R8A8_UNORM;
440 return WINED3DFMT_B8G8R8X8_UNORM;
443 ERR("32 bit RGB pixel format does not match\n");
446 ERR("Invalid dwRGBBitCount in Pixelformat structure\n");
447 return WINED3DFMT_UNKNOWN;
450 else if( (DDPixelFormat->dwFlags & DDPF_ALPHA) )
452 /* Alpha only Pixelformat */
453 switch(DDPixelFormat->u1.dwAlphaBitDepth)
458 ERR("Unsupported Alpha-Only bit depth 0x%x\n", DDPixelFormat->u1.dwAlphaBitDepth);
460 return WINED3DFMT_A8_UNORM;
463 ERR("Invalid AlphaBitDepth in Alpha-Only Pixelformat\n");
464 return WINED3DFMT_UNKNOWN;
467 else if(DDPixelFormat->dwFlags & DDPF_LUMINANCE)
469 /* Luminance-only or luminance-alpha */
470 if(DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS)
472 /* Luminance with Alpha */
473 switch(DDPixelFormat->u1.dwLuminanceBitCount)
476 if(DDPixelFormat->u1.dwAlphaBitDepth == 4)
477 return WINED3DFMT_L4A4_UNORM;
478 ERR("Unknown Alpha / Luminance bit depth combination\n");
479 return WINED3DFMT_UNKNOWN;
482 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
483 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
486 if(DDPixelFormat->u1.dwAlphaBitDepth == 8)
487 return WINED3DFMT_L8A8_UNORM;
488 ERR("Unknown Alpha / Lumincase bit depth combination\n");
489 return WINED3DFMT_UNKNOWN;
495 switch(DDPixelFormat->u1.dwLuminanceBitCount)
498 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
499 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
502 return WINED3DFMT_L8_UNORM;
505 ERR("Unknown luminance-only bit depth 0x%x\n", DDPixelFormat->u1.dwLuminanceBitCount);
506 return WINED3DFMT_UNKNOWN;
510 else if(DDPixelFormat->dwFlags & DDPF_ZBUFFER)
513 if(DDPixelFormat->dwFlags & DDPF_STENCILBUFFER)
515 switch(DDPixelFormat->u1.dwZBufferBitDepth)
518 FIXME("8 Bits Z+Stencil buffer pixelformat is not supported. Returning WINED3DFMT_UNKNOWN\n");
519 return WINED3DFMT_UNKNOWN;
522 FIXME("15 bit depth buffer not handled yet, assuming 16 bit\n");
524 if(DDPixelFormat->u2.dwStencilBitDepth == 1)
525 return WINED3DFMT_S1_UINT_D15_UNORM;
527 FIXME("Don't know how to handle a 16 bit Z buffer with %d bit stencil buffer pixelformat\n", DDPixelFormat->u2.dwStencilBitDepth);
528 return WINED3DFMT_UNKNOWN;
531 FIXME("Don't know how to handle a 24 bit depth buffer with stencil bits\n");
532 return WINED3DFMT_D24_UNORM_S8_UINT;
535 if(DDPixelFormat->u2.dwStencilBitDepth == 8)
536 return WINED3DFMT_D24_UNORM_S8_UINT;
538 return WINED3DFMT_S4X4_UINT_D24_UNORM;
541 ERR("Unknown Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
542 return WINED3DFMT_UNKNOWN;
547 switch(DDPixelFormat->u1.dwZBufferBitDepth)
550 ERR("8 Bit Z buffers are not supported. Trying a 16 Bit one\n");
551 return WINED3DFMT_D16_UNORM;
554 return WINED3DFMT_D16_UNORM;
557 FIXME("24 Bit depth buffer, treating like a 32 bit one\n");
559 if(DDPixelFormat->u3.dwZBitMask == 0x00FFFFFF) {
560 return WINED3DFMT_X8D24_UNORM;
561 } else if(DDPixelFormat->u3.dwZBitMask == 0xFFFFFFFF) {
562 return WINED3DFMT_D32_UNORM;
564 FIXME("Unhandled 32 bit depth buffer bitmasks, returning WINED3DFMT_D24X8\n");
565 return WINED3DFMT_X8D24_UNORM; /* That's most likely to make games happy */
568 ERR("Unsupported Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
569 return WINED3DFMT_UNKNOWN;
573 else if(DDPixelFormat->dwFlags & DDPF_FOURCC)
575 if(DDPixelFormat->dwFourCC == MAKEFOURCC('U', 'Y', 'V', 'Y'))
577 return WINED3DFMT_UYVY;
579 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'U', 'Y', '2'))
581 return WINED3DFMT_YUY2;
583 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'V', '1', '2'))
585 return WINED3DFMT_YV12;
587 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '1'))
589 return WINED3DFMT_DXT1;
591 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '2'))
593 return WINED3DFMT_DXT2;
595 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '3'))
597 return WINED3DFMT_DXT3;
599 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '4'))
601 return WINED3DFMT_DXT4;
603 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '5'))
605 return WINED3DFMT_DXT5;
607 if(DDPixelFormat->dwFourCC == MAKEFOURCC('G', 'R', 'G', 'B'))
609 return WINED3DFMT_G8R8_G8B8;
611 if(DDPixelFormat->dwFourCC == MAKEFOURCC('R', 'G', 'B', 'G'))
613 return WINED3DFMT_R8G8_B8G8;
615 return WINED3DFMT_UNKNOWN; /* Abuse this as an error value */
617 else if(DDPixelFormat->dwFlags & DDPF_BUMPDUDV)
619 if( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
620 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
621 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
622 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00000000) )
624 return WINED3DFMT_R8G8_SNORM;
626 else if ( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
627 (DDPixelFormat->u2.dwBumpDuBitMask == 0x0000001f) &&
628 (DDPixelFormat->u3.dwBumpDvBitMask == 0x000003e0) &&
629 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x0000fc00) )
631 return WINED3DFMT_R5G5_SNORM_L6_UNORM;
633 else if ( (DDPixelFormat->u1.dwBumpBitCount == 32 ) &&
634 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
635 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
636 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00ff0000) )
638 return WINED3DFMT_R8G8_SNORM_L8X8_UNORM;
642 ERR("Unknown Pixelformat!\n");
643 return WINED3DFMT_UNKNOWN;
646 /*****************************************************************************
647 * Various dumping functions.
649 * They write the contents of a specific function to a TRACE.
651 *****************************************************************************/
653 DDRAW_dump_DWORD(const void *in)
655 TRACE("%d\n", *((const DWORD *) in));
658 DDRAW_dump_PTR(const void *in)
660 TRACE("%p\n", *((const void * const*) in));
663 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *ddck)
665 TRACE("Low : %d - High : %d\n", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
668 static void DDRAW_dump_flags_nolf(DWORD flags, const flag_info* names,
673 for (i=0; i < num_names; i++)
674 if ((flags & names[i].val) || /* standard flag value */
675 ((!flags) && (!names[i].val))) /* zero value only */
676 TRACE("%s ", names[i].name);
679 static void DDRAW_dump_flags(DWORD flags, const flag_info* names, size_t num_names)
681 DDRAW_dump_flags_nolf(flags, names, num_names);
685 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in)
687 static const flag_info flags[] = {
688 FE(DDSCAPS_RESERVED1),
690 FE(DDSCAPS_BACKBUFFER),
693 FE(DDSCAPS_FRONTBUFFER),
694 FE(DDSCAPS_OFFSCREENPLAIN),
697 FE(DDSCAPS_PRIMARYSURFACE),
698 FE(DDSCAPS_PRIMARYSURFACELEFT),
699 FE(DDSCAPS_SYSTEMMEMORY),
701 FE(DDSCAPS_3DDEVICE),
702 FE(DDSCAPS_VIDEOMEMORY),
704 FE(DDSCAPS_WRITEONLY),
707 FE(DDSCAPS_LIVEVIDEO),
711 FE(DDSCAPS_RESERVED2),
712 FE(DDSCAPS_ALLOCONLOAD),
713 FE(DDSCAPS_VIDEOPORT),
714 FE(DDSCAPS_LOCALVIDMEM),
715 FE(DDSCAPS_NONLOCALVIDMEM),
716 FE(DDSCAPS_STANDARDVGAMODE),
717 FE(DDSCAPS_OPTIMIZED)
719 static const flag_info flags2[] = {
720 FE(DDSCAPS2_HARDWAREDEINTERLACE),
721 FE(DDSCAPS2_HINTDYNAMIC),
722 FE(DDSCAPS2_HINTSTATIC),
723 FE(DDSCAPS2_TEXTUREMANAGE),
724 FE(DDSCAPS2_RESERVED1),
725 FE(DDSCAPS2_RESERVED2),
727 FE(DDSCAPS2_HINTANTIALIASING),
728 FE(DDSCAPS2_CUBEMAP),
729 FE(DDSCAPS2_CUBEMAP_POSITIVEX),
730 FE(DDSCAPS2_CUBEMAP_NEGATIVEX),
731 FE(DDSCAPS2_CUBEMAP_POSITIVEY),
732 FE(DDSCAPS2_CUBEMAP_NEGATIVEY),
733 FE(DDSCAPS2_CUBEMAP_POSITIVEZ),
734 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ),
735 FE(DDSCAPS2_MIPMAPSUBLEVEL),
736 FE(DDSCAPS2_D3DTEXTUREMANAGE),
737 FE(DDSCAPS2_DONOTPERSIST),
738 FE(DDSCAPS2_STEREOSURFACELEFT)
741 DDRAW_dump_flags_nolf(in->dwCaps, flags, sizeof(flags)/sizeof(flags[0]));
742 DDRAW_dump_flags(in->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
746 DDRAW_dump_DDSCAPS(const DDSCAPS *in)
750 in_bis.dwCaps = in->dwCaps;
755 DDRAW_dump_DDSCAPS2(&in_bis);
759 DDRAW_dump_pixelformat_flag(DWORD flagmask)
761 static const flag_info flags[] =
763 FE(DDPF_ALPHAPIXELS),
766 FE(DDPF_PALETTEINDEXED4),
767 FE(DDPF_PALETTEINDEXEDTO8),
768 FE(DDPF_PALETTEINDEXED8),
774 FE(DDPF_PALETTEINDEXED1),
775 FE(DDPF_PALETTEINDEXED2),
779 DDRAW_dump_flags_nolf(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
783 DDRAW_dump_members(DWORD flags,
785 const member_info* mems,
790 for (i=0; i < num_mems; i++)
792 if (mems[i].val & flags)
794 TRACE(" - %s : ", mems[i].name);
795 mems[i].func((const char *)data + mems[i].offset);
801 DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf)
804 DDRAW_dump_pixelformat_flag(pf->dwFlags);
805 if (pf->dwFlags & DDPF_FOURCC)
807 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
808 (unsigned char)( pf->dwFourCC &0xff),
809 (unsigned char)((pf->dwFourCC>> 8)&0xff),
810 (unsigned char)((pf->dwFourCC>>16)&0xff),
811 (unsigned char)((pf->dwFourCC>>24)&0xff),
816 if (pf->dwFlags & DDPF_RGB)
819 TRACE(", RGB bits: %d, ", pf->u1.dwRGBBitCount);
820 switch (pf->u1.dwRGBBitCount)
822 case 4: cmd = "%1lx"; break;
823 case 8: cmd = "%02lx"; break;
824 case 16: cmd = "%04lx"; break;
825 case 24: cmd = "%06lx"; break;
826 case 32: cmd = "%08lx"; break;
827 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
829 TRACE(" R "); TRACE(cmd, pf->u2.dwRBitMask);
830 TRACE(" G "); TRACE(cmd, pf->u3.dwGBitMask);
831 TRACE(" B "); TRACE(cmd, pf->u4.dwBBitMask);
832 if (pf->dwFlags & DDPF_ALPHAPIXELS)
834 TRACE(" A "); TRACE(cmd, pf->u5.dwRGBAlphaBitMask);
836 if (pf->dwFlags & DDPF_ZPIXELS)
838 TRACE(" Z "); TRACE(cmd, pf->u5.dwRGBZBitMask);
841 if (pf->dwFlags & DDPF_ZBUFFER)
843 TRACE(", Z bits : %d", pf->u1.dwZBufferBitDepth);
845 if (pf->dwFlags & DDPF_ALPHA)
847 TRACE(", Alpha bits : %d", pf->u1.dwAlphaBitDepth);
849 if (pf->dwFlags & DDPF_BUMPDUDV)
851 const char *cmd = "%08lx";
852 TRACE(", Bump bits: %d, ", pf->u1.dwBumpBitCount);
853 TRACE(" U "); TRACE(cmd, pf->u2.dwBumpDuBitMask);
854 TRACE(" V "); TRACE(cmd, pf->u3.dwBumpDvBitMask);
855 TRACE(" L "); TRACE(cmd, pf->u4.dwBumpLuminanceBitMask);
860 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd)
862 #define STRUCT DDSURFACEDESC2
863 static const member_info members[] =
865 ME(DDSD_HEIGHT, DDRAW_dump_DWORD, dwHeight),
866 ME(DDSD_WIDTH, DDRAW_dump_DWORD, dwWidth),
867 ME(DDSD_PITCH, DDRAW_dump_DWORD, u1 /* lPitch */),
868 ME(DDSD_LINEARSIZE, DDRAW_dump_DWORD, u1 /* dwLinearSize */),
869 ME(DDSD_BACKBUFFERCOUNT, DDRAW_dump_DWORD, dwBackBufferCount),
870 ME(DDSD_MIPMAPCOUNT, DDRAW_dump_DWORD, u2 /* dwMipMapCount */),
871 ME(DDSD_ZBUFFERBITDEPTH, DDRAW_dump_DWORD, u2 /* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
872 ME(DDSD_REFRESHRATE, DDRAW_dump_DWORD, u2 /* dwRefreshRate */),
873 ME(DDSD_ALPHABITDEPTH, DDRAW_dump_DWORD, dwAlphaBitDepth),
874 ME(DDSD_LPSURFACE, DDRAW_dump_PTR, lpSurface),
875 ME(DDSD_CKDESTOVERLAY, DDRAW_dump_DDCOLORKEY, u3 /* ddckCKDestOverlay */),
876 ME(DDSD_CKDESTBLT, DDRAW_dump_DDCOLORKEY, ddckCKDestBlt),
877 ME(DDSD_CKSRCOVERLAY, DDRAW_dump_DDCOLORKEY, ddckCKSrcOverlay),
878 ME(DDSD_CKSRCBLT, DDRAW_dump_DDCOLORKEY, ddckCKSrcBlt),
879 ME(DDSD_PIXELFORMAT, DDRAW_dump_pixelformat, u4 /* ddpfPixelFormat */)
881 static const member_info members_caps[] =
883 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS, ddsCaps)
885 static const member_info members_caps2[] =
887 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS2, ddsCaps)
897 if (lpddsd->dwSize >= sizeof(DDSURFACEDESC2))
899 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps2, 1);
903 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps, 1);
905 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members,
906 sizeof(members)/sizeof(members[0]));
911 dump_D3DMATRIX(const D3DMATRIX *mat)
913 TRACE(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
914 TRACE(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
915 TRACE(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
916 TRACE(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
920 get_flexible_vertex_size(DWORD d3dvtVertexType)
925 if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
926 if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
927 if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
928 if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD);
929 switch (d3dvtVertexType & D3DFVF_POSITION_MASK)
931 case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
932 case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
933 case D3DFVF_XYZB1: size += 4 * sizeof(D3DVALUE); break;
934 case D3DFVF_XYZB2: size += 5 * sizeof(D3DVALUE); break;
935 case D3DFVF_XYZB3: size += 6 * sizeof(D3DVALUE); break;
936 case D3DFVF_XYZB4: size += 7 * sizeof(D3DVALUE); break;
937 case D3DFVF_XYZB5: size += 8 * sizeof(D3DVALUE); break;
938 default: ERR("Unexpected position mask\n");
940 for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++)
942 size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE);
948 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
950 /* 2 adds three additional caps fields to the end. Both versions
951 * are unversioned. */
952 pOut->dwCaps = pIn->dwCaps;
958 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, DDDEVICEIDENTIFIER* pOut)
960 /* 2 adds a dwWHQLLevel field to the end. Both structures are
962 memcpy(pOut, pIn, sizeof(*pOut));
965 void DDRAW_dump_cooperativelevel(DWORD cooplevel)
967 static const flag_info flags[] =
969 FE(DDSCL_FULLSCREEN),
970 FE(DDSCL_ALLOWREBOOT),
971 FE(DDSCL_NOWINDOWCHANGES),
973 FE(DDSCL_ALLOWMODEX),
975 FE(DDSCL_SETFOCUSWINDOW),
976 FE(DDSCL_SETDEVICEWINDOW),
977 FE(DDSCL_CREATEDEVICEWINDOW)
983 DDRAW_dump_flags(cooplevel, flags, sizeof(flags)/sizeof(flags[0]));
987 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps)
989 static const flag_info flags1[] =
992 FE(DDCAPS_ALIGNBOUNDARYDEST),
993 FE(DDCAPS_ALIGNSIZEDEST),
994 FE(DDCAPS_ALIGNBOUNDARYSRC),
995 FE(DDCAPS_ALIGNSIZESRC),
996 FE(DDCAPS_ALIGNSTRIDE),
999 FE(DDCAPS_BLTFOURCC),
1000 FE(DDCAPS_BLTSTRETCH),
1003 FE(DDCAPS_OVERLAYCANTCLIP),
1004 FE(DDCAPS_OVERLAYFOURCC),
1005 FE(DDCAPS_OVERLAYSTRETCH),
1007 FE(DDCAPS_PALETTEVSYNC),
1008 FE(DDCAPS_READSCANLINE),
1009 FE(DDCAPS_STEREOVIEW),
1012 FE(DDCAPS_ZOVERLAYS),
1013 FE(DDCAPS_COLORKEY),
1015 FE(DDCAPS_COLORKEYHWASSIST),
1016 FE(DDCAPS_NOHARDWARE),
1017 FE(DDCAPS_BLTCOLORFILL),
1018 FE(DDCAPS_BANKSWITCHED),
1019 FE(DDCAPS_BLTDEPTHFILL),
1021 FE(DDCAPS_CANCLIPSTRETCHED),
1022 FE(DDCAPS_CANBLTSYSMEM)
1024 static const flag_info flags2[] =
1026 FE(DDCAPS2_CERTIFIED),
1027 FE(DDCAPS2_NO2DDURING3DSCENE),
1028 FE(DDCAPS2_VIDEOPORT),
1029 FE(DDCAPS2_AUTOFLIPOVERLAY),
1030 FE(DDCAPS2_CANBOBINTERLEAVED),
1031 FE(DDCAPS2_CANBOBNONINTERLEAVED),
1032 FE(DDCAPS2_COLORCONTROLOVERLAY),
1033 FE(DDCAPS2_COLORCONTROLPRIMARY),
1034 FE(DDCAPS2_CANDROPZ16BIT),
1035 FE(DDCAPS2_NONLOCALVIDMEM),
1036 FE(DDCAPS2_NONLOCALVIDMEMCAPS),
1037 FE(DDCAPS2_NOPAGELOCKREQUIRED),
1038 FE(DDCAPS2_WIDESURFACES),
1039 FE(DDCAPS2_CANFLIPODDEVEN),
1040 FE(DDCAPS2_CANBOBHARDWARE),
1041 FE(DDCAPS2_COPYFOURCC),
1042 FE(DDCAPS2_PRIMARYGAMMA),
1043 FE(DDCAPS2_CANRENDERWINDOWED),
1044 FE(DDCAPS2_CANCALIBRATEGAMMA),
1045 FE(DDCAPS2_FLIPINTERVAL),
1046 FE(DDCAPS2_FLIPNOVSYNC),
1047 FE(DDCAPS2_CANMANAGETEXTURE),
1048 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM),
1050 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL)
1052 static const flag_info flags3[] =
1054 FE(DDCKEYCAPS_DESTBLT),
1055 FE(DDCKEYCAPS_DESTBLTCLRSPACE),
1056 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV),
1057 FE(DDCKEYCAPS_DESTBLTYUV),
1058 FE(DDCKEYCAPS_DESTOVERLAY),
1059 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE),
1060 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV),
1061 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE),
1062 FE(DDCKEYCAPS_DESTOVERLAYYUV),
1063 FE(DDCKEYCAPS_SRCBLT),
1064 FE(DDCKEYCAPS_SRCBLTCLRSPACE),
1065 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV),
1066 FE(DDCKEYCAPS_SRCBLTYUV),
1067 FE(DDCKEYCAPS_SRCOVERLAY),
1068 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE),
1069 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV),
1070 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE),
1071 FE(DDCKEYCAPS_SRCOVERLAYYUV),
1072 FE(DDCKEYCAPS_NOCOSTOVERLAY)
1074 static const flag_info flags4[] =
1076 FE(DDFXCAPS_BLTALPHA),
1077 FE(DDFXCAPS_OVERLAYALPHA),
1078 FE(DDFXCAPS_BLTARITHSTRETCHYN),
1079 FE(DDFXCAPS_BLTARITHSTRETCHY),
1080 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT),
1081 FE(DDFXCAPS_BLTMIRRORUPDOWN),
1082 FE(DDFXCAPS_BLTROTATION),
1083 FE(DDFXCAPS_BLTROTATION90),
1084 FE(DDFXCAPS_BLTSHRINKX),
1085 FE(DDFXCAPS_BLTSHRINKXN),
1086 FE(DDFXCAPS_BLTSHRINKY),
1087 FE(DDFXCAPS_BLTSHRINKYN),
1088 FE(DDFXCAPS_BLTSTRETCHX),
1089 FE(DDFXCAPS_BLTSTRETCHXN),
1090 FE(DDFXCAPS_BLTSTRETCHY),
1091 FE(DDFXCAPS_BLTSTRETCHYN),
1092 FE(DDFXCAPS_OVERLAYARITHSTRETCHY),
1093 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN),
1094 FE(DDFXCAPS_OVERLAYSHRINKX),
1095 FE(DDFXCAPS_OVERLAYSHRINKXN),
1096 FE(DDFXCAPS_OVERLAYSHRINKY),
1097 FE(DDFXCAPS_OVERLAYSHRINKYN),
1098 FE(DDFXCAPS_OVERLAYSTRETCHX),
1099 FE(DDFXCAPS_OVERLAYSTRETCHXN),
1100 FE(DDFXCAPS_OVERLAYSTRETCHY),
1101 FE(DDFXCAPS_OVERLAYSTRETCHYN),
1102 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT),
1103 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN)
1105 static const flag_info flags5[] =
1107 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND),
1108 FE(DDFXALPHACAPS_BLTALPHAPIXELS),
1109 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG),
1110 FE(DDFXALPHACAPS_BLTALPHASURFACES),
1111 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG),
1112 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND),
1113 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS),
1114 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG),
1115 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES),
1116 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG)
1118 static const flag_info flags6[] =
1121 FE(DDPCAPS_8BITENTRIES),
1123 FE(DDPCAPS_INITIALIZE),
1124 FE(DDPCAPS_PRIMARYSURFACE),
1125 FE(DDPCAPS_PRIMARYSURFACELEFT),
1126 FE(DDPCAPS_ALLOW256),
1132 static const flag_info flags7[] =
1134 FE(DDSVCAPS_RESERVED1),
1135 FE(DDSVCAPS_RESERVED2),
1136 FE(DDSVCAPS_RESERVED3),
1137 FE(DDSVCAPS_RESERVED4),
1138 FE(DDSVCAPS_STEREOSEQUENTIAL),
1141 TRACE(" - dwSize : %d\n", lpcaps->dwSize);
1142 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps->dwCaps, flags1, sizeof(flags1)/sizeof(flags1[0]));
1143 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
1144 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps->dwCKeyCaps, flags3, sizeof(flags3)/sizeof(flags3[0]));
1145 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps->dwFXCaps, flags4, sizeof(flags4)/sizeof(flags4[0]));
1146 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps->dwFXAlphaCaps, flags5, sizeof(flags5)/sizeof(flags5[0]));
1147 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps->dwPalCaps, flags6, sizeof(flags6)/sizeof(flags6[0]));
1148 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps->dwSVCaps, flags7, sizeof(flags7)/sizeof(flags7[0]));
1150 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps->dwNumFourCCCodes);
1151 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps->dwCurrVisibleOverlays);
1152 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps->dwMinOverlayStretch);
1153 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps->dwMaxOverlayStretch);
1155 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps->ddsCaps);
1158 /*****************************************************************************
1161 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1164 * dest: Pointer to the destination matrix
1165 * src1: Pointer to the first source matrix
1166 * src2: Pointer to the second source matrix
1168 *****************************************************************************/
1170 multiply_matrix(D3DMATRIX *dest,
1171 const D3DMATRIX *src1,
1172 const D3DMATRIX *src2)
1176 /* Now do the multiplication 'by hand'.
1177 I know that all this could be optimised, but this will be done later :-) */
1178 temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
1179 temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
1180 temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
1181 temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
1183 temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
1184 temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
1185 temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
1186 temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
1188 temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
1189 temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
1190 temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
1191 temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
1193 temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
1194 temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
1195 temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
1196 temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
1198 /* And copy the new matrix in the good storage.. */
1199 memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
1202 void multiply_matrix_D3D_way(D3DMATRIX* result, const D3DMATRIX *m1, const D3DMATRIX *m2)
1206 temp._11 = m1->_11 * m2->_11 + m1->_12 * m2->_21 + m1->_13 * m2->_31 + m1->_14 * m2->_41;
1207 temp._12 = m1->_11 * m2->_12 + m1->_12 * m2->_22 + m1->_13 * m2->_32 + m1->_14 * m2->_42;
1208 temp._13 = m1->_11 * m2->_13 + m1->_12 * m2->_23 + m1->_13 * m2->_33 + m1->_14 * m2->_43;
1209 temp._14 = m1->_11 * m2->_14 + m1->_12 * m2->_24 + m1->_13 * m2->_34 + m1->_14 * m2->_44;
1210 temp._21 = m1->_21 * m2->_11 + m1->_22 * m2->_21 + m1->_23 * m2->_31 + m1->_24 * m2->_41;
1211 temp._22 = m1->_21 * m2->_12 + m1->_22 * m2->_22 + m1->_23 * m2->_32 + m1->_24 * m2->_42;
1212 temp._23 = m1->_21 * m2->_13 + m1->_22 * m2->_23 + m1->_23 * m2->_33 + m1->_24 * m2->_43;
1213 temp._24 = m1->_21 * m2->_14 + m1->_22 * m2->_24 + m1->_23 * m2->_34 + m1->_24 * m2->_44;
1214 temp._31 = m1->_31 * m2->_11 + m1->_32 * m2->_21 + m1->_33 * m2->_31 + m1->_34 * m2->_41;
1215 temp._32 = m1->_31 * m2->_12 + m1->_32 * m2->_22 + m1->_33 * m2->_32 + m1->_34 * m2->_42;
1216 temp._33 = m1->_31 * m2->_13 + m1->_32 * m2->_23 + m1->_33 * m2->_33 + m1->_34 * m2->_43;
1217 temp._34 = m1->_31 * m2->_14 + m1->_32 * m2->_24 + m1->_33 * m2->_34 + m1->_34 * m2->_44;
1218 temp._41 = m1->_41 * m2->_11 + m1->_42 * m2->_21 + m1->_43 * m2->_31 + m1->_44 * m2->_41;
1219 temp._42 = m1->_41 * m2->_12 + m1->_42 * m2->_22 + m1->_43 * m2->_32 + m1->_44 * m2->_42;
1220 temp._43 = m1->_41 * m2->_13 + m1->_42 * m2->_23 + m1->_43 * m2->_33 + m1->_44 * m2->_43;
1221 temp._44 = m1->_41 * m2->_14 + m1->_42 * m2->_24 + m1->_43 * m2->_34 + m1->_44 * m2->_44;
1227 hr_ddraw_from_wined3d(HRESULT hr)
1231 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;