2 /* DirectDraw Base Functions
4 * Copyright 1997-1999 Marcus Meissner
5 * Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
6 * Copyright 2000 TransGaming Technologies Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/port.h"
32 #include "wine/exception.h"
33 #include "ddraw_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(ddraw
);
39 /******************************************************************************
40 * debug output functions
48 #define FE(x) { x, #x }
54 void (*func
)(const void *);
58 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
60 #define DDRAW_dump_flags(flags,names,num_names) \
61 DDRAW_dump_flags_(flags, names, num_names, 1)
63 static void DDRAW_dump_flags_(DWORD flags
, const flag_info
* names
,
64 size_t num_names
, int newline
)
68 for (i
=0; i
< num_names
; i
++)
69 if (names
[i
].val
& flags
)
70 DPRINTF("%s ", names
[i
].name
);
76 static void DDRAW_dump_members(DWORD flags
, const void* data
,
77 const member_info
* mems
, size_t num_mems
)
81 for (i
=0; i
< num_mems
; i
++)
83 if (mems
[i
].val
& flags
)
85 DPRINTF(" - %s : ", mems
[i
].name
);
86 mems
[i
].func((const char *)data
+ mems
[i
].offset
);
92 void DDRAW_dump_DDBLTFX(DWORD flagmask
)
94 static const flag_info flags
[] =
96 FE(DDBLTFX_ARITHSTRETCHY
),
97 FE(DDBLTFX_MIRRORLEFTRIGHT
),
98 FE(DDBLTFX_MIRRORUPDOWN
),
99 FE(DDBLTFX_NOTEARING
),
100 FE(DDBLTFX_ROTATE180
),
101 FE(DDBLTFX_ROTATE270
),
102 FE(DDBLTFX_ROTATE90
),
103 FE(DDBLTFX_ZBUFFERRANGE
),
104 FE(DDBLTFX_ZBUFFERBASEDEST
)
107 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
110 void DDRAW_dump_DDBLTFAST(DWORD flagmask
)
112 static const flag_info flags
[] =
114 FE(DDBLTFAST_NOCOLORKEY
),
115 FE(DDBLTFAST_SRCCOLORKEY
),
116 FE(DDBLTFAST_DESTCOLORKEY
),
120 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
123 void DDRAW_dump_DDBLT(DWORD flagmask
)
125 static const flag_info flags
[] =
128 FE(DDBLT_ALPHADESTCONSTOVERRIDE
),
129 FE(DDBLT_ALPHADESTNEG
),
130 FE(DDBLT_ALPHADESTSURFACEOVERRIDE
),
131 FE(DDBLT_ALPHAEDGEBLEND
),
133 FE(DDBLT_ALPHASRCCONSTOVERRIDE
),
134 FE(DDBLT_ALPHASRCNEG
),
135 FE(DDBLT_ALPHASRCSURFACEOVERRIDE
),
141 FE(DDBLT_KEYDESTOVERRIDE
),
143 FE(DDBLT_KEYSRCOVERRIDE
),
145 FE(DDBLT_ROTATIONANGLE
),
147 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE
),
148 FE(DDBLT_ZBUFFERDESTOVERRIDE
),
149 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE
),
150 FE(DDBLT_ZBUFFERSRCOVERRIDE
),
155 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
158 void DDRAW_dump_DDSCAPS(const DDSCAPS2
*in
)
160 static const flag_info flags
[] =
162 FE(DDSCAPS_RESERVED1
),
164 FE(DDSCAPS_BACKBUFFER
),
167 FE(DDSCAPS_FRONTBUFFER
),
168 FE(DDSCAPS_OFFSCREENPLAIN
),
171 FE(DDSCAPS_PRIMARYSURFACE
),
172 FE(DDSCAPS_PRIMARYSURFACELEFT
),
173 FE(DDSCAPS_SYSTEMMEMORY
),
175 FE(DDSCAPS_3DDEVICE
),
176 FE(DDSCAPS_VIDEOMEMORY
),
178 FE(DDSCAPS_WRITEONLY
),
181 FE(DDSCAPS_LIVEVIDEO
),
185 FE(DDSCAPS_RESERVED2
),
186 FE(DDSCAPS_ALLOCONLOAD
),
187 FE(DDSCAPS_VIDEOPORT
),
188 FE(DDSCAPS_LOCALVIDMEM
),
189 FE(DDSCAPS_NONLOCALVIDMEM
),
190 FE(DDSCAPS_STANDARDVGAMODE
),
191 FE(DDSCAPS_OPTIMIZED
)
194 DDRAW_dump_flags_(in
->dwCaps
, flags
, sizeof(flags
)/sizeof(flags
[0]), 0);
197 void DDRAW_dump_pixelformat_flag(DWORD flagmask
)
199 static const flag_info flags
[] =
201 FE(DDPF_ALPHAPIXELS
),
204 FE(DDPF_PALETTEINDEXED4
),
205 FE(DDPF_PALETTEINDEXEDTO8
),
206 FE(DDPF_PALETTEINDEXED8
),
212 FE(DDPF_PALETTEINDEXED1
),
213 FE(DDPF_PALETTEINDEXED2
),
217 DDRAW_dump_flags_(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]), 0);
220 void DDRAW_dump_paletteformat(DWORD dwFlags
)
222 static const flag_info flags
[] =
225 FE(DDPCAPS_8BITENTRIES
),
227 FE(DDPCAPS_INITIALIZE
),
228 FE(DDPCAPS_PRIMARYSURFACE
),
229 FE(DDPCAPS_PRIMARYSURFACELEFT
),
230 FE(DDPCAPS_ALLOW256
),
237 DDRAW_dump_flags(dwFlags
, flags
, sizeof(flags
)/sizeof(flags
[0]));
240 void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
) {
242 DDRAW_dump_pixelformat_flag(pf
->dwFlags
);
243 if (pf
->dwFlags
& DDPF_FOURCC
) {
244 DPRINTF(", dwFourCC code '%c%c%c%c' (0x%08lx) - %ld bits per pixel",
245 (unsigned char)( pf
->dwFourCC
&0xff),
246 (unsigned char)((pf
->dwFourCC
>> 8)&0xff),
247 (unsigned char)((pf
->dwFourCC
>>16)&0xff),
248 (unsigned char)((pf
->dwFourCC
>>24)&0xff),
253 if (pf
->dwFlags
& DDPF_RGB
) {
255 DPRINTF(", RGB bits: %ld, ", pf
->u1
.dwRGBBitCount
);
256 switch (pf
->u1
.dwRGBBitCount
) {
257 case 4: cmd
= "%1lx"; break;
258 case 8: cmd
= "%02lx"; break;
259 case 16: cmd
= "%04lx"; break;
260 case 24: cmd
= "%06lx"; break;
261 case 32: cmd
= "%08lx"; break;
262 default: ERR("Unexpected bit depth !\n"); cmd
= "%d"; break;
264 DPRINTF(" R "); DPRINTF(cmd
, pf
->u2
.dwRBitMask
);
265 DPRINTF(" G "); DPRINTF(cmd
, pf
->u3
.dwGBitMask
);
266 DPRINTF(" B "); DPRINTF(cmd
, pf
->u4
.dwBBitMask
);
267 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
) {
268 DPRINTF(" A "); DPRINTF(cmd
, pf
->u5
.dwRGBAlphaBitMask
);
270 if (pf
->dwFlags
& DDPF_ZPIXELS
) {
271 DPRINTF(" Z "); DPRINTF(cmd
, pf
->u5
.dwRGBZBitMask
);
274 if (pf
->dwFlags
& DDPF_ZBUFFER
) {
275 DPRINTF(", Z bits : %ld", pf
->u1
.dwZBufferBitDepth
);
277 if (pf
->dwFlags
& DDPF_ALPHA
) {
278 DPRINTF(", Alpha bits : %ld", pf
->u1
.dwAlphaBitDepth
);
283 void DDRAW_dump_colorkeyflag(DWORD ck
)
285 static const flag_info flags
[] =
287 FE(DDCKEY_COLORSPACE
),
289 FE(DDCKEY_DESTOVERLAY
),
291 FE(DDCKEY_SRCOVERLAY
)
294 DDRAW_dump_flags(ck
, flags
, sizeof(flags
)/sizeof(flags
[0]));
297 static void DDRAW_dump_DWORD(const void *in
) {
298 DPRINTF("%ld", *((const DWORD
*) in
));
300 static void DDRAW_dump_PTR(const void *in
) {
301 DPRINTF("%p", *((const void **) in
));
303 void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*ddck
) {
304 DPRINTF(" Low : %ld - High : %ld", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
307 void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
)
309 #define STRUCT DDSURFACEDESC2
310 static const member_info members
[] =
312 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS
, ddsCaps
),
313 ME(DDSD_HEIGHT
, DDRAW_dump_DWORD
, dwHeight
),
314 ME(DDSD_WIDTH
, DDRAW_dump_DWORD
, dwWidth
),
315 ME(DDSD_PITCH
, DDRAW_dump_DWORD
, u1
.lPitch
),
316 ME(DDSD_LINEARSIZE
, DDRAW_dump_DWORD
, u1
.dwLinearSize
),
317 ME(DDSD_BACKBUFFERCOUNT
, DDRAW_dump_DWORD
, dwBackBufferCount
),
318 ME(DDSD_MIPMAPCOUNT
, DDRAW_dump_DWORD
, u2
.dwMipMapCount
),
319 ME(DDSD_REFRESHRATE
, DDRAW_dump_DWORD
, u2
.dwRefreshRate
),
320 ME(DDSD_ALPHABITDEPTH
, DDRAW_dump_DWORD
, dwAlphaBitDepth
),
321 ME(DDSD_LPSURFACE
, DDRAW_dump_PTR
, lpSurface
),
322 ME(DDSD_CKDESTOVERLAY
, DDRAW_dump_DDCOLORKEY
, u3
.ddckCKDestOverlay
),
323 ME(DDSD_CKDESTBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKDestBlt
),
324 ME(DDSD_CKSRCOVERLAY
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcOverlay
),
325 ME(DDSD_CKSRCBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcBlt
),
326 ME(DDSD_PIXELFORMAT
, DDRAW_dump_pixelformat
, u4
.ddpfPixelFormat
)
329 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members
,
330 sizeof(members
)/sizeof(members
[0]));
333 void DDRAW_dump_cooperativelevel(DWORD cooplevel
)
335 static const flag_info flags
[] =
337 FE(DDSCL_FULLSCREEN
),
338 FE(DDSCL_ALLOWREBOOT
),
339 FE(DDSCL_NOWINDOWCHANGES
),
341 FE(DDSCL_ALLOWMODEX
),
343 FE(DDSCL_SETFOCUSWINDOW
),
344 FE(DDSCL_SETDEVICEWINDOW
),
345 FE(DDSCL_CREATEDEVICEWINDOW
)
351 DDRAW_dump_flags(cooplevel
, flags
, sizeof(flags
)/sizeof(flags
[0]));
355 void DDRAW_dump_DDCAPS(const DDCAPS
*lpcaps
) {
356 static const flag_info flags1
[] = {
358 FE(DDCAPS_ALIGNBOUNDARYDEST
),
359 FE(DDCAPS_ALIGNSIZEDEST
),
360 FE(DDCAPS_ALIGNBOUNDARYSRC
),
361 FE(DDCAPS_ALIGNSIZESRC
),
362 FE(DDCAPS_ALIGNSTRIDE
),
365 FE(DDCAPS_BLTFOURCC
),
366 FE(DDCAPS_BLTSTRETCH
),
369 FE(DDCAPS_OVERLAYCANTCLIP
),
370 FE(DDCAPS_OVERLAYFOURCC
),
371 FE(DDCAPS_OVERLAYSTRETCH
),
373 FE(DDCAPS_PALETTEVSYNC
),
374 FE(DDCAPS_READSCANLINE
),
375 FE(DDCAPS_STEREOVIEW
),
378 FE(DDCAPS_ZOVERLAYS
),
381 FE(DDCAPS_COLORKEYHWASSIST
),
382 FE(DDCAPS_NOHARDWARE
),
383 FE(DDCAPS_BLTCOLORFILL
),
384 FE(DDCAPS_BANKSWITCHED
),
385 FE(DDCAPS_BLTDEPTHFILL
),
387 FE(DDCAPS_CANCLIPSTRETCHED
),
388 FE(DDCAPS_CANBLTSYSMEM
)
390 static const flag_info flags2
[] = {
391 FE(DDCAPS2_CERTIFIED
),
392 FE(DDCAPS2_NO2DDURING3DSCENE
),
393 FE(DDCAPS2_VIDEOPORT
),
394 FE(DDCAPS2_AUTOFLIPOVERLAY
),
395 FE(DDCAPS2_CANBOBINTERLEAVED
),
396 FE(DDCAPS2_CANBOBNONINTERLEAVED
),
397 FE(DDCAPS2_COLORCONTROLOVERLAY
),
398 FE(DDCAPS2_COLORCONTROLPRIMARY
),
399 FE(DDCAPS2_CANDROPZ16BIT
),
400 FE(DDCAPS2_NONLOCALVIDMEM
),
401 FE(DDCAPS2_NONLOCALVIDMEMCAPS
),
402 FE(DDCAPS2_NOPAGELOCKREQUIRED
),
403 FE(DDCAPS2_WIDESURFACES
),
404 FE(DDCAPS2_CANFLIPODDEVEN
),
405 FE(DDCAPS2_CANBOBHARDWARE
),
406 FE(DDCAPS2_COPYFOURCC
),
407 FE(DDCAPS2_PRIMARYGAMMA
),
408 FE(DDCAPS2_CANRENDERWINDOWED
),
409 FE(DDCAPS2_CANCALIBRATEGAMMA
),
410 FE(DDCAPS2_FLIPINTERVAL
),
411 FE(DDCAPS2_FLIPNOVSYNC
),
412 FE(DDCAPS2_CANMANAGETEXTURE
),
413 FE(DDCAPS2_TEXMANINNONLOCALVIDMEM
),
415 FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL
)
417 static const flag_info flags3
[] = {
418 FE(DDCKEYCAPS_DESTBLT
),
419 FE(DDCKEYCAPS_DESTBLTCLRSPACE
),
420 FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV
),
421 FE(DDCKEYCAPS_DESTBLTYUV
),
422 FE(DDCKEYCAPS_DESTOVERLAY
),
423 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE
),
424 FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV
),
425 FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE
),
426 FE(DDCKEYCAPS_DESTOVERLAYYUV
),
427 FE(DDCKEYCAPS_SRCBLT
),
428 FE(DDCKEYCAPS_SRCBLTCLRSPACE
),
429 FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV
),
430 FE(DDCKEYCAPS_SRCBLTYUV
),
431 FE(DDCKEYCAPS_SRCOVERLAY
),
432 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE
),
433 FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV
),
434 FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE
),
435 FE(DDCKEYCAPS_SRCOVERLAYYUV
),
436 FE(DDCKEYCAPS_NOCOSTOVERLAY
)
438 static const flag_info flags4
[] = {
439 FE(DDFXCAPS_BLTALPHA
),
440 FE(DDFXCAPS_OVERLAYALPHA
),
441 FE(DDFXCAPS_BLTARITHSTRETCHYN
),
442 FE(DDFXCAPS_BLTARITHSTRETCHY
),
443 FE(DDFXCAPS_BLTMIRRORLEFTRIGHT
),
444 FE(DDFXCAPS_BLTMIRRORUPDOWN
),
445 FE(DDFXCAPS_BLTROTATION
),
446 FE(DDFXCAPS_BLTROTATION90
),
447 FE(DDFXCAPS_BLTSHRINKX
),
448 FE(DDFXCAPS_BLTSHRINKXN
),
449 FE(DDFXCAPS_BLTSHRINKY
),
450 FE(DDFXCAPS_BLTSHRINKYN
),
451 FE(DDFXCAPS_BLTSTRETCHX
),
452 FE(DDFXCAPS_BLTSTRETCHXN
),
453 FE(DDFXCAPS_BLTSTRETCHY
),
454 FE(DDFXCAPS_BLTSTRETCHYN
),
455 FE(DDFXCAPS_OVERLAYARITHSTRETCHY
),
456 FE(DDFXCAPS_OVERLAYARITHSTRETCHYN
),
457 FE(DDFXCAPS_OVERLAYSHRINKX
),
458 FE(DDFXCAPS_OVERLAYSHRINKXN
),
459 FE(DDFXCAPS_OVERLAYSHRINKY
),
460 FE(DDFXCAPS_OVERLAYSHRINKYN
),
461 FE(DDFXCAPS_OVERLAYSTRETCHX
),
462 FE(DDFXCAPS_OVERLAYSTRETCHXN
),
463 FE(DDFXCAPS_OVERLAYSTRETCHY
),
464 FE(DDFXCAPS_OVERLAYSTRETCHYN
),
465 FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT
),
466 FE(DDFXCAPS_OVERLAYMIRRORUPDOWN
)
468 static const flag_info flags5
[] = {
469 FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND
),
470 FE(DDFXALPHACAPS_BLTALPHAPIXELS
),
471 FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG
),
472 FE(DDFXALPHACAPS_BLTALPHASURFACES
),
473 FE(DDFXALPHACAPS_BLTALPHASURFACESNEG
),
474 FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND
),
475 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS
),
476 FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG
),
477 FE(DDFXALPHACAPS_OVERLAYALPHASURFACES
),
478 FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG
)
480 static const flag_info flags6
[] = {
482 FE(DDPCAPS_8BITENTRIES
),
484 FE(DDPCAPS_INITIALIZE
),
485 FE(DDPCAPS_PRIMARYSURFACE
),
486 FE(DDPCAPS_PRIMARYSURFACELEFT
),
487 FE(DDPCAPS_ALLOW256
),
493 static const flag_info flags7
[] = {
494 FE(DDSVCAPS_RESERVED1
),
495 FE(DDSVCAPS_RESERVED2
),
496 FE(DDSVCAPS_RESERVED3
),
497 FE(DDSVCAPS_RESERVED4
),
498 FE(DDSVCAPS_STEREOSEQUENTIAL
),
501 DPRINTF(" - dwSize : %ld\n", lpcaps
->dwSize
);
502 DPRINTF(" - dwCaps : "); DDRAW_dump_flags(lpcaps
->dwCaps
, flags1
, sizeof(flags1
)/sizeof(flags1
[0]));
503 DPRINTF(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps
->dwCaps2
, flags2
, sizeof(flags2
)/sizeof(flags2
[0]));
504 DPRINTF(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps
->dwCKeyCaps
, flags3
, sizeof(flags3
)/sizeof(flags3
[0]));
505 DPRINTF(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps
->dwFXCaps
, flags4
, sizeof(flags4
)/sizeof(flags4
[0]));
506 DPRINTF(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps
->dwFXAlphaCaps
, flags5
, sizeof(flags5
)/sizeof(flags5
[0]));
507 DPRINTF(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps
->dwPalCaps
, flags6
, sizeof(flags6
)/sizeof(flags6
[0]));
508 DPRINTF(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps
->dwSVCaps
, flags7
, sizeof(flags7
)/sizeof(flags7
[0]));
510 DPRINTF(" - dwNumFourCCCodes : %ld\n", lpcaps
->dwNumFourCCCodes
);
511 DPRINTF(" - dwCurrVisibleOverlays : %ld\n", lpcaps
->dwCurrVisibleOverlays
);
512 DPRINTF(" - dwMinOverlayStretch : %ld\n", lpcaps
->dwMinOverlayStretch
);
513 DPRINTF(" - dwMaxOverlayStretch : %ld\n", lpcaps
->dwMaxOverlayStretch
);
515 DPRINTF(" - ddsCaps : "); DDRAW_dump_DDSCAPS(&lpcaps
->ddsCaps
); DPRINTF("\n");