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);
34 /*****************************************************************************
35 * PixelFormat_WineD3DtoDD
37 * Converts an WINED3DFORMAT value into a DDPIXELFORMAT structure
40 * DDPixelFormat: Address of the structure to write the pixel format to
41 * WineD3DFormat: Source format
43 *****************************************************************************/
45 PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat,
46 WINED3DFORMAT WineD3DFormat)
48 DWORD Size = DDPixelFormat->dwSize;
49 TRACE("Converting WINED3DFORMAT %d to DDRAW\n", WineD3DFormat);
53 memset(DDPixelFormat, 0x00, Size);
54 DDPixelFormat->dwSize = Size;
57 case WINED3DFMT_R8G8B8:
58 DDPixelFormat->dwFlags = DDPF_RGB;
59 DDPixelFormat->dwFourCC = 0;
60 DDPixelFormat->u1.dwRGBBitCount = 24;
61 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
62 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
63 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
64 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
67 case WINED3DFMT_A8R8G8B8:
68 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
69 DDPixelFormat->dwFourCC = 0;
70 DDPixelFormat->u1.dwRGBBitCount = 32;
71 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
72 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
73 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
74 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xff000000;
77 case WINED3DFMT_X8R8G8B8:
78 DDPixelFormat->dwFlags = DDPF_RGB;
79 DDPixelFormat->dwFourCC = 0;
80 DDPixelFormat->u1.dwRGBBitCount = 32;
81 DDPixelFormat->u2.dwRBitMask = 0x00ff0000;
82 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
83 DDPixelFormat->u4.dwBBitMask = 0x000000ff;
84 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
87 case WINED3DFMT_X8B8G8R8:
88 DDPixelFormat->dwFlags = DDPF_RGB;
89 DDPixelFormat->dwFourCC = 0;
90 DDPixelFormat->u1.dwRGBBitCount = 32;
91 DDPixelFormat->u2.dwRBitMask = 0x000000ff;
92 DDPixelFormat->u3.dwGBitMask = 0x0000ff00;
93 DDPixelFormat->u4.dwBBitMask = 0x00ff0000;
94 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
97 case WINED3DFMT_R5G6B5:
98 DDPixelFormat->dwFlags = DDPF_RGB;
99 DDPixelFormat->dwFourCC = 0;
100 DDPixelFormat->u1.dwRGBBitCount = 16;
101 DDPixelFormat->u2.dwRBitMask = 0xF800;
102 DDPixelFormat->u3.dwGBitMask = 0x07E0;
103 DDPixelFormat->u4.dwBBitMask = 0x001F;
104 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
107 case WINED3DFMT_X1R5G5B5:
108 DDPixelFormat->dwFlags = DDPF_RGB;
109 DDPixelFormat->dwFourCC = 0;
110 DDPixelFormat->u1.dwRGBBitCount = 16;
111 DDPixelFormat->u2.dwRBitMask = 0x7C00;
112 DDPixelFormat->u3.dwGBitMask = 0x03E0;
113 DDPixelFormat->u4.dwBBitMask = 0x001F;
114 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
117 case WINED3DFMT_A1R5G5B5:
118 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
119 DDPixelFormat->dwFourCC = 0;
120 DDPixelFormat->u1.dwRGBBitCount = 16;
121 DDPixelFormat->u2.dwRBitMask = 0x7C00;
122 DDPixelFormat->u3.dwGBitMask = 0x03E0;
123 DDPixelFormat->u4.dwBBitMask = 0x001F;
124 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x8000;
127 case WINED3DFMT_A4R4G4B4:
128 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
129 DDPixelFormat->dwFourCC = 0;
130 DDPixelFormat->u1.dwRGBBitCount = 16;
131 DDPixelFormat->u2.dwRBitMask = 0x0F00;
132 DDPixelFormat->u3.dwGBitMask = 0x00F0;
133 DDPixelFormat->u4.dwBBitMask = 0x000F;
134 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
137 case WINED3DFMT_R3G3B2:
138 DDPixelFormat->dwFlags = DDPF_RGB;
139 DDPixelFormat->dwFourCC = 0;
140 DDPixelFormat->u1.dwRGBBitCount = 8;
141 DDPixelFormat->u2.dwRBitMask = 0xE0;
142 DDPixelFormat->u3.dwGBitMask = 0x1C;
143 DDPixelFormat->u4.dwBBitMask = 0x03;
144 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
148 DDPixelFormat->dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
149 DDPixelFormat->dwFourCC = 0;
150 DDPixelFormat->u1.dwRGBBitCount = 8;
151 DDPixelFormat->u2.dwRBitMask = 0x00;
152 DDPixelFormat->u3.dwGBitMask = 0x00;
153 DDPixelFormat->u4.dwBBitMask = 0x00;
157 DDPixelFormat->dwFlags = DDPF_ALPHA;
158 DDPixelFormat->dwFourCC = 0;
159 DDPixelFormat->u1.dwAlphaBitDepth = 8;
160 DDPixelFormat->u2.dwRBitMask = 0x0;
161 DDPixelFormat->u3.dwZBitMask = 0x0;
162 DDPixelFormat->u4.dwStencilBitMask = 0x0;
163 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
166 case WINED3DFMT_A8R3G3B2:
167 DDPixelFormat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
168 DDPixelFormat->dwFourCC = 0;
169 DDPixelFormat->u1.dwRGBBitCount = 16;
170 DDPixelFormat->u2.dwRBitMask = 0x00E0;
171 DDPixelFormat->u3.dwGBitMask = 0x001C;
172 DDPixelFormat->u4.dwBBitMask = 0x0003;
173 DDPixelFormat->u5.dwRGBAlphaBitMask = 0xF000;
176 case WINED3DFMT_X4R4G4B4:
177 DDPixelFormat->dwFlags = DDPF_RGB;
178 DDPixelFormat->dwFourCC = 0;
179 DDPixelFormat->u1.dwRGBBitCount = 16;
180 DDPixelFormat->u2.dwRBitMask = 0x0F00;
181 DDPixelFormat->u3.dwGBitMask = 0x00F0;
182 DDPixelFormat->u4.dwBBitMask = 0x000F;
183 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
186 /* How are Z buffer bit depth and Stencil buffer bit depth related?
189 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
190 DDPixelFormat->dwFourCC = 0;
191 DDPixelFormat->u1.dwZBufferBitDepth = 16;
192 DDPixelFormat->u2.dwStencilBitDepth = 0;
193 DDPixelFormat->u3.dwZBitMask = 0x0000FFFF;
194 DDPixelFormat->u4.dwStencilBitMask = 0x0;
195 DDPixelFormat->u5.dwRGBZBitMask = 0x0000FFFF;
199 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
200 DDPixelFormat->dwFourCC = 0;
201 DDPixelFormat->u1.dwZBufferBitDepth = 32;
202 DDPixelFormat->u2.dwStencilBitDepth = 0;
203 DDPixelFormat->u3.dwZBitMask = 0xFFFFFFFF;
204 DDPixelFormat->u4.dwStencilBitMask = 0x0;
205 DDPixelFormat->u5.dwRGBZBitMask = 0xFFFFFFFF;
208 case WINED3DFMT_D24X4S4:
209 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
210 DDPixelFormat->dwFourCC = 0;
211 /* Should I set dwZBufferBitDepth to 32 here? */
212 DDPixelFormat->u1.dwZBufferBitDepth = 24;
213 DDPixelFormat->u2.dwStencilBitDepth = 4;
214 DDPixelFormat->u3.dwZBitMask = 0x0;
215 DDPixelFormat->u4.dwStencilBitMask = 0x0;
216 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
219 case WINED3DFMT_D24S8:
220 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
221 DDPixelFormat->dwFourCC = 0;
222 /* Should I set dwZBufferBitDepth to 32 here? */
223 DDPixelFormat->u1.dwZBufferBitDepth = 24;
224 DDPixelFormat->u2.dwStencilBitDepth = 8;
225 DDPixelFormat->u3.dwZBitMask = 0x0;
226 DDPixelFormat->u4.dwStencilBitMask = 0x0;
227 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
230 case WINED3DFMT_D24X8:
231 DDPixelFormat->dwFlags = DDPF_ZBUFFER;
232 DDPixelFormat->dwFourCC = 0;
233 DDPixelFormat->u1.dwZBufferBitDepth = 24;
234 DDPixelFormat->u2.dwStencilBitDepth = 8;
235 DDPixelFormat->u3.dwZBitMask = 0x0;
236 DDPixelFormat->u4.dwStencilBitMask = 0x0;
237 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
240 case WINED3DFMT_D15S1:
241 DDPixelFormat->dwFlags = DDPF_ZBUFFER | DDPF_STENCILBUFFER;
242 DDPixelFormat->dwFourCC = 0;
243 /* Should I set dwZBufferBitDepth to 16 here? */
244 DDPixelFormat->u1.dwZBufferBitDepth = 15;
245 DDPixelFormat->u2.dwStencilBitDepth = 1;
246 DDPixelFormat->u3.dwZBitMask = 0x0;
247 DDPixelFormat->u4.dwStencilBitMask = 0x0;
248 DDPixelFormat->u5.dwRGBAlphaBitMask = 0x0;
251 case WINED3DFMT_UYVY:
252 case WINED3DFMT_YUY2:
253 case WINED3DFMT_YV12:
254 case WINED3DFMT_DXT1:
255 case WINED3DFMT_DXT2:
256 case WINED3DFMT_DXT3:
257 case WINED3DFMT_DXT4:
258 case WINED3DFMT_DXT5:
259 case WINED3DFMT_MULTI2_ARGB8:
260 case WINED3DFMT_G8R8_G8B8:
261 case WINED3DFMT_R8G8_B8G8:
262 DDPixelFormat->dwFlags = DDPF_FOURCC;
263 DDPixelFormat->dwFourCC = WineD3DFormat;
268 DDPixelFormat->dwFlags = DDPF_LUMINANCE;
269 DDPixelFormat->dwFourCC = 0;
270 DDPixelFormat->u1.dwLuminanceBitCount = 8;
271 DDPixelFormat->u2.dwLuminanceBitMask = 0xff;
272 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
273 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
274 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x0;
277 case WINED3DFMT_A4L4:
278 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
279 DDPixelFormat->dwFourCC = 0;
280 DDPixelFormat->u1.dwLuminanceBitCount = 4;
281 DDPixelFormat->u2.dwLuminanceBitMask = 0x0f;
282 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
283 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
284 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xf0;
287 case WINED3DFMT_A8L8:
288 DDPixelFormat->dwFlags = DDPF_ALPHAPIXELS | DDPF_LUMINANCE;
289 DDPixelFormat->dwFourCC = 0;
290 DDPixelFormat->u1.dwLuminanceBitCount = 16;
291 DDPixelFormat->u2.dwLuminanceBitMask = 0x00ff;
292 DDPixelFormat->u3.dwBumpDvBitMask = 0x0;
293 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0;
294 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0xff00;
298 case WINED3DFMT_V8U8:
299 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
300 DDPixelFormat->dwFourCC = 0;
301 DDPixelFormat->u1.dwBumpBitCount = 16;
302 DDPixelFormat->u2.dwBumpDuBitMask = 0x000000ff;
303 DDPixelFormat->u3.dwBumpDvBitMask = 0x0000ff00;
304 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x00000000;
305 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
308 case WINED3DFMT_L6V5U5:
309 DDPixelFormat->dwFlags = DDPF_BUMPDUDV;
310 DDPixelFormat->dwFourCC = 0;
311 DDPixelFormat->u1.dwBumpBitCount = 16;
312 DDPixelFormat->u2.dwBumpDuBitMask = 0x0000001f;
313 DDPixelFormat->u3.dwBumpDvBitMask = 0x000003e0;
314 DDPixelFormat->u4.dwBumpLuminanceBitMask = 0x0000fc00;
315 DDPixelFormat->u5.dwLuminanceAlphaBitMask = 0x00000000;
319 ERR("Can't translate this Pixelformat %d\n", WineD3DFormat);
322 if(TRACE_ON(ddraw)) {
323 TRACE("Returning: ");
324 DDRAW_dump_pixelformat(DDPixelFormat);
327 /*****************************************************************************
328 * PixelFormat_DD2WineD3D
330 * Reads a DDPIXELFORMAT structure and returns the equal WINED3DFORMAT
333 * DDPixelFormat: The source format
336 * The WINED3DFORMAT equal to the DDraw format
337 * WINED3DFMT_UNKNOWN if a matching format wasn't found
338 *****************************************************************************/
340 PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat)
342 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
345 DDRAW_dump_pixelformat(DDPixelFormat);
348 if(DDPixelFormat->dwFlags & DDPF_PALETTEINDEXED8)
350 return WINED3DFMT_P8;
352 else if(DDPixelFormat->dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 | DDPF_PALETTEINDEXED4) )
354 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
355 return WINED3DFMT_P8;
357 else if(DDPixelFormat->dwFlags & DDPF_RGB)
359 switch(DDPixelFormat->u1.dwRGBBitCount)
362 /* This is the only format that can match here */
363 return WINED3DFMT_R3G3B2;
366 /* Read the Color masks */
367 if( (DDPixelFormat->u2.dwRBitMask == 0xF800) &&
368 (DDPixelFormat->u3.dwGBitMask == 0x07E0) &&
369 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
371 return WINED3DFMT_R5G6B5;
374 if( (DDPixelFormat->u2.dwRBitMask == 0x7C00) &&
375 (DDPixelFormat->u3.dwGBitMask == 0x03E0) &&
376 (DDPixelFormat->u4.dwBBitMask == 0x001F) )
378 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
379 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0x8000))
380 return WINED3DFMT_A1R5G5B5;
382 return WINED3DFMT_X1R5G5B5;
385 if( (DDPixelFormat->u2.dwRBitMask == 0x0F00) &&
386 (DDPixelFormat->u3.dwGBitMask == 0x00F0) &&
387 (DDPixelFormat->u4.dwBBitMask == 0x000F) )
389 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
390 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xF000))
391 return WINED3DFMT_A4R4G4B4;
393 return WINED3DFMT_X4R4G4B4;
396 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
397 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF00) &&
398 (DDPixelFormat->u2.dwRBitMask == 0x00E0) &&
399 (DDPixelFormat->u3.dwGBitMask == 0x001C) &&
400 (DDPixelFormat->u4.dwBBitMask == 0x0003) )
402 return WINED3DFMT_A8R3G3B2;
404 ERR("16 bit RGB Pixel format does not match\n");
405 return WINED3DFMT_UNKNOWN;
408 return WINED3DFMT_R8G8B8;
411 /* Read the Color masks */
412 if( (DDPixelFormat->u2.dwRBitMask == 0x00FF0000) &&
413 (DDPixelFormat->u3.dwGBitMask == 0x0000FF00) &&
414 (DDPixelFormat->u4.dwBBitMask == 0x000000FF) )
416 if( (DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS) &&
417 (DDPixelFormat->u5.dwRGBAlphaBitMask == 0xFF000000))
418 return WINED3DFMT_A8R8G8B8;
420 return WINED3DFMT_X8R8G8B8;
423 ERR("32 bit RGB pixel format does not match\n");
426 ERR("Invalid dwRGBBitCount in Pixelformat structure\n");
427 return WINED3DFMT_UNKNOWN;
430 else if( (DDPixelFormat->dwFlags & DDPF_ALPHA) )
432 /* Alpha only Pixelformat */
433 switch(DDPixelFormat->u1.dwAlphaBitDepth)
438 ERR("Unsupported Alpha-Only bit depth 0x%x\n", DDPixelFormat->u1.dwAlphaBitDepth);
440 return WINED3DFMT_A8;
443 ERR("Invalid AlphaBitDepth in Alpha-Only Pixelformat\n");
444 return WINED3DFMT_UNKNOWN;
447 else if(DDPixelFormat->dwFlags & DDPF_LUMINANCE)
449 /* Luminance-only or luminance-alpha */
450 if(DDPixelFormat->dwFlags & DDPF_ALPHAPIXELS)
452 /* Luminance with Alpha */
453 switch(DDPixelFormat->u1.dwLuminanceBitCount)
456 if(DDPixelFormat->u1.dwAlphaBitDepth == 4)
457 return WINED3DFMT_A4L4;
458 ERR("Unknown Alpha / Luminance bit depth combination\n");
459 return WINED3DFMT_UNKNOWN;
462 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
463 return WINED3DFMT_L6V5U5;
466 if(DDPixelFormat->u1.dwAlphaBitDepth == 8)
467 return WINED3DFMT_A8L8;
468 ERR("Unknown Alpha / Lumincase bit depth combination\n");
469 return WINED3DFMT_UNKNOWN;
475 switch(DDPixelFormat->u1.dwLuminanceBitCount)
478 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
479 return WINED3DFMT_L6V5U5;
482 return WINED3DFMT_L8;
485 ERR("Unknown luminance-only bit depth 0x%x\n", DDPixelFormat->u1.dwLuminanceBitCount);
486 return WINED3DFMT_UNKNOWN;
490 else if(DDPixelFormat->dwFlags & DDPF_ZBUFFER)
493 if(DDPixelFormat->dwFlags & DDPF_STENCILBUFFER)
495 switch(DDPixelFormat->u1.dwZBufferBitDepth)
498 ERR("8 Bits Z+Stencil buffer pixelformat is not supported. Returning WINED3DFMT_UNKNOWN\n");
499 return WINED3DFMT_UNKNOWN;
503 if(DDPixelFormat->u2.dwStencilBitDepth == 1)
504 return WINED3DFMT_D15S1;
506 ERR("Don't know how to handle a 16 bit Z buffer with %d bit stencil buffer pixelformat\n", DDPixelFormat->u2.dwStencilBitDepth);
507 return WINED3DFMT_UNKNOWN;
510 ERR("Don't know how to handle a 24 bit depth buffer with stencil bits\n");
511 return WINED3DFMT_D24S8;
514 if(DDPixelFormat->u2.dwStencilBitDepth == 8)
515 return WINED3DFMT_D24S8;
517 return WINED3DFMT_D24X4S4;
520 ERR("Unknown Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
521 return WINED3DFMT_UNKNOWN;
526 switch(DDPixelFormat->u1.dwZBufferBitDepth)
529 ERR("8 Bit Z buffers are not supported. Trying a 16 Bit one\n");
530 return WINED3DFMT_D16;
533 return WINED3DFMT_D16;
536 return WINED3DFMT_D24X8;
539 return WINED3DFMT_D32;
542 ERR("Unsupported Z buffer depth %d\n", DDPixelFormat->u1.dwZBufferBitDepth);
543 return WINED3DFMT_UNKNOWN;
547 else if(DDPixelFormat->dwFlags & DDPF_FOURCC)
549 if(DDPixelFormat->dwFourCC == MAKEFOURCC('U', 'Y', 'V', 'Y'))
551 return WINED3DFMT_UYVY;
553 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'U', 'Y', '2'))
555 return WINED3DFMT_YUY2;
557 if(DDPixelFormat->dwFourCC == MAKEFOURCC('Y', 'V', '1', '2'))
559 return WINED3DFMT_YV12;
561 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '1'))
563 return WINED3DFMT_DXT1;
565 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '2'))
567 return WINED3DFMT_DXT2;
569 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '3'))
571 return WINED3DFMT_DXT3;
573 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '4'))
575 return WINED3DFMT_DXT4;
577 if(DDPixelFormat->dwFourCC == MAKEFOURCC('D', 'X', 'T', '5'))
579 return WINED3DFMT_DXT5;
581 if(DDPixelFormat->dwFourCC == MAKEFOURCC('G', 'R', 'G', 'B'))
583 return WINED3DFMT_G8R8_G8B8;
585 if(DDPixelFormat->dwFourCC == MAKEFOURCC('R', 'G', 'B', 'G'))
587 return WINED3DFMT_R8G8_B8G8;
589 return WINED3DFMT_UNKNOWN; /* Abuse this as an error value */
591 else if(DDPixelFormat->dwFlags & DDPF_BUMPDUDV)
593 if( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
594 (DDPixelFormat->u2.dwBumpDuBitMask == 0x000000ff) &&
595 (DDPixelFormat->u3.dwBumpDvBitMask == 0x0000ff00) &&
596 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x00000000) )
598 return WINED3DFMT_V8U8;
600 else if ( (DDPixelFormat->u1.dwBumpBitCount == 16 ) &&
601 (DDPixelFormat->u2.dwBumpDuBitMask == 0x0000001f) &&
602 (DDPixelFormat->u3.dwBumpDvBitMask == 0x000003e0) &&
603 (DDPixelFormat->u4.dwBumpLuminanceBitMask == 0x0000fc00) )
605 return WINED3DFMT_L6V5U5;
609 ERR("Unknown Pixelformat!\n");
610 return WINED3DFMT_UNKNOWN;
613 /*****************************************************************************
614 * Various dumping functions.
616 * They write the contents of a specific function to a TRACE.
618 *****************************************************************************/
620 DDRAW_dump_DWORD(const void *in)
622 TRACE("%d\n", *((const DWORD *) in));
625 DDRAW_dump_PTR(const void *in)
627 TRACE("%p\n", *((const void * const*) in));
630 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *ddck)
632 TRACE("Low : %d - High : %d\n", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
635 static void DDRAW_dump_flags_nolf(DWORD flags, const flag_info* names,
640 for (i=0; i < num_names; i++)
641 if ((flags & names[i].val) || /* standard flag value */
642 ((!flags) && (!names[i].val))) /* zero value only */
643 TRACE("%s ", names[i].name);
646 static void DDRAW_dump_flags(DWORD flags, const flag_info* names, size_t num_names)
648 DDRAW_dump_flags_nolf(flags, names, num_names);
652 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in)
654 static const flag_info flags[] = {
655 FE(DDSCAPS_RESERVED1),
657 FE(DDSCAPS_BACKBUFFER),
660 FE(DDSCAPS_FRONTBUFFER),
661 FE(DDSCAPS_OFFSCREENPLAIN),
664 FE(DDSCAPS_PRIMARYSURFACE),
665 FE(DDSCAPS_PRIMARYSURFACELEFT),
666 FE(DDSCAPS_SYSTEMMEMORY),
668 FE(DDSCAPS_3DDEVICE),
669 FE(DDSCAPS_VIDEOMEMORY),
671 FE(DDSCAPS_WRITEONLY),
674 FE(DDSCAPS_LIVEVIDEO),
678 FE(DDSCAPS_RESERVED2),
679 FE(DDSCAPS_ALLOCONLOAD),
680 FE(DDSCAPS_VIDEOPORT),
681 FE(DDSCAPS_LOCALVIDMEM),
682 FE(DDSCAPS_NONLOCALVIDMEM),
683 FE(DDSCAPS_STANDARDVGAMODE),
684 FE(DDSCAPS_OPTIMIZED)
686 static const flag_info flags2[] = {
687 FE(DDSCAPS2_HARDWAREDEINTERLACE),
688 FE(DDSCAPS2_HINTDYNAMIC),
689 FE(DDSCAPS2_HINTSTATIC),
690 FE(DDSCAPS2_TEXTUREMANAGE),
691 FE(DDSCAPS2_RESERVED1),
692 FE(DDSCAPS2_RESERVED2),
694 FE(DDSCAPS2_HINTANTIALIASING),
695 FE(DDSCAPS2_CUBEMAP),
696 FE(DDSCAPS2_CUBEMAP_POSITIVEX),
697 FE(DDSCAPS2_CUBEMAP_NEGATIVEX),
698 FE(DDSCAPS2_CUBEMAP_POSITIVEY),
699 FE(DDSCAPS2_CUBEMAP_NEGATIVEY),
700 FE(DDSCAPS2_CUBEMAP_POSITIVEZ),
701 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ),
702 FE(DDSCAPS2_MIPMAPSUBLEVEL),
703 FE(DDSCAPS2_D3DTEXTUREMANAGE),
704 FE(DDSCAPS2_DONOTPERSIST),
705 FE(DDSCAPS2_STEREOSURFACELEFT)
708 DDRAW_dump_flags_nolf(in->dwCaps, flags, sizeof(flags)/sizeof(flags[0]));
709 DDRAW_dump_flags(in->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
713 DDRAW_dump_DDSCAPS(const DDSCAPS *in)
717 in_bis.dwCaps = in->dwCaps;
722 DDRAW_dump_DDSCAPS2(&in_bis);
726 DDRAW_dump_pixelformat_flag(DWORD flagmask)
728 static const flag_info flags[] =
730 FE(DDPF_ALPHAPIXELS),
733 FE(DDPF_PALETTEINDEXED4),
734 FE(DDPF_PALETTEINDEXEDTO8),
735 FE(DDPF_PALETTEINDEXED8),
741 FE(DDPF_PALETTEINDEXED1),
742 FE(DDPF_PALETTEINDEXED2),
746 DDRAW_dump_flags_nolf(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
750 DDRAW_dump_members(DWORD flags,
752 const member_info* mems,
757 for (i=0; i < num_mems; i++)
759 if (mems[i].val & flags)
761 TRACE(" - %s : ", mems[i].name);
762 mems[i].func((const char *)data + mems[i].offset);
768 DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf)
771 DDRAW_dump_pixelformat_flag(pf->dwFlags);
772 if (pf->dwFlags & DDPF_FOURCC)
774 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
775 (unsigned char)( pf->dwFourCC &0xff),
776 (unsigned char)((pf->dwFourCC>> 8)&0xff),
777 (unsigned char)((pf->dwFourCC>>16)&0xff),
778 (unsigned char)((pf->dwFourCC>>24)&0xff),
783 if (pf->dwFlags & DDPF_RGB)
786 TRACE(", RGB bits: %d, ", pf->u1.dwRGBBitCount);
787 switch (pf->u1.dwRGBBitCount)
789 case 4: cmd = "%1lx"; break;
790 case 8: cmd = "%02lx"; break;
791 case 16: cmd = "%04lx"; break;
792 case 24: cmd = "%06lx"; break;
793 case 32: cmd = "%08lx"; break;
794 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
796 TRACE(" R "); TRACE(cmd, pf->u2.dwRBitMask);
797 TRACE(" G "); TRACE(cmd, pf->u3.dwGBitMask);
798 TRACE(" B "); TRACE(cmd, pf->u4.dwBBitMask);
799 if (pf->dwFlags & DDPF_ALPHAPIXELS)
801 TRACE(" A "); TRACE(cmd, pf->u5.dwRGBAlphaBitMask);
803 if (pf->dwFlags & DDPF_ZPIXELS)
805 TRACE(" Z "); TRACE(cmd, pf->u5.dwRGBZBitMask);
808 if (pf->dwFlags & DDPF_ZBUFFER)
810 TRACE(", Z bits : %d", pf->u1.dwZBufferBitDepth);
812 if (pf->dwFlags & DDPF_ALPHA)
814 TRACE(", Alpha bits : %d", pf->u1.dwAlphaBitDepth);
816 if (pf->dwFlags & DDPF_BUMPDUDV)
818 const char *cmd = "%08lx";
819 TRACE(", Bump bits: %d, ", pf->u1.dwBumpBitCount);
820 TRACE(" U "); TRACE(cmd, pf->u2.dwBumpDuBitMask);
821 TRACE(" V "); TRACE(cmd, pf->u3.dwBumpDvBitMask);
822 TRACE(" L "); TRACE(cmd, pf->u4.dwBumpLuminanceBitMask);
827 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd)
829 #define STRUCT DDSURFACEDESC2
830 static const member_info members[] =
832 ME(DDSD_HEIGHT, DDRAW_dump_DWORD, dwHeight),
833 ME(DDSD_WIDTH, DDRAW_dump_DWORD, dwWidth),
834 ME(DDSD_PITCH, DDRAW_dump_DWORD, u1 /* lPitch */),
835 ME(DDSD_LINEARSIZE, DDRAW_dump_DWORD, u1 /* dwLinearSize */),
836 ME(DDSD_BACKBUFFERCOUNT, DDRAW_dump_DWORD, dwBackBufferCount),
837 ME(DDSD_MIPMAPCOUNT, DDRAW_dump_DWORD, u2 /* dwMipMapCount */),
838 ME(DDSD_ZBUFFERBITDEPTH, DDRAW_dump_DWORD, u2 /* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
839 ME(DDSD_REFRESHRATE, DDRAW_dump_DWORD, u2 /* dwRefreshRate */),
840 ME(DDSD_ALPHABITDEPTH, DDRAW_dump_DWORD, dwAlphaBitDepth),
841 ME(DDSD_LPSURFACE, DDRAW_dump_PTR, lpSurface),
842 ME(DDSD_CKDESTOVERLAY, DDRAW_dump_DDCOLORKEY, u3 /* ddckCKDestOverlay */),
843 ME(DDSD_CKDESTBLT, DDRAW_dump_DDCOLORKEY, ddckCKDestBlt),
844 ME(DDSD_CKSRCOVERLAY, DDRAW_dump_DDCOLORKEY, ddckCKSrcOverlay),
845 ME(DDSD_CKSRCBLT, DDRAW_dump_DDCOLORKEY, ddckCKSrcBlt),
846 ME(DDSD_PIXELFORMAT, DDRAW_dump_pixelformat, u4 /* ddpfPixelFormat */)
848 static const member_info members_caps[] =
850 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS, ddsCaps)
852 static const member_info members_caps2[] =
854 ME(DDSD_CAPS, DDRAW_dump_DDSCAPS2, ddsCaps)
864 if (lpddsd->dwSize >= sizeof(DDSURFACEDESC2))
866 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps2, 1);
870 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps, 1);
872 DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members,
873 sizeof(members)/sizeof(members[0]));
878 dump_D3DMATRIX(const D3DMATRIX *mat)
880 TRACE(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
881 TRACE(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
882 TRACE(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
883 TRACE(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
887 get_flexible_vertex_size(DWORD d3dvtVertexType)
892 if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
893 if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
894 if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
895 if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD);
896 switch (d3dvtVertexType & D3DFVF_POSITION_MASK)
898 case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
899 case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
900 case D3DFVF_XYZB1: size += 4 * sizeof(D3DVALUE); break;
901 case D3DFVF_XYZB2: size += 5 * sizeof(D3DVALUE); break;
902 case D3DFVF_XYZB3: size += 6 * sizeof(D3DVALUE); break;
903 case D3DFVF_XYZB4: size += 7 * sizeof(D3DVALUE); break;
904 case D3DFVF_XYZB5: size += 8 * sizeof(D3DVALUE); break;
905 default: ERR("Unexpected position mask\n");
907 for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++)
909 size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE);
915 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
917 /* 2 adds three additional caps fields to the end. Both versions
918 * are unversioned. */
919 pOut->dwCaps = pIn->dwCaps;
925 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, DDDEVICEIDENTIFIER* pOut)
927 /* 2 adds a dwWHQLLevel field to the end. Both structures are
929 memcpy(pOut, pIn, sizeof(*pOut));
932 void DDRAW_dump_cooperativelevel(DWORD cooplevel)
934 static const flag_info flags[] =
936 FE(DDSCL_FULLSCREEN),
937 FE(DDSCL_ALLOWREBOOT),
938 FE(DDSCL_NOWINDOWCHANGES),
940 FE(DDSCL_ALLOWMODEX),
942 FE(DDSCL_SETFOCUSWINDOW),
943 FE(DDSCL_SETDEVICEWINDOW),
944 FE(DDSCL_CREATEDEVICEWINDOW)
950 DDRAW_dump_flags(cooplevel, flags, sizeof(flags)/sizeof(flags[0]));
954 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps)
956 static const flag_info flags1[] =
959 FE(DDCAPS_ALIGNBOUNDARYDEST),
960 FE(DDCAPS_ALIGNSIZEDEST),
961 FE(DDCAPS_ALIGNBOUNDARYSRC),
962 FE(DDCAPS_ALIGNSIZESRC),
963 FE(DDCAPS_ALIGNSTRIDE),
966 FE(DDCAPS_BLTFOURCC),
967 FE(DDCAPS_BLTSTRETCH),
970 FE(DDCAPS_OVERLAYCANTCLIP),
971 FE(DDCAPS_OVERLAYFOURCC),
972 FE(DDCAPS_OVERLAYSTRETCH),
974 FE(DDCAPS_PALETTEVSYNC),
975 FE(DDCAPS_READSCANLINE),
976 FE(DDCAPS_STEREOVIEW),
979 FE(DDCAPS_ZOVERLAYS),
982 FE(DDCAPS_COLORKEYHWASSIST),
983 FE(DDCAPS_NOHARDWARE),
984 FE(DDCAPS_BLTCOLORFILL),
985 FE(DDCAPS_BANKSWITCHED),
986 FE(DDCAPS_BLTDEPTHFILL),
988 FE(DDCAPS_CANCLIPSTRETCHED),
989 FE(DDCAPS_CANBLTSYSMEM)
991 static const flag_info flags2[] =
993 FE(DDCAPS2_CERTIFIED),
994 FE(DDCAPS2_NO2DDURING3DSCENE),
995 FE(DDCAPS2_VIDEOPORT),
996 FE(DDCAPS2_AUTOFLIPOVERLAY),
997 FE(DDCAPS2_CANBOBINTERLEAVED),
998 FE(DDCAPS2_CANBOBNONINTERLEAVED),
999 FE(DDCAPS2_COLORCONTROLOVERLAY),
1000 FE(DDCAPS2_COLORCONTROLPRIMARY),
1001 FE(DDCAPS2_CANDROPZ16BIT),
1002 FE(DDCAPS2_NONLOCALVIDMEM),
1003 FE(DDCAPS2_NONLOCALVIDMEMCAPS),
1004 FE(DDCAPS2_NOPAGELOCKREQUIRED),
1005 FE(DDCAPS2_WIDESURFACES),
1006 FE(DDCAPS2_CANFLIPODDEVEN),
1007 FE(DDCAPS2_CANBOBHARDWARE),
1008 FE(DDCAPS2_COPYFOURCC),
1009 FE(DDCAPS2_PRIMARYGAMMA),
1010 FE(DDCAPS2_CANRENDERWINDOWED),
1011 FE(DDCAPS2_CANCALIBRATEGAMMA),
1012 FE(DDCAPS2_FLIPINTERVAL),
1013 FE(DDCAPS2_FLIPNOVSYNC),
1014 FE(DDCAPS2_CANMANAGETEXTURE),
1015 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM),
1017 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL)
1019 static const flag_info flags3[] =
1021 FE(DDCKEYCAPS_DESTBLT),
1022 FE(DDCKEYCAPS_DESTBLTCLRSPACE),
1023 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV),
1024 FE(DDCKEYCAPS_DESTBLTYUV),
1025 FE(DDCKEYCAPS_DESTOVERLAY),
1026 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE),
1027 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV),
1028 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE),
1029 FE(DDCKEYCAPS_DESTOVERLAYYUV),
1030 FE(DDCKEYCAPS_SRCBLT),
1031 FE(DDCKEYCAPS_SRCBLTCLRSPACE),
1032 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV),
1033 FE(DDCKEYCAPS_SRCBLTYUV),
1034 FE(DDCKEYCAPS_SRCOVERLAY),
1035 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE),
1036 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV),
1037 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE),
1038 FE(DDCKEYCAPS_SRCOVERLAYYUV),
1039 FE(DDCKEYCAPS_NOCOSTOVERLAY)
1041 static const flag_info flags4[] =
1043 FE(DDFXCAPS_BLTALPHA),
1044 FE(DDFXCAPS_OVERLAYALPHA),
1045 FE(DDFXCAPS_BLTARITHSTRETCHYN),
1046 FE(DDFXCAPS_BLTARITHSTRETCHY),
1047 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT),
1048 FE(DDFXCAPS_BLTMIRRORUPDOWN),
1049 FE(DDFXCAPS_BLTROTATION),
1050 FE(DDFXCAPS_BLTROTATION90),
1051 FE(DDFXCAPS_BLTSHRINKX),
1052 FE(DDFXCAPS_BLTSHRINKXN),
1053 FE(DDFXCAPS_BLTSHRINKY),
1054 FE(DDFXCAPS_BLTSHRINKYN),
1055 FE(DDFXCAPS_BLTSTRETCHX),
1056 FE(DDFXCAPS_BLTSTRETCHXN),
1057 FE(DDFXCAPS_BLTSTRETCHY),
1058 FE(DDFXCAPS_BLTSTRETCHYN),
1059 FE(DDFXCAPS_OVERLAYARITHSTRETCHY),
1060 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN),
1061 FE(DDFXCAPS_OVERLAYSHRINKX),
1062 FE(DDFXCAPS_OVERLAYSHRINKXN),
1063 FE(DDFXCAPS_OVERLAYSHRINKY),
1064 FE(DDFXCAPS_OVERLAYSHRINKYN),
1065 FE(DDFXCAPS_OVERLAYSTRETCHX),
1066 FE(DDFXCAPS_OVERLAYSTRETCHXN),
1067 FE(DDFXCAPS_OVERLAYSTRETCHY),
1068 FE(DDFXCAPS_OVERLAYSTRETCHYN),
1069 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT),
1070 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN)
1072 static const flag_info flags5[] =
1074 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND),
1075 FE(DDFXALPHACAPS_BLTALPHAPIXELS),
1076 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG),
1077 FE(DDFXALPHACAPS_BLTALPHASURFACES),
1078 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG),
1079 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND),
1080 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS),
1081 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG),
1082 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES),
1083 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG)
1085 static const flag_info flags6[] =
1088 FE(DDPCAPS_8BITENTRIES),
1090 FE(DDPCAPS_INITIALIZE),
1091 FE(DDPCAPS_PRIMARYSURFACE),
1092 FE(DDPCAPS_PRIMARYSURFACELEFT),
1093 FE(DDPCAPS_ALLOW256),
1099 static const flag_info flags7[] =
1101 FE(DDSVCAPS_RESERVED1),
1102 FE(DDSVCAPS_RESERVED2),
1103 FE(DDSVCAPS_RESERVED3),
1104 FE(DDSVCAPS_RESERVED4),
1105 FE(DDSVCAPS_STEREOSEQUENTIAL),
1108 TRACE(" - dwSize : %d\n", lpcaps->dwSize);
1109 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps->dwCaps, flags1, sizeof(flags1)/sizeof(flags1[0]));
1110 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
1111 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps->dwCKeyCaps, flags3, sizeof(flags3)/sizeof(flags3[0]));
1112 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps->dwFXCaps, flags4, sizeof(flags4)/sizeof(flags4[0]));
1113 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps->dwFXAlphaCaps, flags5, sizeof(flags5)/sizeof(flags5[0]));
1114 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps->dwPalCaps, flags6, sizeof(flags6)/sizeof(flags6[0]));
1115 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps->dwSVCaps, flags7, sizeof(flags7)/sizeof(flags7[0]));
1117 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps->dwNumFourCCCodes);
1118 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps->dwCurrVisibleOverlays);
1119 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps->dwMinOverlayStretch);
1120 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps->dwMaxOverlayStretch);
1122 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps->ddsCaps);
1125 /*****************************************************************************
1128 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1131 * dest: Pointer to the destination matrix
1132 * src1: Pointer to the first source matrix
1133 * src2: Pointer to the second source matrix
1135 *****************************************************************************/
1137 multiply_matrix(D3DMATRIX *dest,
1138 const D3DMATRIX *src1,
1139 const D3DMATRIX *src2)
1143 /* Now do the multiplication 'by hand'.
1144 I know that all this could be optimised, but this will be done later :-) */
1145 temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
1146 temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
1147 temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
1148 temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
1150 temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
1151 temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
1152 temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
1153 temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
1155 temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
1156 temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
1157 temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
1158 temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
1160 temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
1161 temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
1162 temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
1163 temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
1165 /* And copy the new matrix in the good storage.. */
1166 memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
1171 hr_ddraw_from_wined3d(HRESULT hr)
1175 case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;