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_R8G8B8
:
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_A8R8G8B8
:
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_X8R8G8B8
:
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_X8B8G8R8
:
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_R5G6B5
:
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_X1R5G5B5
:
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_A1R5G5B5
:
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_A4R4G4B4
:
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_R3G3B2
:
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;
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;
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_A8R3G3B2
:
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_X4R4G4B4
:
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?
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;
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_D24X4S4
:
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_D24S8
:
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_D24X8
:
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_D15S1
:
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
;
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_A4L4
:
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_A8L8
:
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_V8U8
:
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_L6V5U5
:
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;
329 ERR("Can't translate this Pixelformat %d\n", WineD3DFormat
);
332 if(TRACE_ON(ddraw
)) {
333 TRACE("Returning: ");
334 DDRAW_dump_pixelformat(DDPixelFormat
);
337 /*****************************************************************************
338 * PixelFormat_DD2WineD3D
340 * Reads a DDPIXELFORMAT structure and returns the equal WINED3DFORMAT
343 * DDPixelFormat: The source format
346 * The WINED3DFORMAT equal to the DDraw format
347 * WINED3DFMT_UNKNOWN if a matching format wasn't found
348 *****************************************************************************/
350 PixelFormat_DD2WineD3D(const DDPIXELFORMAT
*DDPixelFormat
)
352 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
355 DDRAW_dump_pixelformat(DDPixelFormat
);
358 if(DDPixelFormat
->dwFlags
& DDPF_PALETTEINDEXED8
)
360 return WINED3DFMT_P8
;
362 else if(DDPixelFormat
->dwFlags
& (DDPF_PALETTEINDEXED1
| DDPF_PALETTEINDEXED2
| DDPF_PALETTEINDEXED4
) )
364 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
365 return WINED3DFMT_P8
;
367 else if(DDPixelFormat
->dwFlags
& DDPF_RGB
)
369 switch(DDPixelFormat
->u1
.dwRGBBitCount
)
372 /* This is the only format that can match here */
373 return WINED3DFMT_R3G3B2
;
376 /* Read the Color masks */
377 if( (DDPixelFormat
->u2
.dwRBitMask
== 0xF800) &&
378 (DDPixelFormat
->u3
.dwGBitMask
== 0x07E0) &&
379 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
381 return WINED3DFMT_R5G6B5
;
384 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x7C00) &&
385 (DDPixelFormat
->u3
.dwGBitMask
== 0x03E0) &&
386 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
388 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
389 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0x8000))
390 return WINED3DFMT_A1R5G5B5
;
392 return WINED3DFMT_X1R5G5B5
;
395 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x0F00) &&
396 (DDPixelFormat
->u3
.dwGBitMask
== 0x00F0) &&
397 (DDPixelFormat
->u4
.dwBBitMask
== 0x000F) )
399 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
400 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xF000))
401 return WINED3DFMT_A4R4G4B4
;
403 return WINED3DFMT_X4R4G4B4
;
406 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
407 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF00) &&
408 (DDPixelFormat
->u2
.dwRBitMask
== 0x00E0) &&
409 (DDPixelFormat
->u3
.dwGBitMask
== 0x001C) &&
410 (DDPixelFormat
->u4
.dwBBitMask
== 0x0003) )
412 return WINED3DFMT_A8R3G3B2
;
414 ERR("16 bit RGB Pixel format does not match\n");
415 return WINED3DFMT_UNKNOWN
;
418 return WINED3DFMT_R8G8B8
;
421 /* Read the Color masks */
422 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x00FF0000) &&
423 (DDPixelFormat
->u3
.dwGBitMask
== 0x0000FF00) &&
424 (DDPixelFormat
->u4
.dwBBitMask
== 0x000000FF) )
426 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
427 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF000000))
428 return WINED3DFMT_A8R8G8B8
;
430 return WINED3DFMT_X8R8G8B8
;
433 ERR("32 bit RGB pixel format does not match\n");
436 ERR("Invalid dwRGBBitCount in Pixelformat structure\n");
437 return WINED3DFMT_UNKNOWN
;
440 else if( (DDPixelFormat
->dwFlags
& DDPF_ALPHA
) )
442 /* Alpha only Pixelformat */
443 switch(DDPixelFormat
->u1
.dwAlphaBitDepth
)
448 ERR("Unsupported Alpha-Only bit depth 0x%x\n", DDPixelFormat
->u1
.dwAlphaBitDepth
);
450 return WINED3DFMT_A8
;
453 ERR("Invalid AlphaBitDepth in Alpha-Only Pixelformat\n");
454 return WINED3DFMT_UNKNOWN
;
457 else if(DDPixelFormat
->dwFlags
& DDPF_LUMINANCE
)
459 /* Luminance-only or luminance-alpha */
460 if(DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
)
462 /* Luminance with Alpha */
463 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
466 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 4)
467 return WINED3DFMT_A4L4
;
468 ERR("Unknown Alpha / Luminance bit depth combination\n");
469 return WINED3DFMT_UNKNOWN
;
472 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
473 return WINED3DFMT_L6V5U5
;
476 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 8)
477 return WINED3DFMT_A8L8
;
478 ERR("Unknown Alpha / Lumincase bit depth combination\n");
479 return WINED3DFMT_UNKNOWN
;
485 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
488 ERR("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now!!\n");
489 return WINED3DFMT_L6V5U5
;
492 return WINED3DFMT_L8
;
495 ERR("Unknown luminance-only bit depth 0x%x\n", DDPixelFormat
->u1
.dwLuminanceBitCount
);
496 return WINED3DFMT_UNKNOWN
;
500 else if(DDPixelFormat
->dwFlags
& DDPF_ZBUFFER
)
503 if(DDPixelFormat
->dwFlags
& DDPF_STENCILBUFFER
)
505 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
508 FIXME("8 Bits Z+Stencil buffer pixelformat is not supported. Returning WINED3DFMT_UNKNOWN\n");
509 return WINED3DFMT_UNKNOWN
;
512 FIXME("15 bit depth buffer not handled yet, assuming 16 bit\n");
514 if(DDPixelFormat
->u2
.dwStencilBitDepth
== 1)
515 return WINED3DFMT_D15S1
;
517 FIXME("Don't know how to handle a 16 bit Z buffer with %d bit stencil buffer pixelformat\n", DDPixelFormat
->u2
.dwStencilBitDepth
);
518 return WINED3DFMT_UNKNOWN
;
521 FIXME("Don't know how to handle a 24 bit depth buffer with stencil bits\n");
522 return WINED3DFMT_D24S8
;
525 if(DDPixelFormat
->u2
.dwStencilBitDepth
== 8)
526 return WINED3DFMT_D24S8
;
528 return WINED3DFMT_D24X4S4
;
531 ERR("Unknown Z buffer depth %d\n", DDPixelFormat
->u1
.dwZBufferBitDepth
);
532 return WINED3DFMT_UNKNOWN
;
537 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
540 ERR("8 Bit Z buffers are not supported. Trying a 16 Bit one\n");
541 return WINED3DFMT_D16
;
544 return WINED3DFMT_D16
;
547 FIXME("24 Bit depth buffer, treating like a 32 bit one\n");
549 if(DDPixelFormat
->u3
.dwZBitMask
== 0x00FFFFFF) {
550 return WINED3DFMT_D24X8
;
551 } else if(DDPixelFormat
->u3
.dwZBitMask
== 0xFFFFFFFF) {
552 return WINED3DFMT_D32
;
554 FIXME("Unhandled 32 bit depth buffer bitmasks, returning WINED3DFMT_D24X8\n");
555 return WINED3DFMT_D24X8
; /* That's most likely to make games happy */
558 ERR("Unsupported Z buffer depth %d\n", DDPixelFormat
->u1
.dwZBufferBitDepth
);
559 return WINED3DFMT_UNKNOWN
;
563 else if(DDPixelFormat
->dwFlags
& DDPF_FOURCC
)
565 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('U', 'Y', 'V', 'Y'))
567 return WINED3DFMT_UYVY
;
569 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('Y', 'U', 'Y', '2'))
571 return WINED3DFMT_YUY2
;
573 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('Y', 'V', '1', '2'))
575 return WINED3DFMT_YV12
;
577 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('D', 'X', 'T', '1'))
579 return WINED3DFMT_DXT1
;
581 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('D', 'X', 'T', '2'))
583 return WINED3DFMT_DXT2
;
585 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('D', 'X', 'T', '3'))
587 return WINED3DFMT_DXT3
;
589 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('D', 'X', 'T', '4'))
591 return WINED3DFMT_DXT4
;
593 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('D', 'X', 'T', '5'))
595 return WINED3DFMT_DXT5
;
597 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('G', 'R', 'G', 'B'))
599 return WINED3DFMT_G8R8_G8B8
;
601 if(DDPixelFormat
->dwFourCC
== MAKEFOURCC('R', 'G', 'B', 'G'))
603 return WINED3DFMT_R8G8_B8G8
;
605 return WINED3DFMT_UNKNOWN
; /* Abuse this as an error value */
607 else if(DDPixelFormat
->dwFlags
& DDPF_BUMPDUDV
)
609 if( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
610 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x000000ff) &&
611 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x0000ff00) &&
612 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00000000) )
614 return WINED3DFMT_V8U8
;
616 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
617 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x0000001f) &&
618 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x000003e0) &&
619 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x0000fc00) )
621 return WINED3DFMT_L6V5U5
;
625 ERR("Unknown Pixelformat!\n");
626 return WINED3DFMT_UNKNOWN
;
629 /*****************************************************************************
630 * Various dumping functions.
632 * They write the contents of a specific function to a TRACE.
634 *****************************************************************************/
636 DDRAW_dump_DWORD(const void *in
)
638 TRACE("%d\n", *((const DWORD
*) in
));
641 DDRAW_dump_PTR(const void *in
)
643 TRACE("%p\n", *((const void * const*) in
));
646 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*ddck
)
648 TRACE("Low : %d - High : %d\n", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
651 static void DDRAW_dump_flags_nolf(DWORD flags
, const flag_info
* names
,
656 for (i
=0; i
< num_names
; i
++)
657 if ((flags
& names
[i
].val
) || /* standard flag value */
658 ((!flags
) && (!names
[i
].val
))) /* zero value only */
659 TRACE("%s ", names
[i
].name
);
662 static void DDRAW_dump_flags(DWORD flags
, const flag_info
* names
, size_t num_names
)
664 DDRAW_dump_flags_nolf(flags
, names
, num_names
);
668 void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
)
670 static const flag_info flags
[] = {
671 FE(DDSCAPS_RESERVED1
),
673 FE(DDSCAPS_BACKBUFFER
),
676 FE(DDSCAPS_FRONTBUFFER
),
677 FE(DDSCAPS_OFFSCREENPLAIN
),
680 FE(DDSCAPS_PRIMARYSURFACE
),
681 FE(DDSCAPS_PRIMARYSURFACELEFT
),
682 FE(DDSCAPS_SYSTEMMEMORY
),
684 FE(DDSCAPS_3DDEVICE
),
685 FE(DDSCAPS_VIDEOMEMORY
),
687 FE(DDSCAPS_WRITEONLY
),
690 FE(DDSCAPS_LIVEVIDEO
),
694 FE(DDSCAPS_RESERVED2
),
695 FE(DDSCAPS_ALLOCONLOAD
),
696 FE(DDSCAPS_VIDEOPORT
),
697 FE(DDSCAPS_LOCALVIDMEM
),
698 FE(DDSCAPS_NONLOCALVIDMEM
),
699 FE(DDSCAPS_STANDARDVGAMODE
),
700 FE(DDSCAPS_OPTIMIZED
)
702 static const flag_info flags2
[] = {
703 FE(DDSCAPS2_HARDWAREDEINTERLACE
),
704 FE(DDSCAPS2_HINTDYNAMIC
),
705 FE(DDSCAPS2_HINTSTATIC
),
706 FE(DDSCAPS2_TEXTUREMANAGE
),
707 FE(DDSCAPS2_RESERVED1
),
708 FE(DDSCAPS2_RESERVED2
),
710 FE(DDSCAPS2_HINTANTIALIASING
),
711 FE(DDSCAPS2_CUBEMAP
),
712 FE(DDSCAPS2_CUBEMAP_POSITIVEX
),
713 FE(DDSCAPS2_CUBEMAP_NEGATIVEX
),
714 FE(DDSCAPS2_CUBEMAP_POSITIVEY
),
715 FE(DDSCAPS2_CUBEMAP_NEGATIVEY
),
716 FE(DDSCAPS2_CUBEMAP_POSITIVEZ
),
717 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ
),
718 FE(DDSCAPS2_MIPMAPSUBLEVEL
),
719 FE(DDSCAPS2_D3DTEXTUREMANAGE
),
720 FE(DDSCAPS2_DONOTPERSIST
),
721 FE(DDSCAPS2_STEREOSURFACELEFT
)
724 DDRAW_dump_flags_nolf(in
->dwCaps
, flags
, sizeof(flags
)/sizeof(flags
[0]));
725 DDRAW_dump_flags(in
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
729 DDRAW_dump_DDSCAPS(const DDSCAPS
*in
)
733 in_bis
.dwCaps
= in
->dwCaps
;
738 DDRAW_dump_DDSCAPS2(&in_bis
);
742 DDRAW_dump_pixelformat_flag(DWORD flagmask
)
744 static const flag_info flags
[] =
746 FE(DDPF_ALPHAPIXELS
),
749 FE(DDPF_PALETTEINDEXED4
),
750 FE(DDPF_PALETTEINDEXEDTO8
),
751 FE(DDPF_PALETTEINDEXED8
),
757 FE(DDPF_PALETTEINDEXED1
),
758 FE(DDPF_PALETTEINDEXED2
),
762 DDRAW_dump_flags_nolf(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
766 DDRAW_dump_members(DWORD flags
,
768 const member_info
* mems
,
773 for (i
=0; i
< num_mems
; i
++)
775 if (mems
[i
].val
& flags
)
777 TRACE(" - %s : ", mems
[i
].name
);
778 mems
[i
].func((const char *)data
+ mems
[i
].offset
);
784 DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
)
787 DDRAW_dump_pixelformat_flag(pf
->dwFlags
);
788 if (pf
->dwFlags
& DDPF_FOURCC
)
790 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
791 (unsigned char)( pf
->dwFourCC
&0xff),
792 (unsigned char)((pf
->dwFourCC
>> 8)&0xff),
793 (unsigned char)((pf
->dwFourCC
>>16)&0xff),
794 (unsigned char)((pf
->dwFourCC
>>24)&0xff),
799 if (pf
->dwFlags
& DDPF_RGB
)
802 TRACE(", RGB bits: %d, ", pf
->u1
.dwRGBBitCount
);
803 switch (pf
->u1
.dwRGBBitCount
)
805 case 4: cmd
= "%1lx"; break;
806 case 8: cmd
= "%02lx"; break;
807 case 16: cmd
= "%04lx"; break;
808 case 24: cmd
= "%06lx"; break;
809 case 32: cmd
= "%08lx"; break;
810 default: ERR("Unexpected bit depth !\n"); cmd
= "%d"; break;
812 TRACE(" R "); TRACE(cmd
, pf
->u2
.dwRBitMask
);
813 TRACE(" G "); TRACE(cmd
, pf
->u3
.dwGBitMask
);
814 TRACE(" B "); TRACE(cmd
, pf
->u4
.dwBBitMask
);
815 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
)
817 TRACE(" A "); TRACE(cmd
, pf
->u5
.dwRGBAlphaBitMask
);
819 if (pf
->dwFlags
& DDPF_ZPIXELS
)
821 TRACE(" Z "); TRACE(cmd
, pf
->u5
.dwRGBZBitMask
);
824 if (pf
->dwFlags
& DDPF_ZBUFFER
)
826 TRACE(", Z bits : %d", pf
->u1
.dwZBufferBitDepth
);
828 if (pf
->dwFlags
& DDPF_ALPHA
)
830 TRACE(", Alpha bits : %d", pf
->u1
.dwAlphaBitDepth
);
832 if (pf
->dwFlags
& DDPF_BUMPDUDV
)
834 const char *cmd
= "%08lx";
835 TRACE(", Bump bits: %d, ", pf
->u1
.dwBumpBitCount
);
836 TRACE(" U "); TRACE(cmd
, pf
->u2
.dwBumpDuBitMask
);
837 TRACE(" V "); TRACE(cmd
, pf
->u3
.dwBumpDvBitMask
);
838 TRACE(" L "); TRACE(cmd
, pf
->u4
.dwBumpLuminanceBitMask
);
843 void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
)
845 #define STRUCT DDSURFACEDESC2
846 static const member_info members
[] =
848 ME(DDSD_HEIGHT
, DDRAW_dump_DWORD
, dwHeight
),
849 ME(DDSD_WIDTH
, DDRAW_dump_DWORD
, dwWidth
),
850 ME(DDSD_PITCH
, DDRAW_dump_DWORD
, u1
/* lPitch */),
851 ME(DDSD_LINEARSIZE
, DDRAW_dump_DWORD
, u1
/* dwLinearSize */),
852 ME(DDSD_BACKBUFFERCOUNT
, DDRAW_dump_DWORD
, dwBackBufferCount
),
853 ME(DDSD_MIPMAPCOUNT
, DDRAW_dump_DWORD
, u2
/* dwMipMapCount */),
854 ME(DDSD_ZBUFFERBITDEPTH
, DDRAW_dump_DWORD
, u2
/* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
855 ME(DDSD_REFRESHRATE
, DDRAW_dump_DWORD
, u2
/* dwRefreshRate */),
856 ME(DDSD_ALPHABITDEPTH
, DDRAW_dump_DWORD
, dwAlphaBitDepth
),
857 ME(DDSD_LPSURFACE
, DDRAW_dump_PTR
, lpSurface
),
858 ME(DDSD_CKDESTOVERLAY
, DDRAW_dump_DDCOLORKEY
, u3
/* ddckCKDestOverlay */),
859 ME(DDSD_CKDESTBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKDestBlt
),
860 ME(DDSD_CKSRCOVERLAY
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcOverlay
),
861 ME(DDSD_CKSRCBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcBlt
),
862 ME(DDSD_PIXELFORMAT
, DDRAW_dump_pixelformat
, u4
/* ddpfPixelFormat */)
864 static const member_info members_caps
[] =
866 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS
, ddsCaps
)
868 static const member_info members_caps2
[] =
870 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS2
, ddsCaps
)
880 if (lpddsd
->dwSize
>= sizeof(DDSURFACEDESC2
))
882 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps2
, 1);
886 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps
, 1);
888 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members
,
889 sizeof(members
)/sizeof(members
[0]));
894 dump_D3DMATRIX(const D3DMATRIX
*mat
)
896 TRACE(" %f %f %f %f\n", mat
->_11
, mat
->_12
, mat
->_13
, mat
->_14
);
897 TRACE(" %f %f %f %f\n", mat
->_21
, mat
->_22
, mat
->_23
, mat
->_24
);
898 TRACE(" %f %f %f %f\n", mat
->_31
, mat
->_32
, mat
->_33
, mat
->_34
);
899 TRACE(" %f %f %f %f\n", mat
->_41
, mat
->_42
, mat
->_43
, mat
->_44
);
903 get_flexible_vertex_size(DWORD d3dvtVertexType
)
908 if (d3dvtVertexType
& D3DFVF_NORMAL
) size
+= 3 * sizeof(D3DVALUE
);
909 if (d3dvtVertexType
& D3DFVF_DIFFUSE
) size
+= sizeof(DWORD
);
910 if (d3dvtVertexType
& D3DFVF_SPECULAR
) size
+= sizeof(DWORD
);
911 if (d3dvtVertexType
& D3DFVF_RESERVED1
) size
+= sizeof(DWORD
);
912 switch (d3dvtVertexType
& D3DFVF_POSITION_MASK
)
914 case D3DFVF_XYZ
: size
+= 3 * sizeof(D3DVALUE
); break;
915 case D3DFVF_XYZRHW
: size
+= 4 * sizeof(D3DVALUE
); break;
916 case D3DFVF_XYZB1
: size
+= 4 * sizeof(D3DVALUE
); break;
917 case D3DFVF_XYZB2
: size
+= 5 * sizeof(D3DVALUE
); break;
918 case D3DFVF_XYZB3
: size
+= 6 * sizeof(D3DVALUE
); break;
919 case D3DFVF_XYZB4
: size
+= 7 * sizeof(D3DVALUE
); break;
920 case D3DFVF_XYZB5
: size
+= 8 * sizeof(D3DVALUE
); break;
921 default: ERR("Unexpected position mask\n");
923 for (i
= 0; i
< GET_TEXCOUNT_FROM_FVF(d3dvtVertexType
); i
++)
925 size
+= GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType
, i
) * sizeof(D3DVALUE
);
931 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
)
933 /* 2 adds three additional caps fields to the end. Both versions
934 * are unversioned. */
935 pOut
->dwCaps
= pIn
->dwCaps
;
941 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
, DDDEVICEIDENTIFIER
* pOut
)
943 /* 2 adds a dwWHQLLevel field to the end. Both structures are
945 memcpy(pOut
, pIn
, sizeof(*pOut
));
948 void DDRAW_dump_cooperativelevel(DWORD cooplevel
)
950 static const flag_info flags
[] =
952 FE(DDSCL_FULLSCREEN
),
953 FE(DDSCL_ALLOWREBOOT
),
954 FE(DDSCL_NOWINDOWCHANGES
),
956 FE(DDSCL_ALLOWMODEX
),
958 FE(DDSCL_SETFOCUSWINDOW
),
959 FE(DDSCL_SETDEVICEWINDOW
),
960 FE(DDSCL_CREATEDEVICEWINDOW
)
966 DDRAW_dump_flags(cooplevel
, flags
, sizeof(flags
)/sizeof(flags
[0]));
970 void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
)
972 static const flag_info flags1
[] =
975 FE(DDCAPS_ALIGNBOUNDARYDEST
),
976 FE(DDCAPS_ALIGNSIZEDEST
),
977 FE(DDCAPS_ALIGNBOUNDARYSRC
),
978 FE(DDCAPS_ALIGNSIZESRC
),
979 FE(DDCAPS_ALIGNSTRIDE
),
982 FE(DDCAPS_BLTFOURCC
),
983 FE(DDCAPS_BLTSTRETCH
),
986 FE(DDCAPS_OVERLAYCANTCLIP
),
987 FE(DDCAPS_OVERLAYFOURCC
),
988 FE(DDCAPS_OVERLAYSTRETCH
),
990 FE(DDCAPS_PALETTEVSYNC
),
991 FE(DDCAPS_READSCANLINE
),
992 FE(DDCAPS_STEREOVIEW
),
995 FE(DDCAPS_ZOVERLAYS
),
998 FE(DDCAPS_COLORKEYHWASSIST
),
999 FE(DDCAPS_NOHARDWARE
),
1000 FE(DDCAPS_BLTCOLORFILL
),
1001 FE(DDCAPS_BANKSWITCHED
),
1002 FE(DDCAPS_BLTDEPTHFILL
),
1004 FE(DDCAPS_CANCLIPSTRETCHED
),
1005 FE(DDCAPS_CANBLTSYSMEM
)
1007 static const flag_info flags2
[] =
1009 FE(DDCAPS2_CERTIFIED
),
1010 FE(DDCAPS2_NO2DDURING3DSCENE
),
1011 FE(DDCAPS2_VIDEOPORT
),
1012 FE(DDCAPS2_AUTOFLIPOVERLAY
),
1013 FE(DDCAPS2_CANBOBINTERLEAVED
),
1014 FE(DDCAPS2_CANBOBNONINTERLEAVED
),
1015 FE(DDCAPS2_COLORCONTROLOVERLAY
),
1016 FE(DDCAPS2_COLORCONTROLPRIMARY
),
1017 FE(DDCAPS2_CANDROPZ16BIT
),
1018 FE(DDCAPS2_NONLOCALVIDMEM
),
1019 FE(DDCAPS2_NONLOCALVIDMEMCAPS
),
1020 FE(DDCAPS2_NOPAGELOCKREQUIRED
),
1021 FE(DDCAPS2_WIDESURFACES
),
1022 FE(DDCAPS2_CANFLIPODDEVEN
),
1023 FE(DDCAPS2_CANBOBHARDWARE
),
1024 FE(DDCAPS2_COPYFOURCC
),
1025 FE(DDCAPS2_PRIMARYGAMMA
),
1026 FE(DDCAPS2_CANRENDERWINDOWED
),
1027 FE(DDCAPS2_CANCALIBRATEGAMMA
),
1028 FE(DDCAPS2_FLIPINTERVAL
),
1029 FE(DDCAPS2_FLIPNOVSYNC
),
1030 FE(DDCAPS2_CANMANAGETEXTURE
),
1031 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM
),
1033 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL
)
1035 static const flag_info flags3
[] =
1037 FE(DDCKEYCAPS_DESTBLT
),
1038 FE(DDCKEYCAPS_DESTBLTCLRSPACE
),
1039 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV
),
1040 FE(DDCKEYCAPS_DESTBLTYUV
),
1041 FE(DDCKEYCAPS_DESTOVERLAY
),
1042 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE
),
1043 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV
),
1044 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE
),
1045 FE(DDCKEYCAPS_DESTOVERLAYYUV
),
1046 FE(DDCKEYCAPS_SRCBLT
),
1047 FE(DDCKEYCAPS_SRCBLTCLRSPACE
),
1048 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV
),
1049 FE(DDCKEYCAPS_SRCBLTYUV
),
1050 FE(DDCKEYCAPS_SRCOVERLAY
),
1051 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE
),
1052 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV
),
1053 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE
),
1054 FE(DDCKEYCAPS_SRCOVERLAYYUV
),
1055 FE(DDCKEYCAPS_NOCOSTOVERLAY
)
1057 static const flag_info flags4
[] =
1059 FE(DDFXCAPS_BLTALPHA
),
1060 FE(DDFXCAPS_OVERLAYALPHA
),
1061 FE(DDFXCAPS_BLTARITHSTRETCHYN
),
1062 FE(DDFXCAPS_BLTARITHSTRETCHY
),
1063 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT
),
1064 FE(DDFXCAPS_BLTMIRRORUPDOWN
),
1065 FE(DDFXCAPS_BLTROTATION
),
1066 FE(DDFXCAPS_BLTROTATION90
),
1067 FE(DDFXCAPS_BLTSHRINKX
),
1068 FE(DDFXCAPS_BLTSHRINKXN
),
1069 FE(DDFXCAPS_BLTSHRINKY
),
1070 FE(DDFXCAPS_BLTSHRINKYN
),
1071 FE(DDFXCAPS_BLTSTRETCHX
),
1072 FE(DDFXCAPS_BLTSTRETCHXN
),
1073 FE(DDFXCAPS_BLTSTRETCHY
),
1074 FE(DDFXCAPS_BLTSTRETCHYN
),
1075 FE(DDFXCAPS_OVERLAYARITHSTRETCHY
),
1076 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN
),
1077 FE(DDFXCAPS_OVERLAYSHRINKX
),
1078 FE(DDFXCAPS_OVERLAYSHRINKXN
),
1079 FE(DDFXCAPS_OVERLAYSHRINKY
),
1080 FE(DDFXCAPS_OVERLAYSHRINKYN
),
1081 FE(DDFXCAPS_OVERLAYSTRETCHX
),
1082 FE(DDFXCAPS_OVERLAYSTRETCHXN
),
1083 FE(DDFXCAPS_OVERLAYSTRETCHY
),
1084 FE(DDFXCAPS_OVERLAYSTRETCHYN
),
1085 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT
),
1086 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN
)
1088 static const flag_info flags5
[] =
1090 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND
),
1091 FE(DDFXALPHACAPS_BLTALPHAPIXELS
),
1092 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG
),
1093 FE(DDFXALPHACAPS_BLTALPHASURFACES
),
1094 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG
),
1095 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND
),
1096 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS
),
1097 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG
),
1098 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES
),
1099 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG
)
1101 static const flag_info flags6
[] =
1104 FE(DDPCAPS_8BITENTRIES
),
1106 FE(DDPCAPS_INITIALIZE
),
1107 FE(DDPCAPS_PRIMARYSURFACE
),
1108 FE(DDPCAPS_PRIMARYSURFACELEFT
),
1109 FE(DDPCAPS_ALLOW256
),
1115 static const flag_info flags7
[] =
1117 FE(DDSVCAPS_RESERVED1
),
1118 FE(DDSVCAPS_RESERVED2
),
1119 FE(DDSVCAPS_RESERVED3
),
1120 FE(DDSVCAPS_RESERVED4
),
1121 FE(DDSVCAPS_STEREOSEQUENTIAL
),
1124 TRACE(" - dwSize : %d\n", lpcaps
->dwSize
);
1125 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps
->dwCaps
, flags1
, sizeof(flags1
)/sizeof(flags1
[0]));
1126 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
1127 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps
->dwCKeyCaps
, flags3
, sizeof(flags3
)/sizeof(flags3
[0]));
1128 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps
->dwFXCaps
, flags4
, sizeof(flags4
)/sizeof(flags4
[0]));
1129 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps
->dwFXAlphaCaps
, flags5
, sizeof(flags5
)/sizeof(flags5
[0]));
1130 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps
->dwPalCaps
, flags6
, sizeof(flags6
)/sizeof(flags6
[0]));
1131 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps
->dwSVCaps
, flags7
, sizeof(flags7
)/sizeof(flags7
[0]));
1133 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps
->dwNumFourCCCodes
);
1134 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps
->dwCurrVisibleOverlays
);
1135 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps
->dwMinOverlayStretch
);
1136 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps
->dwMaxOverlayStretch
);
1138 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps
->ddsCaps
);
1141 /*****************************************************************************
1144 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1147 * dest: Pointer to the destination matrix
1148 * src1: Pointer to the first source matrix
1149 * src2: Pointer to the second source matrix
1151 *****************************************************************************/
1153 multiply_matrix(D3DMATRIX
*dest
,
1154 const D3DMATRIX
*src1
,
1155 const D3DMATRIX
*src2
)
1159 /* Now do the multiplication 'by hand'.
1160 I know that all this could be optimised, but this will be done later :-) */
1161 temp
._11
= (src1
->_11
* src2
->_11
) + (src1
->_21
* src2
->_12
) + (src1
->_31
* src2
->_13
) + (src1
->_41
* src2
->_14
);
1162 temp
._21
= (src1
->_11
* src2
->_21
) + (src1
->_21
* src2
->_22
) + (src1
->_31
* src2
->_23
) + (src1
->_41
* src2
->_24
);
1163 temp
._31
= (src1
->_11
* src2
->_31
) + (src1
->_21
* src2
->_32
) + (src1
->_31
* src2
->_33
) + (src1
->_41
* src2
->_34
);
1164 temp
._41
= (src1
->_11
* src2
->_41
) + (src1
->_21
* src2
->_42
) + (src1
->_31
* src2
->_43
) + (src1
->_41
* src2
->_44
);
1166 temp
._12
= (src1
->_12
* src2
->_11
) + (src1
->_22
* src2
->_12
) + (src1
->_32
* src2
->_13
) + (src1
->_42
* src2
->_14
);
1167 temp
._22
= (src1
->_12
* src2
->_21
) + (src1
->_22
* src2
->_22
) + (src1
->_32
* src2
->_23
) + (src1
->_42
* src2
->_24
);
1168 temp
._32
= (src1
->_12
* src2
->_31
) + (src1
->_22
* src2
->_32
) + (src1
->_32
* src2
->_33
) + (src1
->_42
* src2
->_34
);
1169 temp
._42
= (src1
->_12
* src2
->_41
) + (src1
->_22
* src2
->_42
) + (src1
->_32
* src2
->_43
) + (src1
->_42
* src2
->_44
);
1171 temp
._13
= (src1
->_13
* src2
->_11
) + (src1
->_23
* src2
->_12
) + (src1
->_33
* src2
->_13
) + (src1
->_43
* src2
->_14
);
1172 temp
._23
= (src1
->_13
* src2
->_21
) + (src1
->_23
* src2
->_22
) + (src1
->_33
* src2
->_23
) + (src1
->_43
* src2
->_24
);
1173 temp
._33
= (src1
->_13
* src2
->_31
) + (src1
->_23
* src2
->_32
) + (src1
->_33
* src2
->_33
) + (src1
->_43
* src2
->_34
);
1174 temp
._43
= (src1
->_13
* src2
->_41
) + (src1
->_23
* src2
->_42
) + (src1
->_33
* src2
->_43
) + (src1
->_43
* src2
->_44
);
1176 temp
._14
= (src1
->_14
* src2
->_11
) + (src1
->_24
* src2
->_12
) + (src1
->_34
* src2
->_13
) + (src1
->_44
* src2
->_14
);
1177 temp
._24
= (src1
->_14
* src2
->_21
) + (src1
->_24
* src2
->_22
) + (src1
->_34
* src2
->_23
) + (src1
->_44
* src2
->_24
);
1178 temp
._34
= (src1
->_14
* src2
->_31
) + (src1
->_24
* src2
->_32
) + (src1
->_34
* src2
->_33
) + (src1
->_44
* src2
->_34
);
1179 temp
._44
= (src1
->_14
* src2
->_41
) + (src1
->_24
* src2
->_42
) + (src1
->_34
* src2
->_43
) + (src1
->_44
* src2
->_44
);
1181 /* And copy the new matrix in the good storage.. */
1182 memcpy(dest
, &temp
, 16 * sizeof(D3DVALUE
));
1187 hr_ddraw_from_wined3d(HRESULT hr
)
1191 case WINED3DERR_INVALIDCALL
: return DDERR_INVALIDPARAMS
;