41 { { 0x00010001, 0x00010001 } },
44 {0xa8373c10,0x7ac4,0x4deb, {0x84,0x9a,0x00,0x98,0x44,0xd0,0x8b,0x2d}},
58 "WINE Direct3D7 Hardware Transform and Lighting acceleration using WineD3D",
60 &IID_IDirect3DTnLHalDevice,
66 "WINE Direct3D7 Hardware acceleration using WineD3D",
68 &IID_IDirect3DHALDevice,
74 "WINE Direct3D7 RGB Software Emulation using WineD3D",
76 &IID_IDirect3DRGBDevice,
150 TRACE(
"Returning IDirectDraw7 interface %p.\n", *
out);
155 TRACE(
"Returning IDirectDraw4 interface %p.\n", *
out);
160 TRACE(
"Returning IDirectDraw2 interface %p.\n", *
out);
165 TRACE(
"Returning IDirectDraw interface %p.\n", *
out);
171 TRACE(
"Returning Direct3D7 interface %p.\n", *
out);
177 TRACE(
"Returning Direct3D3 interface %p.\n", *
out);
183 TRACE(
"Returning Direct3D2 interface %p.\n", *
out);
189 TRACE(
"Returning Direct3D interface %p.\n", *
out);
336 TRACE(
"iface %p.\n", iface);
345 TRACE(
"iface %p.\n", iface);
354 TRACE(
"iface %p.\n", iface);
363 TRACE(
"iface %p.\n", iface);
370 TRACE(
"Destroying the swapchain.\n");
388 ERR(
"Failed to uninit 3D.\n");
410 TRACE(
"Swapchain destroyed.\n");
426 IDirectDraw7_RestoreDisplayMode(&
This->IDirectDraw7_iface);
429 if(
This->devicewindow != 0)
431 TRACE(
" (%p) Destroying the device window %p\n",
This,
This->devicewindow);
433 This->devicewindow = 0;
440 if (
This->wined3d_swapchain)
515 TRACE(
"iface %p.\n", iface);
524 TRACE(
"iface %p.\n", iface);
533 TRACE(
"iface %p.\n", iface);
542 TRACE(
"iface %p.\n", iface);
557 TRACE(
"Setting DDSCL_SETFOCUSWINDOW with an already set window, returning DDERR_HWNDALREADYSET.\n");
586 WARN(
"No window for the Direct3DDevice, created hidden window %p.\n",
window);
592 TRACE(
"Using existing window %p for Direct3D rendering.\n",
window);
609 ERR(
"Error allocating an array for the converted vertex decls.\n");
615 TRACE(
"Successfully initialized 3D.\n");
628 ERR(
"Failed to get display mode.\n");
632 memset(&swapchain_desc, 0,
sizeof(swapchain_desc));
649 ERR(
"Failed to create swapchain, hr %#x.\n",
hr);
655 ERR(
"Failed to get swapchain.\n");
683 TRACE(
"iface %p.\n", iface);
713 TRACE(
"iface %p.\n", iface);
722 TRACE(
"iface %p.\n", iface);
731 TRACE(
"iface %p.\n", iface);
779 DWORD cooplevel,
BOOL restore_mode_on_normal)
786 TRACE(
"ddraw %p, window %p, flags %#x, restore_mode_on_normal %x.\n",
ddraw,
window, cooplevel,
787 restore_mode_on_normal);
794 WARN(
"Recursive call, returning DD_OK.\n");
805 TRACE(
"Incorrect cooplevel flags, returning DDERR_INVALIDPARAMS\n");
812 WARN(
"DDSCL_CREATEDEVICEWINDOW requires DDSCL_EXCLUSIVE.\n");
831 WARN(
"Called with incompatible flags, returning DDERR_INVALIDPARAMS.\n");
844 WARN(
"DDSCL_EXCLUSIVE requires DDSCL_FULLSCREEN and a window.\n");
855 WARN(
"No focus window set.\n");
871 TRACE(
"Created a device window %p.\n", device_window);
929 restore_state =
TRUE;
933 ERR(
"Failed to create stateblock, hr %#x.\n",
hr);
953 ERR(
"Failed to create swapchain, hr %#x.\n",
hr);
974 && restore_mode_on_normal)
978 ERR(
"RestoreDisplayMode failed\n");
991 ERR(
"Failed to acquire focus window, hr %#x.\n",
hr);
998 WARN(
"Unhandled flag DDSCL_ALLOWREBOOT, harmless\n");
1000 WARN(
"Unhandled flag DDSCL_ALLOWMODEX, harmless\n");
1002 WARN(
"Unhandled flag DDSCL_FPUSETUP, harmless\n");
1013 TRACE(
"SetCooperativeLevel returning DD_OK\n");
1092 TRACE(
"iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
1097 TRACE(
"ForceRefreshRate overriding passed-in refresh rate (%u Hz) to %u Hz\n",
1143 ERR(
"Failed to resize buffers, hr %#x.\n",
hr);
1170 TRACE(
"iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
1181 TRACE(
"iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
1198 memset(caps1, 0,
sizeof(*caps1));
1199 caps1->
dwSize =
sizeof(*caps1);
1259 memset(&wined3d_caps, 0,
sizeof(wined3d_caps));
1266 WARN(
"Failed to get device caps, hr %#x.\n",
hr);
1436 caps->
deviceGUID = IID_IDirect3DTnLHalDevice;
1450 switch (
format->u1.dwZBufferBitDepth)
1453 caps->dwZBufferBitDepths |=
DDBD_8;
1456 caps->dwZBufferBitDepths |=
DDBD_16;
1459 caps->dwZBufferBitDepths |=
DDBD_24;
1462 caps->dwZBufferBitDepths |=
DDBD_32;
1491 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, DriverCaps, HELCaps);
1494 if (!DriverCaps && !HELCaps)
1496 WARN(
"Invalid parameters.\n");
1500 memset(&caps, 0,
sizeof(caps));
1501 memset(&winecaps, 0,
sizeof(winecaps));
1502 caps.dwSize =
sizeof(caps);
1508 WARN(
"Failed to get device caps, %#x.\n",
hr);
1513 hr = IDirectDraw7_GetAvailableVidMem(iface, &ddscaps, &caps.dwVidMemTotal, &caps.dwVidMemFree);
1516 WARN(
"IDirectDraw7::GetAvailableVidMem failed\n");
1521 hr = IDirectDraw7_GetFourCCCodes(iface, &caps.dwNumFourCCCodes,
NULL);
1525 WARN(
"IDirectDraw7::GetFourCCCodes failed\n");
1531 caps.dwCKeyCaps = winecaps.
ddraw_caps.color_key_caps;
1534 caps.ddsCaps.dwCaps = winecaps.
ddraw_caps.dds_caps;
1535 caps.dwSVBCaps = winecaps.
ddraw_caps.svb_caps;
1536 caps.dwSVBCKeyCaps = winecaps.
ddraw_caps.svb_color_key_caps;
1537 caps.dwSVBFXCaps = winecaps.
ddraw_caps.svb_fx_caps;
1538 caps.dwVSBCaps = winecaps.
ddraw_caps.vsb_caps;
1539 caps.dwVSBCKeyCaps = winecaps.
ddraw_caps.vsb_color_key_caps;
1540 caps.dwVSBFXCaps = winecaps.
ddraw_caps.vsb_fx_caps;
1541 caps.dwSSBCaps = winecaps.
ddraw_caps.ssb_caps;
1542 caps.dwSSBCKeyCaps = winecaps.
ddraw_caps.ssb_color_key_caps;
1543 caps.dwSSBFXCaps = winecaps.
ddraw_caps.ssb_fx_caps;
1548 caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps;
1557 TRACE(
"Driver Caps :\n");
1567 TRACE(
"HEL Caps :\n");
1579 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1588 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1597 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1613 TRACE(
"iface %p.\n", iface);
1622 TRACE(
"iface %p.\n", iface);
1631 TRACE(
"iface %p.\n", iface);
1640 TRACE(
"iface %p.\n", iface);
1665 TRACE(
"iface %p, surface_desc %p.\n", iface, DDSD);
1675 ERR(
"Failed to get display mode, hr %#x.\n",
hr);
1681 DDSD->
dwSize =
sizeof(*DDSD);
1693 TRACE(
"Returning surface desc :\n");
1706 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1716 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1719 if (
SUCCEEDED(
hr)) surface_desc->dwSize =
sizeof(*surface_desc);
1728 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1731 if (
SUCCEEDED(
hr)) surface_desc->dwSize =
sizeof(*surface_desc);
1765 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
1769 ERR(
"Failed to get display mode, hr %#x.\n",
hr);
1773 outsize = NumCodes && Codes ? *NumCodes : 0;
1797 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1806 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1815 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1833 WARN(
"Failed to get display mode, hr %#x.\n",
hr);
1885 WARN(
"Failed to get raster status, hr %#x.\n",
hr);
1939 unsigned int framebuffer_size, total_vidmem, free_vidmem;
1944 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
1951 TRACE(
"Asked for memory with description: ");
1966 WARN(
"Failed to get display mode, hr %#x.\n",
hr);
1972 framebuffer_size *=
mode.height;
1977 *
free = framebuffer_size > free_vidmem ? 0 : free_vidmem - framebuffer_size;
1978 TRACE(
"Free video memory %#x.\n", *
free);
1987 *
total = framebuffer_size > total_vidmem ? 0 : total_vidmem - framebuffer_size;
2001 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
2012 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
2104 TRACE(
"iface %p.\n", iface);
2108 if (
FAILED(
hr = IDirectDraw7_GetGDISurface(iface, &gdi_surface)))
2110 WARN(
"Failed to retrieve GDI surface, hr %#x.\n",
hr);
2120 IDirectDrawSurface7_Release(gdi_surface);
2131 TRACE(
"iface %p.\n", iface);
2140 TRACE(
"iface %p.\n", iface);
2149 TRACE(
"iface %p.\n", iface);
2224 TRACE(
"iface %p, line %p.\n", iface, Scanline);
2231 WARN(
"Failed to get raster status, hr %#x.\n",
hr);
2247 TRACE(
"iface %p, line %p.\n", iface,
line);
2256 TRACE(
"iface %p, line %p.\n", iface,
line);
2265 TRACE(
"iface %p, line %p.\n", iface,
line);
2274 TRACE(
"iface %p.\n", iface);
2283 TRACE(
"iface %p.\n", iface);
2306 TRACE(
"iface %p, surface %p.\n", iface, GDISurface);
2310 if (!(*GDISurface = &
ddraw->
primary->IDirectDrawSurface7_iface))
2312 WARN(
"Primary not created yet.\n");
2316 IDirectDrawSurface7_AddRef(*GDISurface);
2330 TRACE(
"iface %p, surface %p.\n", iface, surface);
2340 IDirectDrawSurface4_AddRef(*surface);
2341 IDirectDrawSurface7_Release(surface7);
2353 TRACE(
"iface %p, surface %p.\n", iface, surface);
2363 IDirectDrawSurface_AddRef(*surface);
2364 IDirectDrawSurface7_Release(surface7);
2376 TRACE(
"iface %p, surface %p.\n", iface, surface);
2386 IDirectDrawSurface_AddRef(*surface);
2387 IDirectDrawSurface7_Release(surface7);
2431 unsigned int modenum,
fmt;
2433 unsigned enum_mode_count = 0, enum_mode_array_size = 16;
2443 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2449 if (!(enum_modes =
heap_alloc(enum_mode_array_size *
sizeof(*enum_modes))))
2479 for (
i = 0;
i < enum_mode_count;
i++)
2491 memset(&callback_sd, 0,
sizeof(callback_sd));
2492 callback_sd.
dwSize =
sizeof(callback_sd);
2506 callback_sd.u1.
lPitch = (callback_sd.u1.
lPitch + 3) & ~3;
2513 TRACE(
"Application asked to terminate the enumeration\n");
2519 if (enum_mode_count == enum_mode_array_size)
2523 enum_mode_array_size *= 2;
2524 if (!(new_enum_modes =
heap_realloc(enum_modes, enum_mode_array_size *
sizeof(*new_enum_modes))))
2531 enum_modes = new_enum_modes;
2533 enum_modes[enum_mode_count++] =
mode;
2537 TRACE(
"End of enumeration\n");
2549 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2562 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2568 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
2580 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2586 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
2638 TRACE(
"iface %p, device_identifier %p, flags %#x.\n", iface, DDDI,
Flags);
2684 TRACE(
"iface %p, identifier %p, flags %#x.\n", iface, identifier,
flags);
2712 TRACE(
"iface %p, dc %p, surface %p.\n", iface,
dc, surface);
2723 if (surface_impl->
dc !=
dc)
2726 TRACE(
"Found surface %p for dc %p.\n", surface_impl,
dc);
2728 IDirectDrawSurface7_AddRef(*surface);
2735 TRACE(
"No surface found for dc %p.\n",
dc);
2741 IDirectDrawSurface4 **surface)
2748 TRACE(
"iface %p, dc %p, surface %p.\n", iface,
dc, surface);
2762 IDirectDrawSurface7_Release(surface7);
2769 IDirectDrawSurface_Restore(surface);
2770 IDirectDrawSurface_Release(surface);
2777 TRACE(
"iface %p.\n", iface);
2787 TRACE(
"iface %p.\n", iface);
2816 FIXME(
"iface %p, modes %p, mode_count %u, flags %#x partial stub!\n",
2840 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2847 WARN(
"Cooperative level not set.\n");
2854 WARN(
"Application supplied invalid surface descriptor\n");
2865 WARN(
"Surface pointer %p is invalid.\n", surface);
2875 TRACE(
" (%p) Requesting surface desc :\n", iface);
2879 WARN(
"Application tried to create an explicit front or back buffer\n");
2890 IDirectDraw7_AddRef(iface);
2903 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2910 WARN(
"Cooperative level not set.\n");
2917 WARN(
"Application supplied invalid surface descriptor\n");
2928 WARN(
"Surface pointer %p is invalid.\n", surface);
2938 TRACE(
" (%p) Requesting surface desc :\n", iface);
2942 WARN(
"Application tried to create an explicit front or back buffer\n");
2953 IDirectDraw4_AddRef(iface);
2967 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2974 WARN(
"Cooperative level not set.\n");
2981 WARN(
"Application supplied invalid surface descriptor\n");
2992 WARN(
"Surface pointer %p is invalid.\n", surface);
3003 TRACE(
" (%p) Requesting surface desc :\n", iface);
3007 WARN(
"Application tried to create an explicit front or back buffer\n");
3031 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
3038 WARN(
"Cooperative level not set.\n");
3045 WARN(
"Application supplied invalid surface descriptor\n");
3056 WARN(
"Surface pointer %p is invalid.\n", surface);
3067 WARN(
"Application tried to create an explicit front or back buffer.\n");
3096 if ((requested->
dwFlags & must_match) != (provided->
dwFlags & must_match))
3139#define CMP(FLAG, FIELD) \
3140 { DDSD_##FLAG, offsetof(DDSURFACEDESC2, FIELD), \
3141 sizeof(((DDSURFACEDESC2 *)(NULL))->FIELD) }
3146 CMP(BACKBUFFERCOUNT,
u5.dwBackBufferCount),
3148 CMP(CKDESTBLT, ddckCKDestBlt),
3149 CMP(CKDESTOVERLAY,
u3 ),
3150 CMP(CKSRCBLT, ddckCKSrcBlt),
3151 CMP(CKSRCOVERLAY, ddckCKSrcOverlay),
3153 CMP(LINEARSIZE,
u1 ),
3154 CMP(LPSURFACE, lpSurface),
3155 CMP(MIPMAPCOUNT,
u2 ),
3158 CMP(REFRESHRATE,
u2 ),
3159 CMP(TEXTURESTAGE, dwTextureStage),
3209 IDirectDrawSurface7_Release(surface);
3212 surface_desc, cbcontext->
context);
3222 IDirectDrawSurface7_Release(surface);
3254 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3272 memcpy(&testdesc, DDSD,
sizeof(testdesc));
3284 hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface,
NULL);
3289 IDirectDrawSurface7_Release(surface);
3292 ERR(
"Failed to create surface, hr %#x.\n",
hr);
3301 if (match_flags != 0 &&
3322 WARN(
"Not enumerating surface %p because it doesn't have any references.\n", surf);
3328 TRACE(
"Enumerating surface %p.\n", surf);
3353 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3370 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3376 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
3388 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3394 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
3419 TRACE(
"flags %#x, clipper %p, outer_unknown %p.\n",
3420 flags, clipper, outer_unknown);
3427 if (!(
object = heap_alloc_zero(
sizeof(*
object))))
3436 WARN(
"Failed to initialize clipper, hr %#x.\n",
hr);
3442 TRACE(
"Created clipper %p.\n",
object);
3443 *clipper = &
object->IDirectDrawClipper_iface;
3456 IDirectDrawClipper **Clipper,
IUnknown *UnkOuter)
3458 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3459 iface,
Flags, Clipper, UnkOuter);
3465 IDirectDrawClipper **clipper,
IUnknown *outer_unknown)
3469 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3470 iface,
flags, clipper, outer_unknown);
3480 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3481 iface,
flags, clipper, outer_unknown);
3491 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3492 iface,
flags, clipper, outer_unknown);
3521 TRACE(
"iface %p, flags %#x, color_table %p, palette %p, outer_unknown %p.\n",
3522 iface,
Flags, ColorTable, Palette, pUnkOuter);
3532 WARN(
"No cooperative level set, returning DDERR_NOCOOPERATIVELEVELSET\n");
3539 ERR(
"Out of memory when allocating memory for a palette implementation\n");
3547 WARN(
"Failed to initialize palette, hr %#x.\n",
hr);
3553 TRACE(
"Created palette %p.\n",
object);
3554 *Palette = &
object->IDirectDrawPalette_iface;
3566 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3574 IDirectDraw4_AddRef(iface);
3586 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3606 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3642 FIXME(
"iface %p, src %p, dst %p partial stub!\n", iface, Src, Dest);
3645 return IDirectDraw7_CreateSurface(iface, &src_surface->
surface_desc, Dest,
NULL);
3649 IDirectDrawSurface4 **
dst)
3657 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3668 IDirectDrawSurface4_AddRef(*
dst);
3669 IDirectDrawSurface7_Release(dst7);
3675 IDirectDrawSurface *
src, IDirectDrawSurface **
dst)
3683 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3691 IDirectDrawSurface_AddRef(*
dst);
3692 IDirectDrawSurface7_Release(dst7);
3698 IDirectDrawSurface **
dst)
3706 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3714 IDirectDrawSurface_AddRef(*
dst);
3715 IDirectDrawSurface7_Release(dst7);
3762 device_desc7.
dwDevCaps = dev_caps & ~device_list7[
i].remove_caps;
3767 TRACE(
"Application cancelled the enumeration.\n");
3773 TRACE(
"End of enumeration.\n");
3799 static CHAR wined3d_description[] =
"Wine D3DDevice using WineD3D and OpenGL";
3847 static CHAR reference_description[] =
"RGB Direct3D emulation";
3849 TRACE(
"Enumerating WineD3D D3DDevice interface.\n");
3850 hal_desc = device_desc1;
3851 hel_desc = device_desc1;
3862 hr =
callback((
GUID *)&IID_IDirect3DRGBDevice, reference_description,
3866 TRACE(
"Application cancelled the enumeration.\n");
3874 TRACE(
"Enumerating HAL Direct3D device.\n");
3875 hal_desc = device_desc1;
3876 hel_desc = device_desc1;
3886 hr =
callback((
GUID *)&IID_IDirect3DHALDevice, wined3d_description,
3890 TRACE(
"Application cancelled the enumeration.\n");
3895 TRACE(
"End of enumeration.\n");
3947 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
3952 if (!(
object = heap_alloc_zero(
sizeof(*
object))))
3954 ERR(
"Failed to allocate light memory.\n");
3960 TRACE(
"Created light %p.\n",
object);
3961 *
light = &
object->IDirect3DLight_iface;
3970 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
3979 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
4010 TRACE(
"iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
4017 ERR(
"Failed to allocate material memory.\n");
4021 TRACE(
"Created material %p.\n",
object);
4022 *material = &
object->IDirect3DMaterial3_iface;