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);
1166 TRACE(
"iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
1177 TRACE(
"iface %p, width %u, height %u, bpp %u, refresh_rate %u, flags %#x.\n",
1194 memset(caps1, 0,
sizeof(*caps1));
1195 caps1->
dwSize =
sizeof(*caps1);
1255 memset(&wined3d_caps, 0,
sizeof(wined3d_caps));
1262 WARN(
"Failed to get device caps, hr %#x.\n",
hr);
1432 caps->
deviceGUID = IID_IDirect3DTnLHalDevice;
1446 switch (
format->u1.dwZBufferBitDepth)
1449 caps->dwZBufferBitDepths |=
DDBD_8;
1452 caps->dwZBufferBitDepths |=
DDBD_16;
1455 caps->dwZBufferBitDepths |=
DDBD_24;
1458 caps->dwZBufferBitDepths |=
DDBD_32;
1487 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, DriverCaps, HELCaps);
1490 if (!DriverCaps && !HELCaps)
1492 WARN(
"Invalid parameters.\n");
1496 memset(&caps, 0,
sizeof(caps));
1497 memset(&winecaps, 0,
sizeof(winecaps));
1498 caps.dwSize =
sizeof(caps);
1504 WARN(
"Failed to get device caps, %#x.\n",
hr);
1509 hr = IDirectDraw7_GetAvailableVidMem(iface, &ddscaps, &caps.dwVidMemTotal, &caps.dwVidMemFree);
1512 WARN(
"IDirectDraw7::GetAvailableVidMem failed\n");
1517 hr = IDirectDraw7_GetFourCCCodes(iface, &caps.dwNumFourCCCodes,
NULL);
1521 WARN(
"IDirectDraw7::GetFourCCCodes failed\n");
1527 caps.dwCKeyCaps = winecaps.
ddraw_caps.color_key_caps;
1530 caps.ddsCaps.dwCaps = winecaps.
ddraw_caps.dds_caps;
1531 caps.dwSVBCaps = winecaps.
ddraw_caps.svb_caps;
1532 caps.dwSVBCKeyCaps = winecaps.
ddraw_caps.svb_color_key_caps;
1533 caps.dwSVBFXCaps = winecaps.
ddraw_caps.svb_fx_caps;
1534 caps.dwVSBCaps = winecaps.
ddraw_caps.vsb_caps;
1535 caps.dwVSBCKeyCaps = winecaps.
ddraw_caps.vsb_color_key_caps;
1536 caps.dwVSBFXCaps = winecaps.
ddraw_caps.vsb_fx_caps;
1537 caps.dwSSBCaps = winecaps.
ddraw_caps.ssb_caps;
1538 caps.dwSSBCKeyCaps = winecaps.
ddraw_caps.ssb_color_key_caps;
1539 caps.dwSSBFXCaps = winecaps.
ddraw_caps.ssb_fx_caps;
1544 caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps;
1553 TRACE(
"Driver Caps :\n");
1563 TRACE(
"HEL Caps :\n");
1575 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1584 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1593 TRACE(
"iface %p, driver_caps %p, hel_caps %p.\n", iface, driver_caps, hel_caps);
1609 TRACE(
"iface %p.\n", iface);
1618 TRACE(
"iface %p.\n", iface);
1627 TRACE(
"iface %p.\n", iface);
1636 TRACE(
"iface %p.\n", iface);
1661 TRACE(
"iface %p, surface_desc %p.\n", iface, DDSD);
1671 ERR(
"Failed to get display mode, hr %#x.\n",
hr);
1677 DDSD->
dwSize =
sizeof(*DDSD);
1689 TRACE(
"Returning surface desc :\n");
1702 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1712 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1715 if (
SUCCEEDED(
hr)) surface_desc->dwSize =
sizeof(*surface_desc);
1724 TRACE(
"iface %p, surface_desc %p.\n", iface, surface_desc);
1727 if (
SUCCEEDED(
hr)) surface_desc->dwSize =
sizeof(*surface_desc);
1761 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, NumCodes, Codes);
1765 ERR(
"Failed to get display mode, hr %#x.\n",
hr);
1769 outsize = NumCodes && Codes ? *NumCodes : 0;
1793 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1802 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1811 TRACE(
"iface %p, codes_count %p, codes %p.\n", iface, codes_count, codes);
1829 WARN(
"Failed to get display mode, hr %#x.\n",
hr);
1881 WARN(
"Failed to get raster status, hr %#x.\n",
hr);
1935 unsigned int framebuffer_size, total_vidmem, free_vidmem;
1940 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
1947 TRACE(
"Asked for memory with description: ");
1962 WARN(
"Failed to get display mode, hr %#x.\n",
hr);
1968 framebuffer_size *=
mode.height;
1973 *
free = framebuffer_size > free_vidmem ? 0 : free_vidmem - framebuffer_size;
1974 TRACE(
"Free video memory %#x.\n", *
free);
1983 *
total = framebuffer_size > total_vidmem ? 0 : total_vidmem - framebuffer_size;
1997 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
2008 TRACE(
"iface %p, caps %p, total %p, free %p.\n", iface, caps,
total,
free);
2100 TRACE(
"iface %p.\n", iface);
2104 if (
FAILED(
hr = IDirectDraw7_GetGDISurface(iface, &gdi_surface)))
2106 WARN(
"Failed to retrieve GDI surface, hr %#x.\n",
hr);
2116 IDirectDrawSurface7_Release(gdi_surface);
2127 TRACE(
"iface %p.\n", iface);
2136 TRACE(
"iface %p.\n", iface);
2145 TRACE(
"iface %p.\n", iface);
2220 TRACE(
"iface %p, line %p.\n", iface, Scanline);
2227 WARN(
"Failed to get raster status, hr %#x.\n",
hr);
2243 TRACE(
"iface %p, line %p.\n", iface,
line);
2252 TRACE(
"iface %p, line %p.\n", iface,
line);
2261 TRACE(
"iface %p, line %p.\n", iface,
line);
2270 TRACE(
"iface %p.\n", iface);
2279 TRACE(
"iface %p.\n", iface);
2302 TRACE(
"iface %p, surface %p.\n", iface, GDISurface);
2306 if (!(*GDISurface = &
ddraw->
primary->IDirectDrawSurface7_iface))
2308 WARN(
"Primary not created yet.\n");
2312 IDirectDrawSurface7_AddRef(*GDISurface);
2326 TRACE(
"iface %p, surface %p.\n", iface, surface);
2336 IDirectDrawSurface4_AddRef(*surface);
2337 IDirectDrawSurface7_Release(surface7);
2349 TRACE(
"iface %p, surface %p.\n", iface, surface);
2359 IDirectDrawSurface_AddRef(*surface);
2360 IDirectDrawSurface7_Release(surface7);
2372 TRACE(
"iface %p, surface %p.\n", iface, surface);
2382 IDirectDrawSurface_AddRef(*surface);
2383 IDirectDrawSurface7_Release(surface7);
2427 unsigned int modenum,
fmt;
2429 unsigned enum_mode_count = 0, enum_mode_array_size = 16;
2439 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2445 if (!(enum_modes =
heap_alloc(enum_mode_array_size *
sizeof(*enum_modes))))
2475 for (
i = 0;
i < enum_mode_count;
i++)
2487 memset(&callback_sd, 0,
sizeof(callback_sd));
2488 callback_sd.
dwSize =
sizeof(callback_sd);
2502 callback_sd.u1.
lPitch = (callback_sd.u1.
lPitch + 3) & ~3;
2509 TRACE(
"Application asked to terminate the enumeration\n");
2515 if (enum_mode_count == enum_mode_array_size)
2519 enum_mode_array_size *= 2;
2520 if (!(new_enum_modes =
heap_realloc(enum_modes, enum_mode_array_size *
sizeof(*new_enum_modes))))
2527 enum_modes = new_enum_modes;
2529 enum_modes[enum_mode_count++] =
mode;
2533 TRACE(
"End of enumeration\n");
2545 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2558 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2564 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
2576 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
2582 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
2634 TRACE(
"iface %p, device_identifier %p, flags %#x.\n", iface, DDDI,
Flags);
2680 TRACE(
"iface %p, identifier %p, flags %#x.\n", iface, identifier,
flags);
2708 TRACE(
"iface %p, dc %p, surface %p.\n", iface,
dc, surface);
2719 if (surface_impl->
dc !=
dc)
2722 TRACE(
"Found surface %p for dc %p.\n", surface_impl,
dc);
2724 IDirectDrawSurface7_AddRef(*surface);
2731 TRACE(
"No surface found for dc %p.\n",
dc);
2737 IDirectDrawSurface4 **surface)
2744 TRACE(
"iface %p, dc %p, surface %p.\n", iface,
dc, surface);
2758 IDirectDrawSurface7_Release(surface7);
2765 IDirectDrawSurface_Restore(surface);
2766 IDirectDrawSurface_Release(surface);
2773 TRACE(
"iface %p.\n", iface);
2783 TRACE(
"iface %p.\n", iface);
2812 FIXME(
"iface %p, modes %p, mode_count %u, flags %#x partial stub!\n",
2836 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2843 WARN(
"Cooperative level not set.\n");
2850 WARN(
"Application supplied invalid surface descriptor\n");
2861 WARN(
"Surface pointer %p is invalid.\n", surface);
2871 TRACE(
" (%p) Requesting surface desc :\n", iface);
2875 WARN(
"Application tried to create an explicit front or back buffer\n");
2886 IDirectDraw7_AddRef(iface);
2899 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2906 WARN(
"Cooperative level not set.\n");
2913 WARN(
"Application supplied invalid surface descriptor\n");
2924 WARN(
"Surface pointer %p is invalid.\n", surface);
2934 TRACE(
" (%p) Requesting surface desc :\n", iface);
2938 WARN(
"Application tried to create an explicit front or back buffer\n");
2949 IDirectDraw4_AddRef(iface);
2963 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
2970 WARN(
"Cooperative level not set.\n");
2977 WARN(
"Application supplied invalid surface descriptor\n");
2988 WARN(
"Surface pointer %p is invalid.\n", surface);
2999 TRACE(
" (%p) Requesting surface desc :\n", iface);
3003 WARN(
"Application tried to create an explicit front or back buffer\n");
3027 TRACE(
"iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
3034 WARN(
"Cooperative level not set.\n");
3041 WARN(
"Application supplied invalid surface descriptor\n");
3052 WARN(
"Surface pointer %p is invalid.\n", surface);
3063 WARN(
"Application tried to create an explicit front or back buffer.\n");
3092 if ((requested->
dwFlags & must_match) != (provided->
dwFlags & must_match))
3135#define CMP(FLAG, FIELD) \
3136 { DDSD_##FLAG, offsetof(DDSURFACEDESC2, FIELD), \
3137 sizeof(((DDSURFACEDESC2 *)(NULL))->FIELD) }
3142 CMP(BACKBUFFERCOUNT,
u5.dwBackBufferCount),
3144 CMP(CKDESTBLT, ddckCKDestBlt),
3145 CMP(CKDESTOVERLAY,
u3 ),
3146 CMP(CKSRCBLT, ddckCKSrcBlt),
3147 CMP(CKSRCOVERLAY, ddckCKSrcOverlay),
3149 CMP(LINEARSIZE,
u1 ),
3150 CMP(LPSURFACE, lpSurface),
3151 CMP(MIPMAPCOUNT,
u2 ),
3154 CMP(REFRESHRATE,
u2 ),
3155 CMP(TEXTURESTAGE, dwTextureStage),
3205 IDirectDrawSurface7_Release(surface);
3208 surface_desc, cbcontext->
context);
3218 IDirectDrawSurface7_Release(surface);
3250 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3268 memcpy(&testdesc, DDSD,
sizeof(testdesc));
3280 hr = IDirectDraw7_CreateSurface(iface, &testdesc, &surface,
NULL);
3285 IDirectDrawSurface7_Release(surface);
3288 ERR(
"Failed to create surface, hr %#x.\n",
hr);
3297 if (match_flags != 0 &&
3318 WARN(
"Not enumerating surface %p because it doesn't have any references.\n", surf);
3324 TRACE(
"Enumerating surface %p.\n", surf);
3349 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3366 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3372 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
3384 TRACE(
"iface %p, flags %#x, surface_desc %p, context %p, callback %p.\n",
3390 if (surface_desc)
DDSD_to_DDSD2(surface_desc, &surface_desc2);
3415 TRACE(
"flags %#x, clipper %p, outer_unknown %p.\n",
3416 flags, clipper, outer_unknown);
3423 if (!(
object = heap_alloc_zero(
sizeof(*
object))))
3432 WARN(
"Failed to initialize clipper, hr %#x.\n",
hr);
3438 TRACE(
"Created clipper %p.\n",
object);
3439 *clipper = &
object->IDirectDrawClipper_iface;
3452 IDirectDrawClipper **Clipper,
IUnknown *UnkOuter)
3454 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3455 iface,
Flags, Clipper, UnkOuter);
3461 IDirectDrawClipper **clipper,
IUnknown *outer_unknown)
3465 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3466 iface,
flags, clipper, outer_unknown);
3476 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3477 iface,
flags, clipper, outer_unknown);
3487 TRACE(
"iface %p, flags %#x, clipper %p, outer_unknown %p.\n",
3488 iface,
flags, clipper, outer_unknown);
3517 TRACE(
"iface %p, flags %#x, color_table %p, palette %p, outer_unknown %p.\n",
3518 iface,
Flags, ColorTable, Palette, pUnkOuter);
3528 WARN(
"No cooperative level set, returning DDERR_NOCOOPERATIVELEVELSET\n");
3535 ERR(
"Out of memory when allocating memory for a palette implementation\n");
3543 WARN(
"Failed to initialize palette, hr %#x.\n",
hr);
3549 TRACE(
"Created palette %p.\n",
object);
3550 *Palette = &
object->IDirectDrawPalette_iface;
3562 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3570 IDirectDraw4_AddRef(iface);
3582 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3602 TRACE(
"iface %p, flags %#x, entries %p, palette %p, outer_unknown %p.\n",
3638 FIXME(
"iface %p, src %p, dst %p partial stub!\n", iface, Src, Dest);
3641 return IDirectDraw7_CreateSurface(iface, &src_surface->
surface_desc, Dest,
NULL);
3645 IDirectDrawSurface4 **
dst)
3653 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3664 IDirectDrawSurface4_AddRef(*
dst);
3665 IDirectDrawSurface7_Release(dst7);
3671 IDirectDrawSurface *
src, IDirectDrawSurface **
dst)
3679 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3687 IDirectDrawSurface_AddRef(*
dst);
3688 IDirectDrawSurface7_Release(dst7);
3694 IDirectDrawSurface **
dst)
3702 TRACE(
"iface %p, src %p, dst %p.\n", iface,
src,
dst);
3710 IDirectDrawSurface_AddRef(*
dst);
3711 IDirectDrawSurface7_Release(dst7);
3758 device_desc7.
dwDevCaps = dev_caps & ~device_list7[
i].remove_caps;
3763 TRACE(
"Application cancelled the enumeration.\n");
3769 TRACE(
"End of enumeration.\n");
3795 static CHAR wined3d_description[] =
"Wine D3DDevice using WineD3D and OpenGL";
3843 static CHAR reference_description[] =
"RGB Direct3D emulation";
3845 TRACE(
"Enumerating WineD3D D3DDevice interface.\n");
3846 hal_desc = device_desc1;
3847 hel_desc = device_desc1;
3858 hr =
callback((
GUID *)&IID_IDirect3DRGBDevice, reference_description,
3862 TRACE(
"Application cancelled the enumeration.\n");
3870 TRACE(
"Enumerating HAL Direct3D device.\n");
3871 hal_desc = device_desc1;
3872 hel_desc = device_desc1;
3882 hr =
callback((
GUID *)&IID_IDirect3DHALDevice, wined3d_description,
3886 TRACE(
"Application cancelled the enumeration.\n");
3891 TRACE(
"End of enumeration.\n");
3943 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
3948 if (!(
object = heap_alloc_zero(
sizeof(*
object))))
3950 ERR(
"Failed to allocate light memory.\n");
3956 TRACE(
"Created light %p.\n",
object);
3957 *
light = &
object->IDirect3DLight_iface;
3966 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
3975 TRACE(
"iface %p, light %p, outer_unknown %p.\n", iface,
light, outer_unknown);
4006 TRACE(
"iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);
4013 ERR(
"Failed to allocate material memory.\n");
4017 TRACE(
"Created material %p.\n",
object);
4018 *material = &
object->IDirect3DMaterial3_iface;
4029 TRACE(
"iface %p, material %p, outer_unknown %p.\n", iface, material, outer_unknown);