2 * DirectDraw helper functions
4 * Copyright (c) 1997-2000 Marcus Meissner
5 * Copyright (c) 1998 Lionel Ulmer
6 * Copyright (c) 2000 TransGaming Technologies Inc.
7 * Copyright (c) 2006 Stefan Dösinger
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "ddraw_private.h"
26 static void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
);
28 void ddrawformat_from_wined3dformat(DDPIXELFORMAT
*DDPixelFormat
, enum wined3d_format_id wined3d_format
)
30 DWORD Size
= DDPixelFormat
->dwSize
;
34 memset(DDPixelFormat
, 0x00, Size
);
35 DDPixelFormat
->dwSize
= Size
;
36 switch (wined3d_format
)
38 case WINED3DFMT_B8G8R8_UNORM
:
39 DDPixelFormat
->dwFlags
= DDPF_RGB
;
40 DDPixelFormat
->dwFourCC
= 0;
41 DDPixelFormat
->u1
.dwRGBBitCount
= 24;
42 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
43 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
44 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
45 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
48 case WINED3DFMT_B8G8R8A8_UNORM
:
49 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
50 DDPixelFormat
->dwFourCC
= 0;
51 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
52 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
53 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
54 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
55 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xff000000;
58 case WINED3DFMT_B8G8R8X8_UNORM
:
59 DDPixelFormat
->dwFlags
= DDPF_RGB
;
60 DDPixelFormat
->dwFourCC
= 0;
61 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
62 DDPixelFormat
->u2
.dwRBitMask
= 0x00ff0000;
63 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
64 DDPixelFormat
->u4
.dwBBitMask
= 0x000000ff;
65 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
68 case WINED3DFMT_R8G8B8X8_UNORM
:
69 DDPixelFormat
->dwFlags
= DDPF_RGB
;
70 DDPixelFormat
->dwFourCC
= 0;
71 DDPixelFormat
->u1
.dwRGBBitCount
= 32;
72 DDPixelFormat
->u2
.dwRBitMask
= 0x000000ff;
73 DDPixelFormat
->u3
.dwGBitMask
= 0x0000ff00;
74 DDPixelFormat
->u4
.dwBBitMask
= 0x00ff0000;
75 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
78 case WINED3DFMT_B5G6R5_UNORM
:
79 DDPixelFormat
->dwFlags
= DDPF_RGB
;
80 DDPixelFormat
->dwFourCC
= 0;
81 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
82 DDPixelFormat
->u2
.dwRBitMask
= 0xF800;
83 DDPixelFormat
->u3
.dwGBitMask
= 0x07E0;
84 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
85 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
88 case WINED3DFMT_B5G5R5X1_UNORM
:
89 DDPixelFormat
->dwFlags
= DDPF_RGB
;
90 DDPixelFormat
->dwFourCC
= 0;
91 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
92 DDPixelFormat
->u2
.dwRBitMask
= 0x7C00;
93 DDPixelFormat
->u3
.dwGBitMask
= 0x03E0;
94 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
95 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
98 case WINED3DFMT_B5G5R5A1_UNORM
:
99 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
100 DDPixelFormat
->dwFourCC
= 0;
101 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
102 DDPixelFormat
->u2
.dwRBitMask
= 0x7C00;
103 DDPixelFormat
->u3
.dwGBitMask
= 0x03E0;
104 DDPixelFormat
->u4
.dwBBitMask
= 0x001F;
105 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x8000;
108 case WINED3DFMT_B4G4R4A4_UNORM
:
109 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
110 DDPixelFormat
->dwFourCC
= 0;
111 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
112 DDPixelFormat
->u2
.dwRBitMask
= 0x0F00;
113 DDPixelFormat
->u3
.dwGBitMask
= 0x00F0;
114 DDPixelFormat
->u4
.dwBBitMask
= 0x000F;
115 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xF000;
118 case WINED3DFMT_B2G3R3_UNORM
:
119 DDPixelFormat
->dwFlags
= DDPF_RGB
;
120 DDPixelFormat
->dwFourCC
= 0;
121 DDPixelFormat
->u1
.dwRGBBitCount
= 8;
122 DDPixelFormat
->u2
.dwRBitMask
= 0xE0;
123 DDPixelFormat
->u3
.dwGBitMask
= 0x1C;
124 DDPixelFormat
->u4
.dwBBitMask
= 0x03;
125 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
128 case WINED3DFMT_P8_UINT
:
129 DDPixelFormat
->dwFlags
= DDPF_PALETTEINDEXED8
| DDPF_RGB
;
130 DDPixelFormat
->dwFourCC
= 0;
131 DDPixelFormat
->u1
.dwRGBBitCount
= 8;
132 DDPixelFormat
->u2
.dwRBitMask
= 0x00;
133 DDPixelFormat
->u3
.dwGBitMask
= 0x00;
134 DDPixelFormat
->u4
.dwBBitMask
= 0x00;
137 case WINED3DFMT_A8_UNORM
:
138 DDPixelFormat
->dwFlags
= DDPF_ALPHA
;
139 DDPixelFormat
->dwFourCC
= 0;
140 DDPixelFormat
->u1
.dwAlphaBitDepth
= 8;
141 DDPixelFormat
->u2
.dwRBitMask
= 0x0;
142 DDPixelFormat
->u3
.dwZBitMask
= 0x0;
143 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
144 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
147 case WINED3DFMT_B2G3R3A8_UNORM
:
148 DDPixelFormat
->dwFlags
= DDPF_RGB
| DDPF_ALPHAPIXELS
;
149 DDPixelFormat
->dwFourCC
= 0;
150 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
151 DDPixelFormat
->u2
.dwRBitMask
= 0x00E0;
152 DDPixelFormat
->u3
.dwGBitMask
= 0x001C;
153 DDPixelFormat
->u4
.dwBBitMask
= 0x0003;
154 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0xFF00;
157 case WINED3DFMT_B4G4R4X4_UNORM
:
158 DDPixelFormat
->dwFlags
= DDPF_RGB
;
159 DDPixelFormat
->dwFourCC
= 0;
160 DDPixelFormat
->u1
.dwRGBBitCount
= 16;
161 DDPixelFormat
->u2
.dwRBitMask
= 0x0F00;
162 DDPixelFormat
->u3
.dwGBitMask
= 0x00F0;
163 DDPixelFormat
->u4
.dwBBitMask
= 0x000F;
164 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
167 /* How are Z buffer bit depth and Stencil buffer bit depth related?
169 case WINED3DFMT_D16_UNORM
:
170 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
171 DDPixelFormat
->dwFourCC
= 0;
172 DDPixelFormat
->u1
.dwZBufferBitDepth
= 16;
173 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
174 DDPixelFormat
->u3
.dwZBitMask
= 0x0000FFFF;
175 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
176 DDPixelFormat
->u5
.dwRGBZBitMask
= 0x00000000;
179 case WINED3DFMT_D32_UNORM
:
180 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
181 DDPixelFormat
->dwFourCC
= 0;
182 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
183 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
184 DDPixelFormat
->u3
.dwZBitMask
= 0xFFFFFFFF;
185 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0;
186 DDPixelFormat
->u5
.dwRGBZBitMask
= 0x00000000;
189 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
190 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
191 DDPixelFormat
->dwFourCC
= 0;
192 /* Should I set dwZBufferBitDepth to 32 here? */
193 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
194 DDPixelFormat
->u2
.dwStencilBitDepth
= 4;
195 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
196 DDPixelFormat
->u4
.dwStencilBitMask
= 0x0F000000;
197 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
200 case WINED3DFMT_D24_UNORM_S8_UINT
:
201 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
202 DDPixelFormat
->dwFourCC
= 0;
203 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
204 DDPixelFormat
->u2
.dwStencilBitDepth
= 8;
205 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
206 DDPixelFormat
->u4
.dwStencilBitMask
= 0xFF000000;
207 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
210 case WINED3DFMT_X8D24_UNORM
:
211 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
;
212 DDPixelFormat
->dwFourCC
= 0;
213 DDPixelFormat
->u1
.dwZBufferBitDepth
= 32;
214 DDPixelFormat
->u2
.dwStencilBitDepth
= 0;
215 DDPixelFormat
->u3
.dwZBitMask
= 0x00FFFFFF;
216 DDPixelFormat
->u4
.dwStencilBitMask
= 0x00000000;
217 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
220 case WINED3DFMT_S1_UINT_D15_UNORM
:
221 DDPixelFormat
->dwFlags
= DDPF_ZBUFFER
| DDPF_STENCILBUFFER
;
222 DDPixelFormat
->dwFourCC
= 0;
223 DDPixelFormat
->u1
.dwZBufferBitDepth
= 16;
224 DDPixelFormat
->u2
.dwStencilBitDepth
= 1;
225 DDPixelFormat
->u3
.dwZBitMask
= 0x7fff;
226 DDPixelFormat
->u4
.dwStencilBitMask
= 0x8000;
227 DDPixelFormat
->u5
.dwRGBAlphaBitMask
= 0x0;
230 case WINED3DFMT_UYVY
:
231 case WINED3DFMT_YUY2
:
232 DDPixelFormat
->u1
.dwYUVBitCount
= 16;
233 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
234 DDPixelFormat
->dwFourCC
= wined3d_format
;
237 case WINED3DFMT_YV12
:
238 DDPixelFormat
->u1
.dwYUVBitCount
= 12;
239 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
240 DDPixelFormat
->dwFourCC
= wined3d_format
;
243 case WINED3DFMT_DXT1
:
244 case WINED3DFMT_DXT2
:
245 case WINED3DFMT_DXT3
:
246 case WINED3DFMT_DXT4
:
247 case WINED3DFMT_DXT5
:
248 case WINED3DFMT_MULTI2_ARGB8
:
249 case WINED3DFMT_G8R8_G8B8
:
250 case WINED3DFMT_R8G8_B8G8
:
251 DDPixelFormat
->dwFlags
= DDPF_FOURCC
;
252 DDPixelFormat
->dwFourCC
= wined3d_format
;
256 case WINED3DFMT_L8_UNORM
:
257 DDPixelFormat
->dwFlags
= DDPF_LUMINANCE
;
258 DDPixelFormat
->dwFourCC
= 0;
259 DDPixelFormat
->u1
.dwLuminanceBitCount
= 8;
260 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0xff;
261 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
262 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
263 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x0;
266 case WINED3DFMT_L4A4_UNORM
:
267 DDPixelFormat
->dwFlags
= DDPF_ALPHAPIXELS
| DDPF_LUMINANCE
;
268 DDPixelFormat
->dwFourCC
= 0;
269 DDPixelFormat
->u1
.dwLuminanceBitCount
= 4;
270 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0x0f;
271 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
272 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
273 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0xf0;
276 case WINED3DFMT_L8A8_UNORM
:
277 DDPixelFormat
->dwFlags
= DDPF_ALPHAPIXELS
| DDPF_LUMINANCE
;
278 DDPixelFormat
->dwFourCC
= 0;
279 DDPixelFormat
->u1
.dwLuminanceBitCount
= 16;
280 DDPixelFormat
->u2
.dwLuminanceBitMask
= 0x00ff;
281 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0;
282 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0;
283 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0xff00;
287 case WINED3DFMT_R8G8_SNORM
:
288 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
;
289 DDPixelFormat
->dwFourCC
= 0;
290 DDPixelFormat
->u1
.dwBumpBitCount
= 16;
291 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x000000ff;
292 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0000ff00;
293 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x00000000;
294 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
297 case WINED3DFMT_R16G16_SNORM
:
298 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
;
299 DDPixelFormat
->dwFourCC
= 0;
300 DDPixelFormat
->u1
.dwBumpBitCount
= 32;
301 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x0000ffff;
302 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0xffff0000;
303 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x00000000;
304 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
307 case WINED3DFMT_R5G5_SNORM_L6_UNORM
:
308 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
;
309 DDPixelFormat
->dwFourCC
= 0;
310 DDPixelFormat
->u1
.dwBumpBitCount
= 16;
311 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x0000001f;
312 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x000003e0;
313 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x0000fc00;
314 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
317 case WINED3DFMT_R8G8_SNORM_L8X8_UNORM
:
318 DDPixelFormat
->dwFlags
= DDPF_BUMPDUDV
;
319 DDPixelFormat
->dwFourCC
= 0;
320 DDPixelFormat
->u1
.dwBumpBitCount
= 32;
321 DDPixelFormat
->u2
.dwBumpDuBitMask
= 0x000000ff;
322 DDPixelFormat
->u3
.dwBumpDvBitMask
= 0x0000ff00;
323 DDPixelFormat
->u4
.dwBumpLuminanceBitMask
= 0x00ff0000;
324 DDPixelFormat
->u5
.dwLuminanceAlphaBitMask
= 0x00000000;
328 FIXME("Unhandled wined3d format %#x.\n", wined3d_format
);
332 if(TRACE_ON(ddraw
)) {
333 TRACE("Returning: ");
334 DDRAW_dump_pixelformat(DDPixelFormat
);
338 enum wined3d_format_id
wined3dformat_from_ddrawformat(const DDPIXELFORMAT
*DDPixelFormat
)
340 TRACE("Convert a DirectDraw Pixelformat to a WineD3D Pixelformat\n");
343 DDRAW_dump_pixelformat(DDPixelFormat
);
346 if(DDPixelFormat
->dwFlags
& DDPF_PALETTEINDEXED8
)
348 return WINED3DFMT_P8_UINT
;
350 else if(DDPixelFormat
->dwFlags
& (DDPF_PALETTEINDEXED1
| DDPF_PALETTEINDEXED2
| DDPF_PALETTEINDEXED4
) )
352 FIXME("DDPF_PALETTEINDEXED1 to DDPF_PALETTEINDEXED4 are not supported by WineD3D (yet). Returning WINED3DFMT_P8\n");
353 return WINED3DFMT_P8_UINT
;
355 else if(DDPixelFormat
->dwFlags
& DDPF_RGB
)
357 switch(DDPixelFormat
->u1
.dwRGBBitCount
)
360 /* This is the only format that can match here */
361 return WINED3DFMT_B2G3R3_UNORM
;
364 /* Read the Color masks */
365 if( (DDPixelFormat
->u2
.dwRBitMask
== 0xF800) &&
366 (DDPixelFormat
->u3
.dwGBitMask
== 0x07E0) &&
367 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
369 return WINED3DFMT_B5G6R5_UNORM
;
372 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x7C00) &&
373 (DDPixelFormat
->u3
.dwGBitMask
== 0x03E0) &&
374 (DDPixelFormat
->u4
.dwBBitMask
== 0x001F) )
376 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
377 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0x8000))
378 return WINED3DFMT_B5G5R5A1_UNORM
;
380 return WINED3DFMT_B5G5R5X1_UNORM
;
383 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x0F00) &&
384 (DDPixelFormat
->u3
.dwGBitMask
== 0x00F0) &&
385 (DDPixelFormat
->u4
.dwBBitMask
== 0x000F) )
387 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
388 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xF000))
389 return WINED3DFMT_B4G4R4A4_UNORM
;
391 return WINED3DFMT_B4G4R4X4_UNORM
;
394 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
395 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF00) &&
396 (DDPixelFormat
->u2
.dwRBitMask
== 0x00E0) &&
397 (DDPixelFormat
->u3
.dwGBitMask
== 0x001C) &&
398 (DDPixelFormat
->u4
.dwBBitMask
== 0x0003) )
400 return WINED3DFMT_B2G3R3A8_UNORM
;
402 WARN("16 bit RGB Pixel format does not match.\n");
403 return WINED3DFMT_UNKNOWN
;
406 return WINED3DFMT_B8G8R8_UNORM
;
409 /* Read the Color masks */
410 if( (DDPixelFormat
->u2
.dwRBitMask
== 0x00FF0000) &&
411 (DDPixelFormat
->u3
.dwGBitMask
== 0x0000FF00) &&
412 (DDPixelFormat
->u4
.dwBBitMask
== 0x000000FF) )
414 if( (DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
) &&
415 (DDPixelFormat
->u5
.dwRGBAlphaBitMask
== 0xFF000000))
416 return WINED3DFMT_B8G8R8A8_UNORM
;
418 return WINED3DFMT_B8G8R8X8_UNORM
;
421 WARN("32 bit RGB pixel format does not match.\n");
422 return WINED3DFMT_UNKNOWN
;
425 WARN("Invalid dwRGBBitCount in Pixelformat structure.\n");
426 return WINED3DFMT_UNKNOWN
;
429 else if( (DDPixelFormat
->dwFlags
& DDPF_ALPHA
) )
431 /* Alpha only Pixelformat */
432 switch(DDPixelFormat
->u1
.dwAlphaBitDepth
)
435 return WINED3DFMT_A8_UNORM
;
438 WARN("Invalid AlphaBitDepth in Alpha-Only Pixelformat.\n");
439 return WINED3DFMT_UNKNOWN
;
442 else if(DDPixelFormat
->dwFlags
& DDPF_LUMINANCE
)
444 /* Luminance-only or luminance-alpha */
445 if(DDPixelFormat
->dwFlags
& DDPF_ALPHAPIXELS
)
447 /* Luminance with Alpha */
448 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
451 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 4)
452 return WINED3DFMT_L4A4_UNORM
;
453 WARN("Unknown Alpha / Luminance bit depth combination.\n");
454 return WINED3DFMT_UNKNOWN
;
457 FIXME("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now.\n");
458 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
461 if(DDPixelFormat
->u1
.dwAlphaBitDepth
== 8)
462 return WINED3DFMT_L8A8_UNORM
;
463 WARN("Unknown Alpha / Lumincase bit depth combination.\n");
464 return WINED3DFMT_UNKNOWN
;
470 switch(DDPixelFormat
->u1
.dwLuminanceBitCount
)
473 FIXME("A luminance Pixelformat shouldn't have 6 luminance bits. Returning D3DFMT_L6V5U5 for now.\n");
474 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
477 return WINED3DFMT_L8_UNORM
;
480 WARN("Unknown luminance-only bit depth 0x%x.\n", DDPixelFormat
->u1
.dwLuminanceBitCount
);
481 return WINED3DFMT_UNKNOWN
;
485 else if(DDPixelFormat
->dwFlags
& DDPF_ZBUFFER
)
488 if(DDPixelFormat
->dwFlags
& DDPF_STENCILBUFFER
)
490 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
493 if (DDPixelFormat
->u2
.dwStencilBitDepth
== 1) return WINED3DFMT_S1_UINT_D15_UNORM
;
494 WARN("Unknown depth stenil format: 16 z bits, %u stencil bits\n",
495 DDPixelFormat
->u2
.dwStencilBitDepth
);
496 return WINED3DFMT_UNKNOWN
;
499 if (DDPixelFormat
->u2
.dwStencilBitDepth
== 8) return WINED3DFMT_D24_UNORM_S8_UINT
;
500 else if (DDPixelFormat
->u2
.dwStencilBitDepth
== 4) return WINED3DFMT_S4X4_UINT_D24_UNORM
;
501 WARN("Unknown depth stenil format: 32 z bits, %u stencil bits\n",
502 DDPixelFormat
->u2
.dwStencilBitDepth
);
503 return WINED3DFMT_UNKNOWN
;
506 WARN("Unknown depth stenil format: %u z bits, %u stencil bits\n",
507 DDPixelFormat
->u1
.dwZBufferBitDepth
, DDPixelFormat
->u2
.dwStencilBitDepth
);
508 return WINED3DFMT_UNKNOWN
;
513 switch(DDPixelFormat
->u1
.dwZBufferBitDepth
)
516 return WINED3DFMT_D16_UNORM
;
519 return WINED3DFMT_X8D24_UNORM
;
522 if (DDPixelFormat
->u3
.dwZBitMask
== 0x00FFFFFF) return WINED3DFMT_X8D24_UNORM
;
523 else if (DDPixelFormat
->u3
.dwZBitMask
== 0xFFFFFF00) return WINED3DFMT_X8D24_UNORM
;
524 else if (DDPixelFormat
->u3
.dwZBitMask
== 0xFFFFFFFF) return WINED3DFMT_D32_UNORM
;
525 WARN("Unknown depth-only format: 32 z bits, mask 0x%08x\n",
526 DDPixelFormat
->u3
.dwZBitMask
);
527 return WINED3DFMT_UNKNOWN
;
530 WARN("Unknown depth-only format: %u z bits, mask 0x%08x\n",
531 DDPixelFormat
->u1
.dwZBufferBitDepth
, DDPixelFormat
->u3
.dwZBitMask
);
532 return WINED3DFMT_UNKNOWN
;
536 else if(DDPixelFormat
->dwFlags
& DDPF_FOURCC
)
538 return DDPixelFormat
->dwFourCC
;
540 else if(DDPixelFormat
->dwFlags
& DDPF_BUMPDUDV
)
542 if( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
543 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x000000ff) &&
544 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x0000ff00) &&
545 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00000000) )
547 return WINED3DFMT_R8G8_SNORM
;
549 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 32 ) &&
550 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x0000ffff) &&
551 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0xffff0000) &&
552 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00000000) )
554 return WINED3DFMT_R16G16_SNORM
;
556 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 16 ) &&
557 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x0000001f) &&
558 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x000003e0) &&
559 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x0000fc00) )
561 return WINED3DFMT_R5G5_SNORM_L6_UNORM
;
563 else if ( (DDPixelFormat
->u1
.dwBumpBitCount
== 32 ) &&
564 (DDPixelFormat
->u2
.dwBumpDuBitMask
== 0x000000ff) &&
565 (DDPixelFormat
->u3
.dwBumpDvBitMask
== 0x0000ff00) &&
566 (DDPixelFormat
->u4
.dwBumpLuminanceBitMask
== 0x00ff0000) )
568 return WINED3DFMT_R8G8_SNORM_L8X8_UNORM
;
572 WARN("Unknown Pixelformat.\n");
573 return WINED3DFMT_UNKNOWN
;
576 /*****************************************************************************
577 * Various dumping functions.
579 * They write the contents of a specific function to a TRACE.
581 *****************************************************************************/
583 DDRAW_dump_DWORD(const void *in
)
585 TRACE("%d\n", *((const DWORD
*) in
));
588 DDRAW_dump_PTR(const void *in
)
590 TRACE("%p\n", *((const void * const*) in
));
593 DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*ddck
)
595 TRACE("Low : 0x%08x - High : 0x%08x\n", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
598 static void DDRAW_dump_flags_nolf(DWORD flags
, const struct flag_info
*names
, size_t num_names
)
602 for (i
=0; i
< num_names
; i
++)
603 if ((flags
& names
[i
].val
) || /* standard flag value */
604 ((!flags
) && (!names
[i
].val
))) /* zero value only */
605 TRACE("%s ", names
[i
].name
);
608 static void DDRAW_dump_flags(DWORD flags
, const struct flag_info
*names
, size_t num_names
)
610 DDRAW_dump_flags_nolf(flags
, names
, num_names
);
614 void DDRAW_dump_DDSCAPS2(const DDSCAPS2
*in
)
616 static const struct flag_info flags
[] =
618 FE(DDSCAPS_RESERVED1
),
620 FE(DDSCAPS_BACKBUFFER
),
623 FE(DDSCAPS_FRONTBUFFER
),
624 FE(DDSCAPS_OFFSCREENPLAIN
),
627 FE(DDSCAPS_PRIMARYSURFACE
),
628 FE(DDSCAPS_PRIMARYSURFACELEFT
),
629 FE(DDSCAPS_SYSTEMMEMORY
),
631 FE(DDSCAPS_3DDEVICE
),
632 FE(DDSCAPS_VIDEOMEMORY
),
634 FE(DDSCAPS_WRITEONLY
),
637 FE(DDSCAPS_LIVEVIDEO
),
641 FE(DDSCAPS_RESERVED2
),
642 FE(DDSCAPS_ALLOCONLOAD
),
643 FE(DDSCAPS_VIDEOPORT
),
644 FE(DDSCAPS_LOCALVIDMEM
),
645 FE(DDSCAPS_NONLOCALVIDMEM
),
646 FE(DDSCAPS_STANDARDVGAMODE
),
647 FE(DDSCAPS_OPTIMIZED
)
649 static const struct flag_info flags2
[] =
651 FE(DDSCAPS2_HARDWAREDEINTERLACE
),
652 FE(DDSCAPS2_HINTDYNAMIC
),
653 FE(DDSCAPS2_HINTSTATIC
),
654 FE(DDSCAPS2_TEXTUREMANAGE
),
655 FE(DDSCAPS2_RESERVED1
),
656 FE(DDSCAPS2_RESERVED2
),
658 FE(DDSCAPS2_HINTANTIALIASING
),
659 FE(DDSCAPS2_CUBEMAP
),
660 FE(DDSCAPS2_CUBEMAP_POSITIVEX
),
661 FE(DDSCAPS2_CUBEMAP_NEGATIVEX
),
662 FE(DDSCAPS2_CUBEMAP_POSITIVEY
),
663 FE(DDSCAPS2_CUBEMAP_NEGATIVEY
),
664 FE(DDSCAPS2_CUBEMAP_POSITIVEZ
),
665 FE(DDSCAPS2_CUBEMAP_NEGATIVEZ
),
666 FE(DDSCAPS2_MIPMAPSUBLEVEL
),
667 FE(DDSCAPS2_D3DTEXTUREMANAGE
),
668 FE(DDSCAPS2_DONOTPERSIST
),
669 FE(DDSCAPS2_STEREOSURFACELEFT
)
672 DDRAW_dump_flags_nolf(in
->dwCaps
, flags
, sizeof(flags
)/sizeof(flags
[0]));
673 DDRAW_dump_flags(in
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
677 DDRAW_dump_DDSCAPS(const DDSCAPS
*in
)
681 in_bis
.dwCaps
= in
->dwCaps
;
684 in_bis
.u1
.dwCaps4
= 0;
686 DDRAW_dump_DDSCAPS2(&in_bis
);
690 DDRAW_dump_pixelformat_flag(DWORD flagmask
)
692 static const struct flag_info flags
[] =
694 FE(DDPF_ALPHAPIXELS
),
697 FE(DDPF_PALETTEINDEXED4
),
698 FE(DDPF_PALETTEINDEXEDTO8
),
699 FE(DDPF_PALETTEINDEXED8
),
705 FE(DDPF_PALETTEINDEXED1
),
706 FE(DDPF_PALETTEINDEXED2
),
710 DDRAW_dump_flags_nolf(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
713 static void DDRAW_dump_members(DWORD flags
, const void *data
, const struct member_info
*mems
, size_t num_mems
)
717 for (i
=0; i
< num_mems
; i
++)
719 if (mems
[i
].val
& flags
)
721 TRACE(" - %s : ", mems
[i
].name
);
722 mems
[i
].func((const char *)data
+ mems
[i
].offset
);
728 DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
)
731 DDRAW_dump_pixelformat_flag(pf
->dwFlags
);
732 if (pf
->dwFlags
& DDPF_FOURCC
)
734 TRACE(", dwFourCC code '%c%c%c%c' (0x%08x) - %d bits per pixel",
735 (unsigned char)( pf
->dwFourCC
&0xff),
736 (unsigned char)((pf
->dwFourCC
>> 8)&0xff),
737 (unsigned char)((pf
->dwFourCC
>>16)&0xff),
738 (unsigned char)((pf
->dwFourCC
>>24)&0xff),
743 if (pf
->dwFlags
& DDPF_RGB
)
746 TRACE(", RGB bits: %d, ", pf
->u1
.dwRGBBitCount
);
747 switch (pf
->u1
.dwRGBBitCount
)
749 case 4: cmd
= "%1lx"; break;
750 case 8: cmd
= "%02lx"; break;
751 case 16: cmd
= "%04lx"; break;
752 case 24: cmd
= "%06lx"; break;
753 case 32: cmd
= "%08lx"; break;
754 default: ERR("Unexpected bit depth!\n"); cmd
= "%d"; break;
756 TRACE(" R "); TRACE(cmd
, pf
->u2
.dwRBitMask
);
757 TRACE(" G "); TRACE(cmd
, pf
->u3
.dwGBitMask
);
758 TRACE(" B "); TRACE(cmd
, pf
->u4
.dwBBitMask
);
759 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
)
761 TRACE(" A "); TRACE(cmd
, pf
->u5
.dwRGBAlphaBitMask
);
763 if (pf
->dwFlags
& DDPF_ZPIXELS
)
765 TRACE(" Z "); TRACE(cmd
, pf
->u5
.dwRGBZBitMask
);
768 if (pf
->dwFlags
& DDPF_ZBUFFER
)
770 TRACE(", Z bits : %d", pf
->u1
.dwZBufferBitDepth
);
772 if (pf
->dwFlags
& DDPF_ALPHA
)
774 TRACE(", Alpha bits : %d", pf
->u1
.dwAlphaBitDepth
);
776 if (pf
->dwFlags
& DDPF_BUMPDUDV
)
778 const char *cmd
= "%08lx";
779 TRACE(", Bump bits: %d, ", pf
->u1
.dwBumpBitCount
);
780 TRACE(" U "); TRACE(cmd
, pf
->u2
.dwBumpDuBitMask
);
781 TRACE(" V "); TRACE(cmd
, pf
->u3
.dwBumpDvBitMask
);
782 TRACE(" L "); TRACE(cmd
, pf
->u4
.dwBumpLuminanceBitMask
);
787 void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
)
789 #define STRUCT DDSURFACEDESC2
790 static const struct member_info members
[] =
792 ME(DDSD_HEIGHT
, DDRAW_dump_DWORD
, dwHeight
),
793 ME(DDSD_WIDTH
, DDRAW_dump_DWORD
, dwWidth
),
794 ME(DDSD_PITCH
, DDRAW_dump_DWORD
, u1
/* lPitch */),
795 ME(DDSD_LINEARSIZE
, DDRAW_dump_DWORD
, u1
/* dwLinearSize */),
796 ME(DDSD_BACKBUFFERCOUNT
, DDRAW_dump_DWORD
, u5
.dwBackBufferCount
),
797 ME(DDSD_MIPMAPCOUNT
, DDRAW_dump_DWORD
, u2
/* dwMipMapCount */),
798 ME(DDSD_ZBUFFERBITDEPTH
, DDRAW_dump_DWORD
, u2
/* dwZBufferBitDepth */), /* This is for 'old-style' D3D */
799 ME(DDSD_REFRESHRATE
, DDRAW_dump_DWORD
, u2
/* dwRefreshRate */),
800 ME(DDSD_ALPHABITDEPTH
, DDRAW_dump_DWORD
, dwAlphaBitDepth
),
801 ME(DDSD_LPSURFACE
, DDRAW_dump_PTR
, lpSurface
),
802 ME(DDSD_CKDESTOVERLAY
, DDRAW_dump_DDCOLORKEY
, u3
/* ddckCKDestOverlay */),
803 ME(DDSD_CKDESTBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKDestBlt
),
804 ME(DDSD_CKSRCOVERLAY
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcOverlay
),
805 ME(DDSD_CKSRCBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcBlt
),
806 ME(DDSD_PIXELFORMAT
, DDRAW_dump_pixelformat
, u4
/* ddpfPixelFormat */)
808 static const struct member_info members_caps
[] =
810 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS
, ddsCaps
)
812 static const struct member_info members_caps2
[] =
814 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS2
, ddsCaps
)
824 if (lpddsd
->dwSize
>= sizeof(DDSURFACEDESC2
))
826 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps2
, 1);
830 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members_caps
, 1);
832 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members
,
833 sizeof(members
)/sizeof(members
[0]));
838 dump_D3DMATRIX(const D3DMATRIX
*mat
)
840 TRACE(" %f %f %f %f\n", mat
->_11
, mat
->_12
, mat
->_13
, mat
->_14
);
841 TRACE(" %f %f %f %f\n", mat
->_21
, mat
->_22
, mat
->_23
, mat
->_24
);
842 TRACE(" %f %f %f %f\n", mat
->_31
, mat
->_32
, mat
->_33
, mat
->_34
);
843 TRACE(" %f %f %f %f\n", mat
->_41
, mat
->_42
, mat
->_43
, mat
->_44
);
847 get_flexible_vertex_size(DWORD d3dvtVertexType
)
852 if (d3dvtVertexType
& D3DFVF_NORMAL
) size
+= 3 * sizeof(D3DVALUE
);
853 if (d3dvtVertexType
& D3DFVF_DIFFUSE
) size
+= sizeof(DWORD
);
854 if (d3dvtVertexType
& D3DFVF_SPECULAR
) size
+= sizeof(DWORD
);
855 if (d3dvtVertexType
& D3DFVF_RESERVED1
) size
+= sizeof(DWORD
);
856 switch (d3dvtVertexType
& D3DFVF_POSITION_MASK
)
858 case D3DFVF_XYZ
: size
+= 3 * sizeof(D3DVALUE
); break;
859 case D3DFVF_XYZRHW
: size
+= 4 * sizeof(D3DVALUE
); break;
860 case D3DFVF_XYZB1
: size
+= 4 * sizeof(D3DVALUE
); break;
861 case D3DFVF_XYZB2
: size
+= 5 * sizeof(D3DVALUE
); break;
862 case D3DFVF_XYZB3
: size
+= 6 * sizeof(D3DVALUE
); break;
863 case D3DFVF_XYZB4
: size
+= 7 * sizeof(D3DVALUE
); break;
864 case D3DFVF_XYZB5
: size
+= 8 * sizeof(D3DVALUE
); break;
865 default: ERR("Unexpected position mask\n");
867 for (i
= 0; i
< GET_TEXCOUNT_FROM_FVF(d3dvtVertexType
); i
++)
869 size
+= GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType
, i
) * sizeof(D3DVALUE
);
875 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS
* pIn
, DDSCAPS2
* pOut
)
877 /* 2 adds three additional caps fields to the end. Both versions
878 * are unversioned. */
879 pOut
->dwCaps
= pIn
->dwCaps
;
882 pOut
->u1
.dwCaps4
= 0;
885 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2
* pIn
, DDDEVICEIDENTIFIER
* pOut
)
887 /* 2 adds a dwWHQLLevel field to the end. Both structures are
889 memcpy(pOut
, pIn
, sizeof(*pOut
));
892 void DDRAW_dump_cooperativelevel(DWORD cooplevel
)
894 static const struct flag_info flags
[] =
896 FE(DDSCL_FULLSCREEN
),
897 FE(DDSCL_ALLOWREBOOT
),
898 FE(DDSCL_NOWINDOWCHANGES
),
900 FE(DDSCL_ALLOWMODEX
),
902 FE(DDSCL_SETFOCUSWINDOW
),
903 FE(DDSCL_SETDEVICEWINDOW
),
904 FE(DDSCL_CREATEDEVICEWINDOW
)
910 DDRAW_dump_flags(cooplevel
, flags
, sizeof(flags
)/sizeof(flags
[0]));
914 void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
)
916 static const struct flag_info flags1
[] =
919 FE(DDCAPS_ALIGNBOUNDARYDEST
),
920 FE(DDCAPS_ALIGNSIZEDEST
),
921 FE(DDCAPS_ALIGNBOUNDARYSRC
),
922 FE(DDCAPS_ALIGNSIZESRC
),
923 FE(DDCAPS_ALIGNSTRIDE
),
926 FE(DDCAPS_BLTFOURCC
),
927 FE(DDCAPS_BLTSTRETCH
),
930 FE(DDCAPS_OVERLAYCANTCLIP
),
931 FE(DDCAPS_OVERLAYFOURCC
),
932 FE(DDCAPS_OVERLAYSTRETCH
),
934 FE(DDCAPS_PALETTEVSYNC
),
935 FE(DDCAPS_READSCANLINE
),
936 FE(DDCAPS_STEREOVIEW
),
939 FE(DDCAPS_ZOVERLAYS
),
942 FE(DDCAPS_COLORKEYHWASSIST
),
943 FE(DDCAPS_NOHARDWARE
),
944 FE(DDCAPS_BLTCOLORFILL
),
945 FE(DDCAPS_BANKSWITCHED
),
946 FE(DDCAPS_BLTDEPTHFILL
),
948 FE(DDCAPS_CANCLIPSTRETCHED
),
949 FE(DDCAPS_CANBLTSYSMEM
)
951 static const struct flag_info flags2
[] =
953 FE(DDCAPS2_CERTIFIED
),
954 FE(DDCAPS2_NO2DDURING3DSCENE
),
955 FE(DDCAPS2_VIDEOPORT
),
956 FE(DDCAPS2_AUTOFLIPOVERLAY
),
957 FE(DDCAPS2_CANBOBINTERLEAVED
),
958 FE(DDCAPS2_CANBOBNONINTERLEAVED
),
959 FE(DDCAPS2_COLORCONTROLOVERLAY
),
960 FE(DDCAPS2_COLORCONTROLPRIMARY
),
961 FE(DDCAPS2_CANDROPZ16BIT
),
962 FE(DDCAPS2_NONLOCALVIDMEM
),
963 FE(DDCAPS2_NONLOCALVIDMEMCAPS
),
964 FE(DDCAPS2_NOPAGELOCKREQUIRED
),
965 FE(DDCAPS2_WIDESURFACES
),
966 FE(DDCAPS2_CANFLIPODDEVEN
),
967 FE(DDCAPS2_CANBOBHARDWARE
),
968 FE(DDCAPS2_COPYFOURCC
),
969 FE(DDCAPS2_PRIMARYGAMMA
),
970 FE(DDCAPS2_CANRENDERWINDOWED
),
971 FE(DDCAPS2_CANCALIBRATEGAMMA
),
972 FE(DDCAPS2_FLIPINTERVAL
),
973 FE(DDCAPS2_FLIPNOVSYNC
),
974 FE(DDCAPS2_CANMANAGETEXTURE
),
975 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM
),
977 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL
)
979 static const struct flag_info flags3
[] =
981 FE(DDCKEYCAPS_DESTBLT
),
982 FE(DDCKEYCAPS_DESTBLTCLRSPACE
),
983 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV
),
984 FE(DDCKEYCAPS_DESTBLTYUV
),
985 FE(DDCKEYCAPS_DESTOVERLAY
),
986 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE
),
987 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV
),
988 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE
),
989 FE(DDCKEYCAPS_DESTOVERLAYYUV
),
990 FE(DDCKEYCAPS_SRCBLT
),
991 FE(DDCKEYCAPS_SRCBLTCLRSPACE
),
992 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV
),
993 FE(DDCKEYCAPS_SRCBLTYUV
),
994 FE(DDCKEYCAPS_SRCOVERLAY
),
995 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE
),
996 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV
),
997 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE
),
998 FE(DDCKEYCAPS_SRCOVERLAYYUV
),
999 FE(DDCKEYCAPS_NOCOSTOVERLAY
)
1001 static const struct flag_info flags4
[] =
1003 FE(DDFXCAPS_BLTALPHA
),
1004 FE(DDFXCAPS_OVERLAYALPHA
),
1005 FE(DDFXCAPS_BLTARITHSTRETCHYN
),
1006 FE(DDFXCAPS_BLTARITHSTRETCHY
),
1007 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT
),
1008 FE(DDFXCAPS_BLTMIRRORUPDOWN
),
1009 FE(DDFXCAPS_BLTROTATION
),
1010 FE(DDFXCAPS_BLTROTATION90
),
1011 FE(DDFXCAPS_BLTSHRINKX
),
1012 FE(DDFXCAPS_BLTSHRINKXN
),
1013 FE(DDFXCAPS_BLTSHRINKY
),
1014 FE(DDFXCAPS_BLTSHRINKYN
),
1015 FE(DDFXCAPS_BLTSTRETCHX
),
1016 FE(DDFXCAPS_BLTSTRETCHXN
),
1017 FE(DDFXCAPS_BLTSTRETCHY
),
1018 FE(DDFXCAPS_BLTSTRETCHYN
),
1019 FE(DDFXCAPS_OVERLAYARITHSTRETCHY
),
1020 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN
),
1021 FE(DDFXCAPS_OVERLAYSHRINKX
),
1022 FE(DDFXCAPS_OVERLAYSHRINKXN
),
1023 FE(DDFXCAPS_OVERLAYSHRINKY
),
1024 FE(DDFXCAPS_OVERLAYSHRINKYN
),
1025 FE(DDFXCAPS_OVERLAYSTRETCHX
),
1026 FE(DDFXCAPS_OVERLAYSTRETCHXN
),
1027 FE(DDFXCAPS_OVERLAYSTRETCHY
),
1028 FE(DDFXCAPS_OVERLAYSTRETCHYN
),
1029 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT
),
1030 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN
)
1032 static const struct flag_info flags5
[] =
1034 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND
),
1035 FE(DDFXALPHACAPS_BLTALPHAPIXELS
),
1036 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG
),
1037 FE(DDFXALPHACAPS_BLTALPHASURFACES
),
1038 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG
),
1039 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND
),
1040 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS
),
1041 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG
),
1042 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES
),
1043 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG
)
1045 static const struct flag_info flags6
[] =
1048 FE(DDPCAPS_8BITENTRIES
),
1050 FE(DDPCAPS_INITIALIZE
),
1051 FE(DDPCAPS_PRIMARYSURFACE
),
1052 FE(DDPCAPS_PRIMARYSURFACELEFT
),
1053 FE(DDPCAPS_ALLOW256
),
1059 static const struct flag_info flags7
[] =
1061 FE(DDSVCAPS_RESERVED1
),
1062 FE(DDSVCAPS_RESERVED2
),
1063 FE(DDSVCAPS_RESERVED3
),
1064 FE(DDSVCAPS_RESERVED4
),
1065 FE(DDSVCAPS_STEREOSEQUENTIAL
),
1068 TRACE(" - dwSize : %d\n", lpcaps
->dwSize
);
1069 TRACE(" - dwCaps : "); DDRAW_dump_flags(lpcaps
->dwCaps
, flags1
, sizeof(flags1
)/sizeof(flags1
[0]));
1070 TRACE(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
1071 TRACE(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps
->dwCKeyCaps
, flags3
, sizeof(flags3
)/sizeof(flags3
[0]));
1072 TRACE(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps
->dwFXCaps
, flags4
, sizeof(flags4
)/sizeof(flags4
[0]));
1073 TRACE(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps
->dwFXAlphaCaps
, flags5
, sizeof(flags5
)/sizeof(flags5
[0]));
1074 TRACE(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps
->dwPalCaps
, flags6
, sizeof(flags6
)/sizeof(flags6
[0]));
1075 TRACE(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps
->dwSVCaps
, flags7
, sizeof(flags7
)/sizeof(flags7
[0]));
1077 TRACE(" - dwNumFourCCCodes : %d\n", lpcaps
->dwNumFourCCCodes
);
1078 TRACE(" - dwCurrVisibleOverlays : %d\n", lpcaps
->dwCurrVisibleOverlays
);
1079 TRACE(" - dwMinOverlayStretch : %d\n", lpcaps
->dwMinOverlayStretch
);
1080 TRACE(" - dwMaxOverlayStretch : %d\n", lpcaps
->dwMaxOverlayStretch
);
1082 TRACE(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps
->ddsCaps
);
1085 /*****************************************************************************
1088 * Multiplies 2 4x4 matrices src1 and src2, and stores the result in dest.
1091 * dest: Pointer to the destination matrix
1092 * src1: Pointer to the first source matrix
1093 * src2: Pointer to the second source matrix
1095 *****************************************************************************/
1097 multiply_matrix(D3DMATRIX
*dest
,
1098 const D3DMATRIX
*src1
,
1099 const D3DMATRIX
*src2
)
1103 /* Now do the multiplication 'by hand'.
1104 I know that all this could be optimised, but this will be done later :-) */
1105 temp
._11
= (src1
->_11
* src2
->_11
) + (src1
->_21
* src2
->_12
) + (src1
->_31
* src2
->_13
) + (src1
->_41
* src2
->_14
);
1106 temp
._21
= (src1
->_11
* src2
->_21
) + (src1
->_21
* src2
->_22
) + (src1
->_31
* src2
->_23
) + (src1
->_41
* src2
->_24
);
1107 temp
._31
= (src1
->_11
* src2
->_31
) + (src1
->_21
* src2
->_32
) + (src1
->_31
* src2
->_33
) + (src1
->_41
* src2
->_34
);
1108 temp
._41
= (src1
->_11
* src2
->_41
) + (src1
->_21
* src2
->_42
) + (src1
->_31
* src2
->_43
) + (src1
->_41
* src2
->_44
);
1110 temp
._12
= (src1
->_12
* src2
->_11
) + (src1
->_22
* src2
->_12
) + (src1
->_32
* src2
->_13
) + (src1
->_42
* src2
->_14
);
1111 temp
._22
= (src1
->_12
* src2
->_21
) + (src1
->_22
* src2
->_22
) + (src1
->_32
* src2
->_23
) + (src1
->_42
* src2
->_24
);
1112 temp
._32
= (src1
->_12
* src2
->_31
) + (src1
->_22
* src2
->_32
) + (src1
->_32
* src2
->_33
) + (src1
->_42
* src2
->_34
);
1113 temp
._42
= (src1
->_12
* src2
->_41
) + (src1
->_22
* src2
->_42
) + (src1
->_32
* src2
->_43
) + (src1
->_42
* src2
->_44
);
1115 temp
._13
= (src1
->_13
* src2
->_11
) + (src1
->_23
* src2
->_12
) + (src1
->_33
* src2
->_13
) + (src1
->_43
* src2
->_14
);
1116 temp
._23
= (src1
->_13
* src2
->_21
) + (src1
->_23
* src2
->_22
) + (src1
->_33
* src2
->_23
) + (src1
->_43
* src2
->_24
);
1117 temp
._33
= (src1
->_13
* src2
->_31
) + (src1
->_23
* src2
->_32
) + (src1
->_33
* src2
->_33
) + (src1
->_43
* src2
->_34
);
1118 temp
._43
= (src1
->_13
* src2
->_41
) + (src1
->_23
* src2
->_42
) + (src1
->_33
* src2
->_43
) + (src1
->_43
* src2
->_44
);
1120 temp
._14
= (src1
->_14
* src2
->_11
) + (src1
->_24
* src2
->_12
) + (src1
->_34
* src2
->_13
) + (src1
->_44
* src2
->_14
);
1121 temp
._24
= (src1
->_14
* src2
->_21
) + (src1
->_24
* src2
->_22
) + (src1
->_34
* src2
->_23
) + (src1
->_44
* src2
->_24
);
1122 temp
._34
= (src1
->_14
* src2
->_31
) + (src1
->_24
* src2
->_32
) + (src1
->_34
* src2
->_33
) + (src1
->_44
* src2
->_34
);
1123 temp
._44
= (src1
->_14
* src2
->_41
) + (src1
->_24
* src2
->_42
) + (src1
->_34
* src2
->_43
) + (src1
->_44
* src2
->_44
);
1125 /* And copy the new matrix in the good storage.. */
1126 memcpy(dest
, &temp
, 16 * sizeof(D3DVALUE
));
1130 hr_ddraw_from_wined3d(HRESULT hr
)
1134 case WINED3DERR_INVALIDCALL
: return DDERR_INVALIDPARAMS
;
1139 /* Note that this function writes the full sizeof(DDSURFACEDESC2) size, don't use it
1140 * for writing into application-provided DDSURFACEDESC2 structures if the size may
1142 void DDSD_to_DDSD2(const DDSURFACEDESC
*in
, DDSURFACEDESC2
*out
)
1144 /* The output of this function is never passed to the application directly, so
1145 * the memset is not strictly needed. CreateSurface still has problems with this
1146 * though. Don't forget to set ddsCaps.dwCaps2/3/4 to 0 when removing this */
1147 memset(out
, 0x00, sizeof(*out
));
1148 out
->dwSize
= sizeof(*out
);
1149 out
->dwFlags
= in
->dwFlags
& ~DDSD_ZBUFFERBITDEPTH
;
1150 if (in
->dwFlags
& DDSD_WIDTH
) out
->dwWidth
= in
->dwWidth
;
1151 if (in
->dwFlags
& DDSD_HEIGHT
) out
->dwHeight
= in
->dwHeight
;
1152 if (in
->dwFlags
& DDSD_PIXELFORMAT
) out
->u4
.ddpfPixelFormat
= in
->ddpfPixelFormat
;
1153 else if(in
->dwFlags
& DDSD_ZBUFFERBITDEPTH
)
1155 out
->dwFlags
|= DDSD_PIXELFORMAT
;
1156 memset(&out
->u4
.ddpfPixelFormat
, 0, sizeof(out
->u4
.ddpfPixelFormat
));
1157 out
->u4
.ddpfPixelFormat
.dwSize
= sizeof(out
->u4
.ddpfPixelFormat
);
1158 out
->u4
.ddpfPixelFormat
.dwFlags
= DDPF_ZBUFFER
;
1159 out
->u4
.ddpfPixelFormat
.u1
.dwZBufferBitDepth
= in
->u2
.dwZBufferBitDepth
;
1160 /* 0 is not a valid DDSURFACEDESC / DDPIXELFORMAT on either side of the
1162 out
->u4
.ddpfPixelFormat
.u3
.dwZBitMask
= ~0U >> (32 - in
->u2
.dwZBufferBitDepth
);
1164 /* ddsCaps is read even without DDSD_CAPS set. See dsurface:no_ddsd_caps_test */
1165 out
->ddsCaps
.dwCaps
= in
->ddsCaps
.dwCaps
;
1166 if (in
->dwFlags
& DDSD_PITCH
) out
->u1
.lPitch
= in
->u1
.lPitch
;
1167 if (in
->dwFlags
& DDSD_BACKBUFFERCOUNT
) out
->u5
.dwBackBufferCount
= in
->dwBackBufferCount
;
1168 if (in
->dwFlags
& DDSD_ALPHABITDEPTH
) out
->dwAlphaBitDepth
= in
->dwAlphaBitDepth
;
1169 /* DDraw(native, and wine) does not set the DDSD_LPSURFACE, so always copy */
1170 out
->lpSurface
= in
->lpSurface
;
1171 if (in
->dwFlags
& DDSD_CKDESTOVERLAY
) out
->u3
.ddckCKDestOverlay
= in
->ddckCKDestOverlay
;
1172 if (in
->dwFlags
& DDSD_CKDESTBLT
) out
->ddckCKDestBlt
= in
->ddckCKDestBlt
;
1173 if (in
->dwFlags
& DDSD_CKSRCOVERLAY
) out
->ddckCKSrcOverlay
= in
->ddckCKSrcOverlay
;
1174 if (in
->dwFlags
& DDSD_CKSRCBLT
) out
->ddckCKSrcBlt
= in
->ddckCKSrcBlt
;
1175 if (in
->dwFlags
& DDSD_MIPMAPCOUNT
) out
->u2
.dwMipMapCount
= in
->u2
.dwMipMapCount
;
1176 if (in
->dwFlags
& DDSD_REFRESHRATE
) out
->u2
.dwRefreshRate
= in
->u2
.dwRefreshRate
;
1177 if (in
->dwFlags
& DDSD_LINEARSIZE
) out
->u1
.dwLinearSize
= in
->u1
.dwLinearSize
;
1178 /* Does not exist in DDSURFACEDESC:
1179 * DDSD_TEXTURESTAGE, DDSD_FVF, DDSD_SRCVBHANDLE,
1183 /* Note that this function writes the full sizeof(DDSURFACEDESC) size, don't use it
1184 * for writing into application-provided DDSURFACEDESC structures if the size may
1186 void DDSD2_to_DDSD(const DDSURFACEDESC2
*in
, DDSURFACEDESC
*out
)
1188 memset(out
, 0, sizeof(*out
));
1189 out
->dwSize
= sizeof(*out
);
1190 out
->dwFlags
= in
->dwFlags
;
1191 if (in
->dwFlags
& DDSD_WIDTH
) out
->dwWidth
= in
->dwWidth
;
1192 if (in
->dwFlags
& DDSD_HEIGHT
) out
->dwHeight
= in
->dwHeight
;
1193 if (in
->dwFlags
& DDSD_PIXELFORMAT
)
1195 out
->ddpfPixelFormat
= in
->u4
.ddpfPixelFormat
;
1196 if ((in
->dwFlags
& DDSD_CAPS
) && (in
->ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
))
1198 /* Z buffers have DDSD_ZBUFFERBITDEPTH set, but not DDSD_PIXELFORMAT. They do
1199 * have valid data in ddpfPixelFormat though */
1200 out
->dwFlags
&= ~DDSD_PIXELFORMAT
;
1201 out
->dwFlags
|= DDSD_ZBUFFERBITDEPTH
;
1202 out
->u2
.dwZBufferBitDepth
= in
->u4
.ddpfPixelFormat
.u1
.dwZBufferBitDepth
;
1205 /* ddsCaps is read even without DDSD_CAPS set. See dsurface:no_ddsd_caps_test */
1206 out
->ddsCaps
.dwCaps
= in
->ddsCaps
.dwCaps
;
1207 if (in
->dwFlags
& DDSD_PITCH
) out
->u1
.lPitch
= in
->u1
.lPitch
;
1208 if (in
->dwFlags
& DDSD_BACKBUFFERCOUNT
) out
->dwBackBufferCount
= in
->u5
.dwBackBufferCount
;
1209 if (in
->dwFlags
& DDSD_ZBUFFERBITDEPTH
) out
->u2
.dwZBufferBitDepth
= in
->u2
.dwMipMapCount
; /* same union */
1210 if (in
->dwFlags
& DDSD_ALPHABITDEPTH
) out
->dwAlphaBitDepth
= in
->dwAlphaBitDepth
;
1211 /* DDraw(native, and wine) does not set the DDSD_LPSURFACE, so always copy */
1212 out
->lpSurface
= in
->lpSurface
;
1213 if (in
->dwFlags
& DDSD_CKDESTOVERLAY
) out
->ddckCKDestOverlay
= in
->u3
.ddckCKDestOverlay
;
1214 if (in
->dwFlags
& DDSD_CKDESTBLT
) out
->ddckCKDestBlt
= in
->ddckCKDestBlt
;
1215 if (in
->dwFlags
& DDSD_CKSRCOVERLAY
) out
->ddckCKSrcOverlay
= in
->ddckCKSrcOverlay
;
1216 if (in
->dwFlags
& DDSD_CKSRCBLT
) out
->ddckCKSrcBlt
= in
->ddckCKSrcBlt
;
1217 if (in
->dwFlags
& DDSD_MIPMAPCOUNT
) out
->u2
.dwMipMapCount
= in
->u2
.dwMipMapCount
;
1218 if (in
->dwFlags
& DDSD_REFRESHRATE
) out
->u2
.dwRefreshRate
= in
->u2
.dwRefreshRate
;
1219 if (in
->dwFlags
& DDSD_LINEARSIZE
) out
->u1
.dwLinearSize
= in
->u1
.dwLinearSize
;
1220 /* Does not exist in DDSURFACEDESC:
1221 * DDSD_TEXTURESTAGE, DDSD_FVF, DDSD_SRCVBHANDLE,
1223 if (in
->dwFlags
& DDSD_TEXTURESTAGE
) WARN("Does not exist in DDSURFACEDESC: DDSD_TEXTURESTAGE\n");
1224 if (in
->dwFlags
& DDSD_FVF
) WARN("Does not exist in DDSURFACEDESC: DDSD_FVF\n");
1225 if (in
->dwFlags
& DDSD_SRCVBHANDLE
) WARN("Does not exist in DDSURFACEDESC: DDSD_SRCVBHANDLE\n");
1226 out
->dwFlags
&= ~(DDSD_TEXTURESTAGE
| DDSD_FVF
| DDSD_SRCVBHANDLE
);