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
25 #include "wine/port.h"
27 #include "ddraw_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
31 static void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
);
33 void ddrawformat_from_wined3dformat(DDPIXELFORMAT
*DDPixelFormat
, enum wined3d_format_id wined3d_format
)
35 DWORD Size
= DDPixelFormat
->dwSize
;
39 memset(DDPixelFormat
, 0x00, Size
);
40 DDPixelFormat
->dwSize
= Size
;
41 switch (wined3d_format
)
43 case WINED3DFMT_B8G8R8_UNORM
:
44 DDPixelFormat
->dwFlags
= DDPF_RGB
;
45 DDPixelFormat
->dwFourCC
= 0;
46 DDPixelFormat
->u1
.dwRGBBitCount
= 24;
47 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
48 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
49 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
50 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
53 case WINED3DFMT_B8G8R8A8_UNORM
:
54 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
55 DDPixelFormat
->dwFourCC
= 0;
56 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
57 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
58 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
59 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
60 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xff000000;
63 case WINED3DFMT_B8G8R8X8_UNORM
:
64 DDPixelFormat
->dwFlags
= DDPF_RGB
;
65 DDPixelFormat
->dwFourCC
= 0;
66 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
67 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
68 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
69 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
70 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
73 case WINED3DFMT_R8G8B8X8_UNORM
:
74 DDPixelFormat
->dwFlags
= DDPF_RGB
;
75 DDPixelFormat
->dwFourCC
= 0;
76 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
77 DDPixelFormat
->u2
.dwRBitMask
= 0x000000ff;
78 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
79 DDPixelFormat
->u4
.dwBBitMask
= 0x00ff0000;
80 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
83 case WINED3DFMT_B5G6R5_UNORM
:
84 DDPixelFormat
->dwFlags
= DDPF_RGB
;
85 DDPixelFormat
->dwFourCC
= 0;
86 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
87 DDPixelFormat
->u2
.dwRBitMask
= 0xF800;
88 DDPixelFormat
->u3
.dwGBitMask
= 0x07E0;
89 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
90 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
93 case WINED3DFMT_B5G5R5X1_UNORM
:
94 DDPixelFormat
->dwFlags
= DDPF_RGB
;
95 DDPixelFormat
->dwFourCC
= 0;
96 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
97 DDPixelFormat
->u2
.dwRBitMask
= 0x7C00;
98 DDPixelFormat
->u3
.dwGBitMask
= 0x03E0;
99 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
100 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
103 case WINED3DFMT_B5G5R5A1_UNORM
:
104 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
105 DDPixelFormat
->dwFourCC
= 0;
106 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
107 DDPixelFormat
->u2
.dwRBitMask
= 0x7C00;
108 DDPixelFormat
->u3
.dwGBitMask
= 0x03E0;
109 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
110 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x8000;
113 case WINED3DFMT_B4G4R4A4_UNORM
:
114 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
115 DDPixelFormat
->dwFourCC
= 0;
116 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
117 DDPixelFormat
->u2
.dwRBitMask
= 0x0F00;
118 DDPixelFormat
->u3
.dwGBitMask
= 0x00F0;
119 DDPixelFormat
->u4
.dwBBitMask
= 0x000F;
120 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xF000;
123 case WINED3DFMT_B2G3R3_UNORM
:
124 DDPixelFormat
->dwFlags
= DDPF_RGB
;
125 DDPixelFormat
->dwFourCC
= 0;
126 DDPixelFormat
->u1
.dwRGBBitCount
= 8;
127 DDPixelFormat
->u2
.dwRBitMask
= 0xE0;
128 DDPixelFormat
->u3
.dwGBitMask
= 0x1C;
129 DDPixelFormat
->u4
.dwBBitMask
= 0x03;
130 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
133 case WINED3DFMT_P8_UINT
:
134 DDPixelFormat
->dwFlags
= DDPF_PALETTEINDEXED8
| DDPF_RGB
;
135 DDPixelFormat
->dwFourCC
= 0;
136 DDPixelFormat
->u1
.dwRGBBitCount
= 8;
137 DDPixelFormat
->u2
.dwRBitMask
= 0x00;
138 DDPixelFormat
->u3
.dwGBitMask
= 0x00;
139 DDPixelFormat
->u4
.dwBBitMask
= 0x00;
142 case WINED3DFMT_A8_UNORM
:
143 DDPixelFormat
->dwFlags
= DDPF_ALPHA
;
144 DDPixelFormat
->dwFourCC
= 0;
145 DDPixelFormat
->u1
.dwAlphaBitDepth
= 8;
146 DDPixelFormat
->u2
.dwRBitMask
= 0x0;
147 DDPixelFormat
->u3
.dwZBitMask
= 0x0;
148 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
149 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
152 case WINED3DFMT_B2G3R3A8_UNORM
:
153 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
154 DDPixelFormat
->dwFourCC
= 0;
155 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
156 DDPixelFormat
->u2
.dwRBitMask
= 0x00E0;
157 DDPixelFormat
->u3
.dwGBitMask
= 0x001C;
158 DDPixelFormat
->u4
.dwBBitMask
= 0x0003;
159 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xFF00;
162 case WINED3DFMT_B4G4R4X4_UNORM
:
163 DDPixelFormat
->dwFlags
= DDPF_RGB
;
164 DDPixelFormat
->dwFourCC
= 0;
165 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
166 DDPixelFormat
->u2
.dwRBitMask
= 0x0F00;
167 DDPixelFormat
->u3
.dwGBitMask
= 0x00F0;
168 DDPixelFormat
->u4
.dwBBitMask
= 0x000F;
169 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
172 /* How are Z buffer bit depth and Stencil buffer bit depth related?
174 case WINED3DFMT_D16_UNORM
:
175 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
176 DDPixelFormat
->dwFourCC
= 0;
177 DDPixelFormat
->u1
.dwZBufferBitDepth
= 16;
178 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
179 DDPixelFormat
->u3
.dwZBitMask
= 0x0000FFFF;
180 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
181 DDPixelFormat
->u5
.dwRGBZBitMask
= 0x00000000;
184 case WINED3DFMT_D32_UNORM
:
185 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
186 DDPixelFormat
->dwFourCC
= 0;
187 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
188 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
189 DDPixelFormat
->u3
.dwZBitMask
= 0xFFFFFFFF;
190 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
191 DDPixelFormat
->u5
.dwRGBZBitMask
= 0x00000000;
194 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
195 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
196 DDPixelFormat
->dwFourCC
= 0;
197 /* Should I set dwZBufferBitDepth to 32 here? */
198 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
199 DDPixelFormat
->u2
.dwStencilBitDepth
= 4;
200 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
201 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0F000000;
202 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
205 case WINED3DFMT_D24_UNORM_S8_UINT
:
206 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
207 DDPixelFormat
->dwFourCC
= 0;
208 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
209 DDPixelFormat
->u2
.dwStencilBitDepth
= 8;
210 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
211 DDPixelFormat
->u4
.dwStencilBitMask
= 0xFF000000;
212 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
215 case WINED3DFMT_X8D24_UNORM
:
216 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
217 DDPixelFormat
->dwFourCC
= 0;
218 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
219 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
220 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
221 DDPixelFormat
->u4
.dwStencilBitMask
= 0x00000000;
222 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
225 case WINED3DFMT_S1_UINT_D15_UNORM
:
226 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
227 DDPixelFormat
->dwFourCC
= 0;
228 DDPixelFormat
->u1
.dwZBufferBitDepth
= 16;
229 DDPixelFormat
->u2
.dwStencilBitDepth
= 1;
230 DDPixelFormat
->u3
.dwZBitMask
= 0x7fff;
231 DDPixelFormat
->u4
.dwStencilBitMask
= 0x8000;
232 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
235 case WINED3DFMT_UYVY
:
236 case WINED3DFMT_YUY2
:
237 DDPixelFormat
->u1
.dwYUVBitCount
= 16;
238 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
239 DDPixelFormat
->dwFourCC
= wined3d_format
;
242 case WINED3DFMT_YV12
:
243 DDPixelFormat
->u1
.dwYUVBitCount
= 12;
244 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
245 DDPixelFormat
->dwFourCC
= wined3d_format
;
248 case WINED3DFMT_DXT1
:
249 case WINED3DFMT_DXT2
:
250 case WINED3DFMT_DXT3
:
251 case WINED3DFMT_DXT4
:
252 case WINED3DFMT_DXT5
:
253 case WINED3DFMT_MULTI2_ARGB8
:
254 case WINED3DFMT_G8R8_G8B8
:
255 case WINED3DFMT_R8G8_B8G8
:
256 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
257 DDPixelFormat
->dwFourCC
= wined3d_format
;
261 case WINED3DFMT_L8_UNORM
:
262 DDPixelFormat
->dwFlags
= DDPF_LUMINANCE
;
263 DDPixelFormat
->dwFourCC
= 0;
264 DDPixelFormat
->u1
.dwLuminanceBitCount
= 8;
265 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0xff;
266 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
267 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
268 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
271 case WINED3DFMT_L4A4_UNORM
:
272 DDPixelFormat
->dwFlags
= DDPF_ALPHAPIXELS
| DDPF_LUMINANCE
;
273 DDPixelFormat
->dwFourCC
= 0;
274 DDPixelFormat
->u1
.dwLuminanceBitCount
= 4;
275 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0x0f;
276 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
277 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
278 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0xf0;
281 case WINED3DFMT_L8A8_UNORM
:
282 DDPixelFormat
->dwFlags
= DDPF_ALPHAPIXELS
| DDPF_LUMINANCE
;
283 DDPixelFormat
->dwFourCC
= 0;
284 DDPixelFormat
->u1
.dwLuminanceBitCount
= 16;
285 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0x00ff;
286 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
287 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
288 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0xff00;
292 case WINED3DFMT_R8G8_SNORM
:
293 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
;
294 DDPixelFormat
->dwFourCC
= 0;
295 DDPixelFormat
->u1
.dwBumpBitCount
= 16;
296 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x000000ff;
297 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0000ff00;
298 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x00000000;
299 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
302 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
303 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
| DDPF_BUMPLUMINANCE
;
304 DDPixelFormat
->dwFourCC
= 0;
305 DDPixelFormat
->u1
.dwBumpBitCount
= 16;
306 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x0000001f;
307 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x000003e0;
308 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0000fc00;
309 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
312 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
313 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
| DDPF_BUMPLUMINANCE
;
314 DDPixelFormat
->dwFourCC
= 0;
315 DDPixelFormat
->u1
.dwBumpBitCount
= 32;
316 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x000000ff;
317 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0000ff00;
318 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x00ff0000;
319 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
323 FIXME("Unhandled wined3d format %#x.\n", wined3d_format
);
327 if(TRACE_ON(ddraw
)) {
328 TRACE("Returning: ");
329 DDRAW_dump_pixelformat(DDPixelFormat
);
333 enum wined3d_format_id
wined3dformat_from_ddrawformat(const DDPIXELFORMAT
*DDPixelFormat
)
335 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
338 DDRAW_dump_pixelformat(DDPixelFormat
);
341 if(DDPixelFormat
->dwFlags
& DDPF_PALETTEINDEXED8
)
343 return WINED3DFMT_P8_UINT
;
345 else if(DDPixelFormat
->dwFlags
& (DDPF_PALETTEINDEXED1
| DDPF_PALETTEINDEXED2
| DDPF_PALETTEINDEXED4
) )
347 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
348 return WINED3DFMT_P8_UINT
;
350 else if(DDPixelFormat
->dwFlags
& DDPF_RGB
)
352 switch(DDPixelFormat
->u1
.dwRGBBitCount
)
355 /* This is the only format that can match here */
356 return WINED3DFMT_B2G3R3_UNORM
;
359 /* Read the Color masks */
360 if( (DDPixelFormat
->u2
.dwRBitMask
== 0xF800) &&
361 (DDPixelFormat
->u3
.dwGBitMask
== 0x07E0) &&
362 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
364 return WINED3DFMT_B5G6R5_UNORM
;
367 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x7C00) &&
368 (DDPixelFormat
->u3
.dwGBitMask
== 0x03E0) &&
369 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
371 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
372 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0x8000))
373 return WINED3DFMT_B5G5R5A1_UNORM
;
375 return WINED3DFMT_B5G5R5X1_UNORM
;
378 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x0F00) &&
379 (DDPixelFormat
->u3
.dwGBitMask
== 0x00F0) &&
380 (DDPixelFormat
->u4
.dwBBitMask
== 0x000F) )
382 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
383 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xF000))
384 return WINED3DFMT_B4G4R4A4_UNORM
;
386 return WINED3DFMT_B4G4R4X4_UNORM
;
389 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
390 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF00) &&
391 (DDPixelFormat
->u2
.dwRBitMask
== 0x00E0) &&
392 (DDPixelFormat
->u3
.dwGBitMask
== 0x001C) &&
393 (DDPixelFormat
->u4
.dwBBitMask
== 0x0003) )
395 return WINED3DFMT_B2G3R3A8_UNORM
;
397 WARN("16 bit RGB Pixel format does not match.\n");
398 return WINED3DFMT_UNKNOWN
;
401 return WINED3DFMT_B8G8R8_UNORM
;
404 /* Read the Color masks */
405 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x00FF0000) &&
406 (DDPixelFormat
->u3
.dwGBitMask
== 0x0000FF00) &&
407 (DDPixelFormat
->u4
.dwBBitMask
== 0x000000FF) )
409 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
410 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF000000))
411 return WINED3DFMT_B8G8R8A8_UNORM
;
413 return WINED3DFMT_B8G8R8X8_UNORM
;
416 WARN("32 bit RGB pixel format does not match.\n");
417 return WINED3DFMT_UNKNOWN
;
420 WARN("Invalid dwRGBBitCount in Pixelformat structure.\n");
421 return WINED3DFMT_UNKNOWN
;
424 else if( (DDPixelFormat
->dwFlags
& DDPF_ALPHA
) )
426 /* Alpha only Pixelformat */
427 switch(DDPixelFormat
->u1
.dwAlphaBitDepth
)
430 return WINED3DFMT_A8_UNORM
;
433 WARN("Invalid AlphaBitDepth in Alpha-Only Pixelformat.\n");
434 return WINED3DFMT_UNKNOWN
;
437 else if(DDPixelFormat
->dwFlags
& DDPF_LUMINANCE
)
439 /* Luminance-only or luminance-alpha */
440 if(DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
)
442 /* Luminance with Alpha */
443 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
446 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 4)
447 return WINED3DFMT_L4A4_UNORM
;
448 WARN("Unknown Alpha / Luminance bit depth combination.\n");
449 return WINED3DFMT_UNKNOWN
;
452 FIXME("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now.\n");
453 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
456 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 8)
457 return WINED3DFMT_L8A8_UNORM
;
458 WARN("Unknown Alpha / Lumincase bit depth combination.\n");
459 return WINED3DFMT_UNKNOWN
;
465 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
468 FIXME("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now.\n");
469 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
472 return WINED3DFMT_L8_UNORM
;
475 WARN("Unknown luminance-only bit depth 0x%x.\n", DDPixelFormat
->u1
.dwLuminanceBitCount
);
476 return WINED3DFMT_UNKNOWN
;
480 else if(DDPixelFormat
->dwFlags
& DDPF_ZBUFFER
)
483 if(DDPixelFormat
->dwFlags
& DDPF_STENCILBUFFER
)
485 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
488 if (DDPixelFormat
->u2
.dwStencilBitDepth
== 1) return WINED3DFMT_S1_UINT_D15_UNORM
;
489 WARN("Unknown depth stenil format: 16 z bits, %u stencil bits\n",
490 DDPixelFormat
->u2
.dwStencilBitDepth
);
491 return WINED3DFMT_UNKNOWN
;
494 if (DDPixelFormat
->u2
.dwStencilBitDepth
== 8) return WINED3DFMT_D24_UNORM_S8_UINT
;
495 else if (DDPixelFormat
->u2
.dwStencilBitDepth
== 4) return WINED3DFMT_S4X4_UINT_D24_UNORM
;
496 WARN("Unknown depth stenil format: 32 z bits, %u stencil bits\n",
497 DDPixelFormat
->u2
.dwStencilBitDepth
);
498 return WINED3DFMT_UNKNOWN
;
501 WARN("Unknown depth stenil format: %u z bits, %u stencil bits\n",
502 DDPixelFormat
->u1
.dwZBufferBitDepth
, DDPixelFormat
->u2
.dwStencilBitDepth
);
503 return WINED3DFMT_UNKNOWN
;
508 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
511 return WINED3DFMT_D16_UNORM
;
514 return WINED3DFMT_X8D24_UNORM
;
517 if (DDPixelFormat
->u3
.dwZBitMask
== 0x00FFFFFF) return WINED3DFMT_X8D24_UNORM
;
518 else if (DDPixelFormat
->u3
.dwZBitMask
== 0xFFFFFF00) return WINED3DFMT_X8D24_UNORM
;
519 else if (DDPixelFormat
->u3
.dwZBitMask
== 0xFFFFFFFF) return WINED3DFMT_D32_UNORM
;
520 WARN("Unknown depth-only format: 32 z bits, mask 0x%08x\n",
521 DDPixelFormat
->u3
.dwZBitMask
);
522 return WINED3DFMT_UNKNOWN
;
525 WARN("Unknown depth-only format: %u z bits, mask 0x%08x\n",
526 DDPixelFormat
->u1
.dwZBufferBitDepth
, DDPixelFormat
->u3
.dwZBitMask
);
527 return WINED3DFMT_UNKNOWN
;
531 else if(DDPixelFormat
->dwFlags
& DDPF_FOURCC
)
533 return DDPixelFormat
->dwFourCC
;
535 else if(DDPixelFormat
->dwFlags
& DDPF_BUMPDUDV
)
537 if( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
538 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x000000ff) &&
539 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x0000ff00) &&
540 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00000000) )
542 return WINED3DFMT_R8G8_SNORM
;
544 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
545 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x0000001f) &&
546 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x000003e0) &&
547 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x0000fc00) )
549 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
551 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 32 ) &&
552 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x000000ff) &&
553 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x0000ff00) &&
554 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00ff0000) )
556 return WINED3DFMT_R8G8_SNORM_L8X8_UNORM
;
560 WARN("Unknown Pixelformat.\n");
561 return WINED3DFMT_UNKNOWN
;
564 /*****************************************************************************
565 * Various dumping functions.
567 * They write the contents of a specific function to a TRACE.
569 *****************************************************************************/
571 DDRAW_dump_DWORD(const void *in
)
573 TRACE("%d\n", *((const DWORD
*) in
));
576 DDRAW_dump_PTR(const void *in
)
578 TRACE("%p\n", *((const void * const*) in
));
581 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*ddck
)
583 TRACE("Low : 0x%08x - High : 0x%08x\n", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
586 static void DDRAW_dump_flags_nolf(DWORD flags
, const struct flag_info
*names
, size_t num_names
)
590 for (i
=0; i
< num_names
; i
++)
591 if ((flags
& names
[i
].val
) || /* standard flag value */
592 ((!flags
) && (!names
[i
].val
))) /* zero value only */
593 TRACE("%s ", names
[i
].name
);
596 static void DDRAW_dump_flags(DWORD flags
, const struct flag_info
*names
, size_t num_names
)
598 DDRAW_dump_flags_nolf(flags
, names
, num_names
);
602 void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
)
604 static const struct flag_info flags
[] =
606 FE(DDSCAPS_RESERVED1
),
608 FE(DDSCAPS_BACKBUFFER
),
611 FE(DDSCAPS_FRONTBUFFER
),
612 FE(DDSCAPS_OFFSCREENPLAIN
),
615 FE(DDSCAPS_PRIMARYSURFACE
),
616 FE(DDSCAPS_PRIMARYSURFACELEFT
),
617 FE(DDSCAPS_SYSTEMMEMORY
),
619 FE(DDSCAPS_3DDEVICE
),
620 FE(DDSCAPS_VIDEOMEMORY
),
622 FE(DDSCAPS_WRITEONLY
),
625 FE(DDSCAPS_LIVEVIDEO
),
629 FE(DDSCAPS_RESERVED2
),
630 FE(DDSCAPS_ALLOCONLOAD
),
631 FE(DDSCAPS_VIDEOPORT
),
632 FE(DDSCAPS_LOCALVIDMEM
),
633 FE(DDSCAPS_NONLOCALVIDMEM
),
634 FE(DDSCAPS_STANDARDVGAMODE
),
635 FE(DDSCAPS_OPTIMIZED
)
637 static const struct flag_info flags2
[] =
639 FE(DDSCAPS2_HARDWAREDEINTERLACE
),
640 FE(DDSCAPS2_HINTDYNAMIC
),
641 FE(DDSCAPS2_HINTSTATIC
),
642 FE(DDSCAPS2_TEXTUREMANAGE
),
643 FE(DDSCAPS2_RESERVED1
),
644 FE(DDSCAPS2_RESERVED2
),
646 FE(DDSCAPS2_HINTANTIALIASING
),
647 FE(DDSCAPS2_CUBEMAP
),
648 FE(DDSCAPS2_CUBEMAP_POSITIVEX
),
649 FE(DDSCAPS2_CUBEMAP_NEGATIVEX
),
650 FE(DDSCAPS2_CUBEMAP_POSITIVEY
),
651 FE(DDSCAPS2_CUBEMAP_NEGATIVEY
),
652 FE(DDSCAPS2_CUBEMAP_POSITIVEZ
),
653 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ
),
654 FE(DDSCAPS2_MIPMAPSUBLEVEL
),
655 FE(DDSCAPS2_D3DTEXTUREMANAGE
),
656 FE(DDSCAPS2_DONOTPERSIST
),
657 FE(DDSCAPS2_STEREOSURFACELEFT
)
660 DDRAW_dump_flags_nolf(in
->dwCaps
, flags
, sizeof(flags
)/sizeof(flags
[0]));
661 DDRAW_dump_flags(in
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
665 DDRAW_dump_DDSCAPS(const DDSCAPS
*in
)
669 in_bis
.dwCaps
= in
->dwCaps
;
672 in_bis
.u1
.dwCaps4
= 0;
674 DDRAW_dump_DDSCAPS2(&in_bis
);
678 DDRAW_dump_pixelformat_flag(DWORD flagmask
)
680 static const struct flag_info flags
[] =
682 FE(DDPF_ALPHAPIXELS
),
685 FE(DDPF_PALETTEINDEXED4
),
686 FE(DDPF_PALETTEINDEXEDTO8
),
687 FE(DDPF_PALETTEINDEXED8
),
693 FE(DDPF_PALETTEINDEXED1
),
694 FE(DDPF_PALETTEINDEXED2
),
698 DDRAW_dump_flags_nolf(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
701 static void DDRAW_dump_members(DWORD flags
, const void *data
, const struct member_info
*mems
, size_t num_mems
)
705 for (i
=0; i
< num_mems
; i
++)
707 if (mems
[i
].val
& flags
)
709 TRACE(" - %s : ", mems
[i
].name
);
710 mems
[i
].func((const char *)data
+ mems
[i
].offset
);
716 DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
)
719 DDRAW_dump_pixelformat_flag(pf
->dwFlags
);
720 if (pf
->dwFlags
& DDPF_FOURCC
)
721 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %u bits per pixel",
722 (unsigned char)( pf
->dwFourCC
&0xff),
723 (unsigned char)((pf
->dwFourCC
>> 8)&0xff),
724 (unsigned char)((pf
->dwFourCC
>>16)&0xff),
725 (unsigned char)((pf
->dwFourCC
>>24)&0xff),
727 pf
->u1
.dwYUVBitCount
);
728 if (pf
->dwFlags
& DDPF_RGB
)
730 TRACE(", RGB bits: %u, R 0x%08x G 0x%08x B 0x%08x",
731 pf
->u1
.dwRGBBitCount
,
735 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
)
736 TRACE(" A 0x%08x", pf
->u5
.dwRGBAlphaBitMask
);
737 if (pf
->dwFlags
& DDPF_ZPIXELS
)
738 TRACE(" Z 0x%08x", pf
->u5
.dwRGBZBitMask
);
740 if (pf
->dwFlags
& DDPF_ZBUFFER
)
741 TRACE(", Z bits: %u", pf
->u1
.dwZBufferBitDepth
);
742 if (pf
->dwFlags
& DDPF_ALPHA
)
743 TRACE(", Alpha bits: %u", pf
->u1
.dwAlphaBitDepth
);
744 if (pf
->dwFlags
& DDPF_BUMPDUDV
)
745 TRACE(", Bump bits: %u, U 0x%08x V 0x%08x L 0x%08x",
746 pf
->u1
.dwBumpBitCount
,
747 pf
->u2
.dwBumpDuBitMask
,
748 pf
->u3
.dwBumpDvBitMask
,
749 pf
->u4
.dwBumpLuminanceBitMask
);
753 void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
)
755 #define STRUCT DDSURFACEDESC2
756 static const struct member_info members
[] =
758 ME(DDSD_HEIGHT
, DDRAW_dump_DWORD
, dwHeight
),
759 ME(DDSD_WIDTH
, DDRAW_dump_DWORD
, dwWidth
),
760 ME(DDSD_PITCH
, DDRAW_dump_DWORD
, u1
/* lPitch */),
761 ME(DDSD_LINEARSIZE
, DDRAW_dump_DWORD
, u1
/* dwLinearSize */),
762 ME(DDSD_BACKBUFFERCOUNT
, DDRAW_dump_DWORD
, u5
.dwBackBufferCount
),
763 ME(DDSD_MIPMAPCOUNT
, DDRAW_dump_DWORD
, u2
/* dwMipMapCount */),
764 ME(DDSD_ZBUFFERBITDEPTH
, DDRAW_dump_DWORD
, u2
/* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
765 ME(DDSD_REFRESHRATE
, DDRAW_dump_DWORD
, u2
/* dwRefreshRate */),
766 ME(DDSD_ALPHABITDEPTH
, DDRAW_dump_DWORD
, dwAlphaBitDepth
),
767 ME(DDSD_LPSURFACE
, DDRAW_dump_PTR
, lpSurface
),
768 ME(DDSD_CKDESTOVERLAY
, DDRAW_dump_DDCOLORKEY
, u3
/* ddckCKDestOverlay */),
769 ME(DDSD_CKDESTBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKDestBlt
),
770 ME(DDSD_CKSRCOVERLAY
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcOverlay
),
771 ME(DDSD_CKSRCBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcBlt
),
772 ME(DDSD_PIXELFORMAT
, DDRAW_dump_pixelformat
, u4
/* ddpfPixelFormat */)
774 static const struct member_info members_caps
[] =
776 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS
, ddsCaps
)
778 static const struct member_info members_caps2
[] =
780 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS2
, ddsCaps
)
790 if (lpddsd
->dwSize
>= sizeof(DDSURFACEDESC2
))
792 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps2
, 1);
796 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps
, 1);
798 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members
,
799 sizeof(members
)/sizeof(members
[0]));
804 dump_D3DMATRIX(const D3DMATRIX
*mat
)
806 TRACE(" %f %f %f %f\n", mat
->_11
, mat
->_12
, mat
->_13
, mat
->_14
);
807 TRACE(" %f %f %f %f\n", mat
->_21
, mat
->_22
, mat
->_23
, mat
->_24
);
808 TRACE(" %f %f %f %f\n", mat
->_31
, mat
->_32
, mat
->_33
, mat
->_34
);
809 TRACE(" %f %f %f %f\n", mat
->_41
, mat
->_42
, mat
->_43
, mat
->_44
);
813 get_flexible_vertex_size(DWORD d3dvtVertexType
)
818 if (d3dvtVertexType
& D3DFVF_NORMAL
) size
+= 3 * sizeof(D3DVALUE
);
819 if (d3dvtVertexType
& D3DFVF_DIFFUSE
) size
+= sizeof(DWORD
);
820 if (d3dvtVertexType
& D3DFVF_SPECULAR
) size
+= sizeof(DWORD
);
821 if (d3dvtVertexType
& D3DFVF_RESERVED1
) size
+= sizeof(DWORD
);
822 switch (d3dvtVertexType
& D3DFVF_POSITION_MASK
)
824 case D3DFVF_XYZ
: size
+= 3 * sizeof(D3DVALUE
); break;
825 case D3DFVF_XYZRHW
: size
+= 4 * sizeof(D3DVALUE
); break;
826 case D3DFVF_XYZB1
: size
+= 4 * sizeof(D3DVALUE
); break;
827 case D3DFVF_XYZB2
: size
+= 5 * sizeof(D3DVALUE
); break;
828 case D3DFVF_XYZB3
: size
+= 6 * sizeof(D3DVALUE
); break;
829 case D3DFVF_XYZB4
: size
+= 7 * sizeof(D3DVALUE
); break;
830 case D3DFVF_XYZB5
: size
+= 8 * sizeof(D3DVALUE
); break;
831 default: ERR("Unexpected position mask\n");
833 for (i
= 0; i
< GET_TEXCOUNT_FROM_FVF(d3dvtVertexType
); i
++)
835 size
+= GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType
, i
) * sizeof(D3DVALUE
);
841 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
)
843 /* 2 adds three additional caps fields to the end. Both versions
844 * are unversioned. */
845 pOut
->dwCaps
= pIn
->dwCaps
;
848 pOut
->u1
.dwCaps4
= 0;
851 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
, DDDEVICEIDENTIFIER
* pOut
)
853 /* 2 adds a dwWHQLLevel field to the end. Both structures are
855 memcpy(pOut
, pIn
, sizeof(*pOut
));
858 void DDRAW_dump_cooperativelevel(DWORD cooplevel
)
860 static const struct flag_info flags
[] =
862 FE(DDSCL_FULLSCREEN
),
863 FE(DDSCL_ALLOWREBOOT
),
864 FE(DDSCL_NOWINDOWCHANGES
),
866 FE(DDSCL_ALLOWMODEX
),
868 FE(DDSCL_SETFOCUSWINDOW
),
869 FE(DDSCL_SETDEVICEWINDOW
),
870 FE(DDSCL_CREATEDEVICEWINDOW
)
876 DDRAW_dump_flags(cooplevel
, flags
, sizeof(flags
)/sizeof(flags
[0]));
880 void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
)
882 static const struct flag_info flags1
[] =
885 FE(DDCAPS_ALIGNBOUNDARYDEST
),
886 FE(DDCAPS_ALIGNSIZEDEST
),
887 FE(DDCAPS_ALIGNBOUNDARYSRC
),
888 FE(DDCAPS_ALIGNSIZESRC
),
889 FE(DDCAPS_ALIGNSTRIDE
),
892 FE(DDCAPS_BLTFOURCC
),
893 FE(DDCAPS_BLTSTRETCH
),
896 FE(DDCAPS_OVERLAYCANTCLIP
),
897 FE(DDCAPS_OVERLAYFOURCC
),
898 FE(DDCAPS_OVERLAYSTRETCH
),
900 FE(DDCAPS_PALETTEVSYNC
),
901 FE(DDCAPS_READSCANLINE
),
902 FE(DDCAPS_STEREOVIEW
),
905 FE(DDCAPS_ZOVERLAYS
),
908 FE(DDCAPS_COLORKEYHWASSIST
),
909 FE(DDCAPS_NOHARDWARE
),
910 FE(DDCAPS_BLTCOLORFILL
),
911 FE(DDCAPS_BANKSWITCHED
),
912 FE(DDCAPS_BLTDEPTHFILL
),
914 FE(DDCAPS_CANCLIPSTRETCHED
),
915 FE(DDCAPS_CANBLTSYSMEM
)
917 static const struct flag_info flags2
[] =
919 FE(DDCAPS2_CERTIFIED
),
920 FE(DDCAPS2_NO2DDURING3DSCENE
),
921 FE(DDCAPS2_VIDEOPORT
),
922 FE(DDCAPS2_AUTOFLIPOVERLAY
),
923 FE(DDCAPS2_CANBOBINTERLEAVED
),
924 FE(DDCAPS2_CANBOBNONINTERLEAVED
),
925 FE(DDCAPS2_COLORCONTROLOVERLAY
),
926 FE(DDCAPS2_COLORCONTROLPRIMARY
),
927 FE(DDCAPS2_CANDROPZ16BIT
),
928 FE(DDCAPS2_NONLOCALVIDMEM
),
929 FE(DDCAPS2_NONLOCALVIDMEMCAPS
),
930 FE(DDCAPS2_NOPAGELOCKREQUIRED
),
931 FE(DDCAPS2_WIDESURFACES
),
932 FE(DDCAPS2_CANFLIPODDEVEN
),
933 FE(DDCAPS2_CANBOBHARDWARE
),
934 FE(DDCAPS2_COPYFOURCC
),
935 FE(DDCAPS2_PRIMARYGAMMA
),
936 FE(DDCAPS2_CANRENDERWINDOWED
),
937 FE(DDCAPS2_CANCALIBRATEGAMMA
),
938 FE(DDCAPS2_FLIPINTERVAL
),
939 FE(DDCAPS2_FLIPNOVSYNC
),
940 FE(DDCAPS2_CANMANAGETEXTURE
),
941 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM
),
943 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL
)
945 static const struct flag_info flags3
[] =
947 FE(DDCKEYCAPS_DESTBLT
),
948 FE(DDCKEYCAPS_DESTBLTCLRSPACE
),
949 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV
),
950 FE(DDCKEYCAPS_DESTBLTYUV
),
951 FE(DDCKEYCAPS_DESTOVERLAY
),
952 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE
),
953 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV
),
954 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE
),
955 FE(DDCKEYCAPS_DESTOVERLAYYUV
),
956 FE(DDCKEYCAPS_SRCBLT
),
957 FE(DDCKEYCAPS_SRCBLTCLRSPACE
),
958 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV
),
959 FE(DDCKEYCAPS_SRCBLTYUV
),
960 FE(DDCKEYCAPS_SRCOVERLAY
),
961 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE
),
962 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV
),
963 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE
),
964 FE(DDCKEYCAPS_SRCOVERLAYYUV
),
965 FE(DDCKEYCAPS_NOCOSTOVERLAY
)
967 static const struct flag_info flags4
[] =
969 FE(DDFXCAPS_BLTALPHA
),
970 FE(DDFXCAPS_OVERLAYALPHA
),
971 FE(DDFXCAPS_BLTARITHSTRETCHYN
),
972 FE(DDFXCAPS_BLTARITHSTRETCHY
),
973 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT
),
974 FE(DDFXCAPS_BLTMIRRORUPDOWN
),
975 FE(DDFXCAPS_BLTROTATION
),
976 FE(DDFXCAPS_BLTROTATION90
),
977 FE(DDFXCAPS_BLTSHRINKX
),
978 FE(DDFXCAPS_BLTSHRINKXN
),
979 FE(DDFXCAPS_BLTSHRINKY
),
980 FE(DDFXCAPS_BLTSHRINKYN
),
981 FE(DDFXCAPS_BLTSTRETCHX
),
982 FE(DDFXCAPS_BLTSTRETCHXN
),
983 FE(DDFXCAPS_BLTSTRETCHY
),
984 FE(DDFXCAPS_BLTSTRETCHYN
),
985 FE(DDFXCAPS_OVERLAYARITHSTRETCHY
),
986 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN
),
987 FE(DDFXCAPS_OVERLAYSHRINKX
),
988 FE(DDFXCAPS_OVERLAYSHRINKXN
),
989 FE(DDFXCAPS_OVERLAYSHRINKY
),
990 FE(DDFXCAPS_OVERLAYSHRINKYN
),
991 FE(DDFXCAPS_OVERLAYSTRETCHX
),
992 FE(DDFXCAPS_OVERLAYSTRETCHXN
),
993 FE(DDFXCAPS_OVERLAYSTRETCHY
),
994 FE(DDFXCAPS_OVERLAYSTRETCHYN
),
995 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT
),
996 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN
)
998 static const struct flag_info flags5
[] =
1000 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND
),
1001 FE(DDFXALPHACAPS_BLTALPHAPIXELS
),
1002 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG
),
1003 FE(DDFXALPHACAPS_BLTALPHASURFACES
),
1004 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG
),
1005 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND
),
1006 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS
),
1007 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG
),
1008 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES
),
1009 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG
)
1011 static const struct flag_info flags6
[] =
1014 FE(DDPCAPS_8BITENTRIES
),
1016 FE(DDPCAPS_INITIALIZE
),
1017 FE(DDPCAPS_PRIMARYSURFACE
),
1018 FE(DDPCAPS_PRIMARYSURFACELEFT
),
1019 FE(DDPCAPS_ALLOW256
),
1025 static const struct flag_info flags7
[] =
1027 FE(DDSVCAPS_RESERVED1
),
1028 FE(DDSVCAPS_RESERVED2
),
1029 FE(DDSVCAPS_RESERVED3
),
1030 FE(DDSVCAPS_RESERVED4
),
1031 FE(DDSVCAPS_STEREOSEQUENTIAL
),
1034 TRACE(" - dwSize : %d\n", lpcaps
->dwSize
);
1035 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps
->dwCaps
, flags1
, sizeof(flags1
)/sizeof(flags1
[0]));
1036 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
1037 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps
->dwCKeyCaps
, flags3
, sizeof(flags3
)/sizeof(flags3
[0]));
1038 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps
->dwFXCaps
, flags4
, sizeof(flags4
)/sizeof(flags4
[0]));
1039 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps
->dwFXAlphaCaps
, flags5
, sizeof(flags5
)/sizeof(flags5
[0]));
1040 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps
->dwPalCaps
, flags6
, sizeof(flags6
)/sizeof(flags6
[0]));
1041 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps
->dwSVCaps
, flags7
, sizeof(flags7
)/sizeof(flags7
[0]));
1043 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps
->dwNumFourCCCodes
);
1044 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps
->dwCurrVisibleOverlays
);
1045 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps
->dwMinOverlayStretch
);
1046 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps
->dwMaxOverlayStretch
);
1048 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps
->ddsCaps
);
1051 /*****************************************************************************
1054 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1057 * dest: Pointer to the destination matrix
1058 * src1: Pointer to the first source matrix
1059 * src2: Pointer to the second source matrix
1061 *****************************************************************************/
1063 multiply_matrix(D3DMATRIX
*dest
,
1064 const D3DMATRIX
*src1
,
1065 const D3DMATRIX
*src2
)
1069 /* Now do the multiplication 'by hand'.
1070 I know that all this could be optimised, but this will be done later :-) */
1071 temp
._11
= (src1
->_11
* src2
->_11
) + (src1
->_21
* src2
->_12
) + (src1
->_31
* src2
->_13
) + (src1
->_41
* src2
->_14
);
1072 temp
._21
= (src1
->_11
* src2
->_21
) + (src1
->_21
* src2
->_22
) + (src1
->_31
* src2
->_23
) + (src1
->_41
* src2
->_24
);
1073 temp
._31
= (src1
->_11
* src2
->_31
) + (src1
->_21
* src2
->_32
) + (src1
->_31
* src2
->_33
) + (src1
->_41
* src2
->_34
);
1074 temp
._41
= (src1
->_11
* src2
->_41
) + (src1
->_21
* src2
->_42
) + (src1
->_31
* src2
->_43
) + (src1
->_41
* src2
->_44
);
1076 temp
._12
= (src1
->_12
* src2
->_11
) + (src1
->_22
* src2
->_12
) + (src1
->_32
* src2
->_13
) + (src1
->_42
* src2
->_14
);
1077 temp
._22
= (src1
->_12
* src2
->_21
) + (src1
->_22
* src2
->_22
) + (src1
->_32
* src2
->_23
) + (src1
->_42
* src2
->_24
);
1078 temp
._32
= (src1
->_12
* src2
->_31
) + (src1
->_22
* src2
->_32
) + (src1
->_32
* src2
->_33
) + (src1
->_42
* src2
->_34
);
1079 temp
._42
= (src1
->_12
* src2
->_41
) + (src1
->_22
* src2
->_42
) + (src1
->_32
* src2
->_43
) + (src1
->_42
* src2
->_44
);
1081 temp
._13
= (src1
->_13
* src2
->_11
) + (src1
->_23
* src2
->_12
) + (src1
->_33
* src2
->_13
) + (src1
->_43
* src2
->_14
);
1082 temp
._23
= (src1
->_13
* src2
->_21
) + (src1
->_23
* src2
->_22
) + (src1
->_33
* src2
->_23
) + (src1
->_43
* src2
->_24
);
1083 temp
._33
= (src1
->_13
* src2
->_31
) + (src1
->_23
* src2
->_32
) + (src1
->_33
* src2
->_33
) + (src1
->_43
* src2
->_34
);
1084 temp
._43
= (src1
->_13
* src2
->_41
) + (src1
->_23
* src2
->_42
) + (src1
->_33
* src2
->_43
) + (src1
->_43
* src2
->_44
);
1086 temp
._14
= (src1
->_14
* src2
->_11
) + (src1
->_24
* src2
->_12
) + (src1
->_34
* src2
->_13
) + (src1
->_44
* src2
->_14
);
1087 temp
._24
= (src1
->_14
* src2
->_21
) + (src1
->_24
* src2
->_22
) + (src1
->_34
* src2
->_23
) + (src1
->_44
* src2
->_24
);
1088 temp
._34
= (src1
->_14
* src2
->_31
) + (src1
->_24
* src2
->_32
) + (src1
->_34
* src2
->_33
) + (src1
->_44
* src2
->_34
);
1089 temp
._44
= (src1
->_14
* src2
->_41
) + (src1
->_24
* src2
->_42
) + (src1
->_34
* src2
->_43
) + (src1
->_44
* src2
->_44
);
1091 /* And copy the new matrix in the good storage.. */
1092 memcpy(dest
, &temp
, 16 * sizeof(D3DVALUE
));
1096 hr_ddraw_from_wined3d(HRESULT hr
)
1100 case WINED3DERR_INVALIDCALL
: return DDERR_INVALIDPARAMS
;
1105 /* Note that this function writes the full sizeof(DDSURFACEDESC2) size, don't use it
1106 * for writing into application-provided DDSURFACEDESC2 structures if the size may
1108 void DDSD_to_DDSD2(const DDSURFACEDESC
*in
, DDSURFACEDESC2
*out
)
1110 /* The output of this function is never passed to the application directly, so
1111 * the memset is not strictly needed. CreateSurface still has problems with this
1112 * though. Don't forget to set ddsCaps.dwCaps2/3/4 to 0 when removing this */
1113 memset(out
, 0x00, sizeof(*out
));
1114 out
->dwSize
= sizeof(*out
);
1115 out
->dwFlags
= in
->dwFlags
& ~DDSD_ZBUFFERBITDEPTH
;
1116 if (in
->dwFlags
& DDSD_WIDTH
) out
->dwWidth
= in
->dwWidth
;
1117 if (in
->dwFlags
& DDSD_HEIGHT
) out
->dwHeight
= in
->dwHeight
;
1118 if (in
->dwFlags
& DDSD_PIXELFORMAT
) out
->u4
.ddpfPixelFormat
= in
->ddpfPixelFormat
;
1119 else if(in
->dwFlags
& DDSD_ZBUFFERBITDEPTH
)
1121 out
->dwFlags
|= DDSD_PIXELFORMAT
;
1122 memset(&out
->u4
.ddpfPixelFormat
, 0, sizeof(out
->u4
.ddpfPixelFormat
));
1123 out
->u4
.ddpfPixelFormat
.dwSize
= sizeof(out
->u4
.ddpfPixelFormat
);
1124 out
->u4
.ddpfPixelFormat
.dwFlags
= DDPF_ZBUFFER
;
1125 out
->u4
.ddpfPixelFormat
.u1
.dwZBufferBitDepth
= in
->u2
.dwZBufferBitDepth
;
1126 /* 0 is not a valid DDSURFACEDESC / DDPIXELFORMAT on either side of the
1128 out
->u4
.ddpfPixelFormat
.u3
.dwZBitMask
= ~0U >> (32 - in
->u2
.dwZBufferBitDepth
);
1130 /* ddsCaps is read even without DDSD_CAPS set. See dsurface:no_ddsd_caps_test */
1131 out
->ddsCaps
.dwCaps
= in
->ddsCaps
.dwCaps
;
1132 if (in
->dwFlags
& DDSD_PITCH
) out
->u1
.lPitch
= in
->u1
.lPitch
;
1133 if (in
->dwFlags
& DDSD_BACKBUFFERCOUNT
) out
->u5
.dwBackBufferCount
= in
->dwBackBufferCount
;
1134 if (in
->dwFlags
& DDSD_ALPHABITDEPTH
) out
->dwAlphaBitDepth
= in
->dwAlphaBitDepth
;
1135 /* DDraw(native, and wine) does not set the DDSD_LPSURFACE, so always copy */
1136 out
->lpSurface
= in
->lpSurface
;
1137 if (in
->dwFlags
& DDSD_CKDESTOVERLAY
) out
->u3
.ddckCKDestOverlay
= in
->ddckCKDestOverlay
;
1138 if (in
->dwFlags
& DDSD_CKDESTBLT
) out
->ddckCKDestBlt
= in
->ddckCKDestBlt
;
1139 if (in
->dwFlags
& DDSD_CKSRCOVERLAY
) out
->ddckCKSrcOverlay
= in
->ddckCKSrcOverlay
;
1140 if (in
->dwFlags
& DDSD_CKSRCBLT
) out
->ddckCKSrcBlt
= in
->ddckCKSrcBlt
;
1141 if (in
->dwFlags
& DDSD_MIPMAPCOUNT
) out
->u2
.dwMipMapCount
= in
->u2
.dwMipMapCount
;
1142 if (in
->dwFlags
& DDSD_REFRESHRATE
) out
->u2
.dwRefreshRate
= in
->u2
.dwRefreshRate
;
1143 if (in
->dwFlags
& DDSD_LINEARSIZE
) out
->u1
.dwLinearSize
= in
->u1
.dwLinearSize
;
1144 /* Does not exist in DDSURFACEDESC:
1145 * DDSD_TEXTURESTAGE, DDSD_FVF, DDSD_SRCVBHANDLE,
1149 /* Note that this function writes the full sizeof(DDSURFACEDESC) size, don't use it
1150 * for writing into application-provided DDSURFACEDESC structures if the size may
1152 void DDSD2_to_DDSD(const DDSURFACEDESC2
*in
, DDSURFACEDESC
*out
)
1154 memset(out
, 0, sizeof(*out
));
1155 out
->dwSize
= sizeof(*out
);
1156 out
->dwFlags
= in
->dwFlags
;
1157 if (in
->dwFlags
& DDSD_WIDTH
) out
->dwWidth
= in
->dwWidth
;
1158 if (in
->dwFlags
& DDSD_HEIGHT
) out
->dwHeight
= in
->dwHeight
;
1159 if (in
->dwFlags
& DDSD_PIXELFORMAT
)
1161 out
->ddpfPixelFormat
= in
->u4
.ddpfPixelFormat
;
1162 if ((in
->dwFlags
& DDSD_CAPS
) && (in
->ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
))
1164 /* Z buffers have DDSD_ZBUFFERBITDEPTH set, but not DDSD_PIXELFORMAT. They do
1165 * have valid data in ddpfPixelFormat though */
1166 out
->dwFlags
&= ~DDSD_PIXELFORMAT
;
1167 out
->dwFlags
|= DDSD_ZBUFFERBITDEPTH
;
1168 out
->u2
.dwZBufferBitDepth
= in
->u4
.ddpfPixelFormat
.u1
.dwZBufferBitDepth
;
1171 /* ddsCaps is read even without DDSD_CAPS set. See dsurface:no_ddsd_caps_test */
1172 out
->ddsCaps
.dwCaps
= in
->ddsCaps
.dwCaps
;
1173 if (in
->dwFlags
& DDSD_PITCH
) out
->u1
.lPitch
= in
->u1
.lPitch
;
1174 if (in
->dwFlags
& DDSD_BACKBUFFERCOUNT
) out
->dwBackBufferCount
= in
->u5
.dwBackBufferCount
;
1175 if (in
->dwFlags
& DDSD_ZBUFFERBITDEPTH
) out
->u2
.dwZBufferBitDepth
= in
->u2
.dwMipMapCount
; /* same union */
1176 if (in
->dwFlags
& DDSD_ALPHABITDEPTH
) out
->dwAlphaBitDepth
= in
->dwAlphaBitDepth
;
1177 /* DDraw(native, and wine) does not set the DDSD_LPSURFACE, so always copy */
1178 out
->lpSurface
= in
->lpSurface
;
1179 if (in
->dwFlags
& DDSD_CKDESTOVERLAY
) out
->ddckCKDestOverlay
= in
->u3
.ddckCKDestOverlay
;
1180 if (in
->dwFlags
& DDSD_CKDESTBLT
) out
->ddckCKDestBlt
= in
->ddckCKDestBlt
;
1181 if (in
->dwFlags
& DDSD_CKSRCOVERLAY
) out
->ddckCKSrcOverlay
= in
->ddckCKSrcOverlay
;
1182 if (in
->dwFlags
& DDSD_CKSRCBLT
) out
->ddckCKSrcBlt
= in
->ddckCKSrcBlt
;
1183 if (in
->dwFlags
& DDSD_MIPMAPCOUNT
) out
->u2
.dwMipMapCount
= in
->u2
.dwMipMapCount
;
1184 if (in
->dwFlags
& DDSD_REFRESHRATE
) out
->u2
.dwRefreshRate
= in
->u2
.dwRefreshRate
;
1185 if (in
->dwFlags
& DDSD_LINEARSIZE
) out
->u1
.dwLinearSize
= in
->u1
.dwLinearSize
;
1186 /* Does not exist in DDSURFACEDESC:
1187 * DDSD_TEXTURESTAGE, DDSD_FVF, DDSD_SRCVBHANDLE,
1189 if (in
->dwFlags
& DDSD_TEXTURESTAGE
) WARN("Does not exist in DDSURFACEDESC: DDSD_TEXTURESTAGE\n");
1190 if (in
->dwFlags
& DDSD_FVF
) WARN("Does not exist in DDSURFACEDESC: DDSD_FVF\n");
1191 if (in
->dwFlags
& DDSD_SRCVBHANDLE
) WARN("Does not exist in DDSURFACEDESC: DDSD_SRCVBHANDLE\n");
1192 out
->dwFlags
&= ~(DDSD_TEXTURESTAGE
| DDSD_FVF
| DDSD_SRCVBHANDLE
);