Commit ae5a4368 authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

- Make d3d8 know about the wined3d device and start using it.

- Move some of the screen mode related functions into wined3d and add untested support for the new d3d9 options of providing the format to some of the calls. - Move other functions from the directx interface into the common library and implement the calls from d3d9 as well. - Copy across the first of the functions used to make traces more readable, creating utils.c to store them in. Eventually the ones in d3d8 will be removed but for now just duplicate the code.
parent 469b41f2
......@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = d3d8.dll
IMPORTS = user32 gdi32 kernel32 advapi32
IMPORTS = wined3d user32 gdi32 advapi32 kernel32
EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
......
......@@ -51,14 +51,14 @@ void WINAPI DebugSetMute(void)
IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion)
{
IDirect3D8Impl *object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->lpVtbl = &Direct3D8_Vtbl;
object->direct3d8 = object;
object->ref = 1;
object->WineD3D = WineDirect3DCreate(SDKVersion, 8);
TRACE("SDKVersion = %x, Created Direct3D object at %p\n", SDKVersion, object);
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
return (IDirect3D8 *)object;
}
......
......@@ -66,6 +66,7 @@ extern int num_lock;
#include "windef.h"
#include "winbase.h"
#include "d3d8.h"
#include "wine/wined3d_interface.h"
extern int vs_mode;
#define VS_NONE 0
......@@ -284,6 +285,9 @@ struct IDirect3D8Impl
IDirect3D8Vtbl *lpVtbl;
DWORD ref;
/* The WineD3D device */
IWineD3D *WineD3D;
/* IDirect3D8 fields */
GL_Info gl_info;
BOOL isGLInfoValid;
......
......@@ -194,23 +194,22 @@ ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
ULONG ref = --This->ref;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0)
if (ref == 0) {
IWineD3D_Release(This->WineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3D Interface follow: */
HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
FIXME_(d3d_caps)("(%p)->(%p): stub\n", This, pInitializeFunction);
return D3D_OK;
return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
}
UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
/* FIXME: Set to one for now to imply the display */
TRACE_(d3d_caps)("(%p): Mostly stub, only returns primary display\n", This);
return 1;
return IWineD3D_GetAdapterCount(This->WineD3D);
}
HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
......@@ -264,142 +263,19 @@ HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
return D3D_OK;
}
/*#define DEBUG_SINGLE_MODE*/
#undef DEBUG_SINGLE_MODE
UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,
UINT Adapter) {
UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d)\n", This, Adapter);
if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int i = 0;
#if !defined( DEBUG_SINGLE_MODE )
DEVMODEW DevModeW;
while (EnumDisplaySettingsExW(NULL, i, &DevModeW, 0)) {
i++;
}
#else
i = 1;
#endif
TRACE_(d3d_caps)("(%p}->(Adapter: %d) => %d\n", This, Adapter, i);
return i;
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
return 0;
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, D3DFMT_UNKNOWN);
}
HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface,
UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p)\n", This, Adapter, Mode, pMode);
if (NULL == pMode ||
Adapter >= IDirect3D8Impl_GetAdapterCount(iface) ||
Mode >= IDirect3D8Impl_GetAdapterModeCount(iface, Adapter)) {
return D3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int bpp = 0;
#if !defined( DEBUG_SINGLE_MODE )
HDC hdc;
DEVMODEW DevModeW;
if (EnumDisplaySettingsExW(NULL, Mode, &DevModeW, 0))
{
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
bpp = DevModeW.dmBitsPerPel;
pMode->RefreshRate = D3DADAPTER_DEFAULT;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
}
}
else
{
TRACE_(d3d_caps)("Requested mode out of range %d\n", Mode);
return D3DERR_INVALIDCALL;
}
hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
bpp = min(GetDeviceCaps(hdc, BITSPIXEL), bpp);
DeleteDC(hdc);
switch (bpp) {
case 8: pMode->Format = D3DFMT_R3G3B2; break;
case 16: pMode->Format = D3DFMT_R5G6B5; break;
case 24: /* pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
default: pMode->Format = D3DFMT_UNKNOWN;
}
#else
if (Mode > 0) return D3DERR_INVALIDCALL;
pMode->Width = 800;
pMode->Height = 600;
pMode->RefreshRate = D3DADAPTER_DEFAULT;
pMode->Format = D3DFMT_A8R8G8B8;
bpp = 32;
#endif
TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x,%s) bpp %u\n", pMode->Width, pMode->Height, pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format), bpp);
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
return D3D_OK;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, D3DFMT_UNKNOWN, Mode, pMode);
}
HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface,
UINT Adapter, D3DDISPLAYMODE* pMode) {
HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
if (NULL == pMode ||
Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int bpp = 0;
DEVMODEW DevModeW;
EnumDisplaySettingsExW(NULL, (DWORD)-1, &DevModeW, 0);
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
bpp = DevModeW.dmBitsPerPel;
pMode->RefreshRate = D3DADAPTER_DEFAULT;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
}
switch (bpp) {
case 8: pMode->Format = D3DFMT_R3G3B2; break;
case 16: pMode->Format = D3DFMT_R5G6B5; break;
case 24: /*pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
default: pMode->Format = D3DFMT_UNKNOWN;
}
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%x\n", pMode->Width,
pMode->Height, pMode->RefreshRate, pMode->Format);
return D3D_OK;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, pMode);
}
HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
......@@ -877,16 +753,9 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D
HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
FIXME_(d3d_caps)("(%p)->(Adptr:%d)\n", This, Adapter);
if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
return NULL;
}
return D3D_OK;
return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
}
static void IDirect3D8Impl_FillGLCaps(LPDIRECT3D8 iface, Display* display) {
const char *GL_Extensions = NULL;
const char *GLX_Extensions = NULL;
......
......@@ -61,16 +61,18 @@ ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9 iface) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
ULONG ref = --This->ref;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0)
if (ref == 0) {
IWineD3D_Release(This->WineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3D9 Interface follow: */
HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9 iface, void* pInitializeFunction) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p)->(%p): stub\n", This, pInitializeFunction);
return D3D_OK;
return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
}
UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9 iface) {
......@@ -86,20 +88,17 @@ HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9 iface, UINT Adapt
UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p): stub\n", This);
return 0;
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, Format);
}
HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9 iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p): stub\n", This);
return D3D_OK;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, Format, Mode, pMode);
}
HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p): stub\n", This);
return D3D_OK;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, pMode);
}
HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(LPDIRECT3D9 iface,
......@@ -149,8 +148,7 @@ HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D
HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p) : stub\n", This);
return NULL;
return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
}
HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow,
......
......@@ -9,6 +9,7 @@ EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_
C_SRCS = \
directx.c \
utils.c \
vertexshader.c \
wined3d_main.c
......
......@@ -20,6 +20,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Compile time diagnostics: */
/* Uncomment this to force only a single display mode to be exposed: */
/*#define DEBUG_SINGLE_MODE*/
#include "config.h"
#include "wined3d_private.h"
......@@ -34,6 +40,223 @@ UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) {
return 1;
}
HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void* pInitializeFunction) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
FIXME("(%p)->(%p): stub\n", This, pInitializeFunction);
return D3D_OK;
}
HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
FIXME_(d3d_caps)("(%p)->(Adptr:%d)\n", This, Adapter);
if (Adapter >= IWineD3DImpl_GetAdapterCount(iface)) {
return NULL;
}
return D3D_OK;
}
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
of the same bpp but different resolutions */
/* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, D3DFORMAT Format) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, Format: %s)\n", This, Adapter, debug_d3dformat(Format));
if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
return 0;
}
if (Adapter == 0) { /* Display */
int i = 0;
int j = 0;
#if !defined( DEBUG_SINGLE_MODE )
DEVMODEW DevModeW;
/* Work out the current screen bpp */
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
int bpp = GetDeviceCaps(hdc, BITSPIXEL);
DeleteDC(hdc);
while (EnumDisplaySettingsExW(NULL, j, &DevModeW, 0)) {
j++;
switch (Format)
{
case D3DFMT_UNKNOWN:
i++;
break;
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
if (min(DevModeW.dmBitsPerPel, bpp) == 32) i++;
break;
case D3DFMT_X1R5G5B5:
case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5:
if (min(DevModeW.dmBitsPerPel, bpp) == 16) i++;
break;
default:
/* Skip other modes as they do not match requested format */
break;
}
}
#else
i = 1;
j = 1;
#endif
TRACE_(d3d_caps)("(%p}->(Adapter: %d) => %d (out of %d)\n", This, Adapter, i, j);
return i;
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
return 0;
}
/* Note: dx9 supplies a format. Calls from d3d8 supply D3DFMT_UNKNOWN */
HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter:%d, mode:%d, pMode:%p, format:%s)\n", This, Adapter, Mode, pMode, debug_d3dformat(Format));
/* Validate the parameters as much as possible */
if (NULL == pMode ||
Adapter >= IWineD3DImpl_GetAdapterCount(iface) ||
Mode >= IWineD3DImpl_GetAdapterModeCount(iface, Adapter, Format)) {
return D3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
#if !defined( DEBUG_SINGLE_MODE )
DEVMODEW DevModeW;
int ModeIdx = 0;
/* Work out the current screen bpp */
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
int bpp = GetDeviceCaps(hdc, BITSPIXEL);
DeleteDC(hdc);
/* If we are filtering to a specific format, then need to skip all unrelated
modes, but if mode is irrelevant, then we can use the index directly */
if (Format == D3DFMT_UNKNOWN)
{
ModeIdx = Mode;
} else {
int i = 0;
int j = 0;
DEVMODEW DevModeWtmp;
while ((Mode+1) < i && EnumDisplaySettingsExW(NULL, j, &DevModeWtmp, 0)) {
j++;
switch (Format)
{
case D3DFMT_UNKNOWN:
i++;
break;
case D3DFMT_X8R8G8B8:
case D3DFMT_A8R8G8B8:
if (min(DevModeWtmp.dmBitsPerPel, bpp) == 32) i++;
break;
case D3DFMT_X1R5G5B5:
case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5:
if (min(DevModeWtmp.dmBitsPerPel, bpp) == 16) i++;
break;
default:
/* Skip other modes as they do not match requested format */
break;
}
}
ModeIdx = j;
}
/* Now get the display mode via the calculated index */
if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0))
{
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
bpp = min(DevModeW.dmBitsPerPel, bpp);
pMode->RefreshRate = D3DADAPTER_DEFAULT;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
}
if (Format == D3DFMT_UNKNOWN)
{
switch (bpp) {
case 8: pMode->Format = D3DFMT_R3G3B2; break;
case 16: pMode->Format = D3DFMT_R5G6B5; break;
case 24: /* pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
default: pMode->Format = D3DFMT_UNKNOWN;
}
} else {
pMode->Format = Format;
}
}
else
{
TRACE_(d3d_caps)("Requested mode out of range %d\n", Mode);
return D3DERR_INVALIDCALL;
}
#else
/* Return one setting of the format requested */
if (Mode > 0) return D3DERR_INVALIDCALL;
pMode->Width = 800;
pMode->Height = 600;
pMode->RefreshRate = D3DADAPTER_DEFAULT;
pMode->Format = (Format==D3DFMT_UNKNOWN)?D3DFMT_A8R8G8B8:Format;
bpp = 32;
#endif
TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height,
pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format), bpp);
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
return D3D_OK;
}
HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
if (NULL == pMode ||
Adapter >= IWineD3D_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int bpp = 0;
DEVMODEW DevModeW;
EnumDisplaySettingsExW(NULL, (DWORD)-1, &DevModeW, 0);
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
bpp = DevModeW.dmBitsPerPel;
pMode->RefreshRate = D3DADAPTER_DEFAULT;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
}
switch (bpp) {
case 8: pMode->Format = D3DFMT_R3G3B2; break;
case 16: pMode->Format = D3DFMT_R5G6B5; break;
case 24: /*pMode->Format = D3DFMT_R5G6B5; break;*/ /* Make 24bit appear as 32 bit */
case 32: pMode->Format = D3DFMT_A8R8G8B8; break;
default: pMode->Format = D3DFMT_UNKNOWN;
}
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%s\n", pMode->Width,
pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
return D3D_OK;
}
/* IUnknown parts follow: */
HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *ppobj)
......@@ -42,11 +265,18 @@ HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *p
}
ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
return 1;
IWineD3DImpl *This = (IWineD3DImpl *)iface;
FIXME("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
return 0;
IWineD3DImpl *This = (IWineD3DImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
return ref;
}
/* VTbl definition */
......@@ -55,5 +285,10 @@ IWineD3DVtbl IWineD3D_Vtbl =
IWineD3DImpl_QueryInterface,
IWineD3DImpl_AddRef,
IWineD3DImpl_Release,
IWineD3DImpl_GetAdapterCount
IWineD3DImpl_GetAdapterCount,
IWineD3DImpl_RegisterSoftwareDevice,
IWineD3DImpl_GetAdapterMonitor,
IWineD3DImpl_GetAdapterModeCount,
IWineD3DImpl_EnumAdapterModes,
IWineD3DImpl_GetAdapterDisplayMode
};
/*
* Utility functions for the WineD3D Library
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
const char* debug_d3dformat(D3DFORMAT fmt) {
switch (fmt) {
#define FMT_TO_STR(fmt) case fmt: return #fmt
FMT_TO_STR(D3DFMT_UNKNOWN);
FMT_TO_STR(D3DFMT_R8G8B8);
FMT_TO_STR(D3DFMT_A8R8G8B8);
FMT_TO_STR(D3DFMT_X8R8G8B8);
FMT_TO_STR(D3DFMT_R5G6B5);
FMT_TO_STR(D3DFMT_X1R5G5B5);
FMT_TO_STR(D3DFMT_A1R5G5B5);
FMT_TO_STR(D3DFMT_A4R4G4B4);
FMT_TO_STR(D3DFMT_R3G3B2);
FMT_TO_STR(D3DFMT_A8);
FMT_TO_STR(D3DFMT_A8R3G3B2);
FMT_TO_STR(D3DFMT_X4R4G4B4);
FMT_TO_STR(D3DFMT_A8P8);
FMT_TO_STR(D3DFMT_P8);
FMT_TO_STR(D3DFMT_L8);
FMT_TO_STR(D3DFMT_A8L8);
FMT_TO_STR(D3DFMT_A4L4);
FMT_TO_STR(D3DFMT_V8U8);
FMT_TO_STR(D3DFMT_L6V5U5);
FMT_TO_STR(D3DFMT_X8L8V8U8);
FMT_TO_STR(D3DFMT_Q8W8V8U8);
FMT_TO_STR(D3DFMT_V16U16);
FMT_TO_STR(D3DFMT_W11V11U10);
FMT_TO_STR(D3DFMT_UYVY);
FMT_TO_STR(D3DFMT_YUY2);
FMT_TO_STR(D3DFMT_DXT1);
FMT_TO_STR(D3DFMT_DXT2);
FMT_TO_STR(D3DFMT_DXT3);
FMT_TO_STR(D3DFMT_DXT4);
FMT_TO_STR(D3DFMT_DXT5);
FMT_TO_STR(D3DFMT_D16_LOCKABLE);
FMT_TO_STR(D3DFMT_D32);
FMT_TO_STR(D3DFMT_D15S1);
FMT_TO_STR(D3DFMT_D24S8);
FMT_TO_STR(D3DFMT_D16);
FMT_TO_STR(D3DFMT_D24X8);
FMT_TO_STR(D3DFMT_D24X4S4);
FMT_TO_STR(D3DFMT_VERTEXDATA);
FMT_TO_STR(D3DFMT_INDEX16);
FMT_TO_STR(D3DFMT_INDEX32);
#undef FMT_TO_STR
default:
FIXME("Unrecognized %u D3DFORMAT!\n", fmt);
return "unrecognized";
}
}
......@@ -36,6 +36,7 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion) {
IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
object->lpVtbl = &IWineD3D_Vtbl;
object->dxVersion = dxVersion;
object->ref = 1;
TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
......
......@@ -61,6 +61,10 @@ typedef struct IWineD3DImpl
extern IWineD3DVtbl IWineD3D_Vtbl;
/* Utility function prototypes */
const char* debug_d3dformat(D3DFORMAT fmt);
#if 0 /* Needs fixing during rework */
......
......@@ -45,6 +45,12 @@ typedef struct IWineD3D IWineD3D;
#define IWineD3D_METHODS \
IUnknown_METHODS \
STDMETHOD_(UINT,GetAdapterCount )(THIS) PURE; \
STDMETHOD(RegisterSoftwareDevice)(THIS_ void * pInitializeFunction) PURE; \
STDMETHOD_(HMONITOR,GetAdapterMonitor)(THIS_ UINT Adapter) PURE; \
STDMETHOD_(UINT,GetAdapterModeCount)(THIS_ UINT Adapter, D3DFORMAT Format) PURE; \
STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter, UINT Mode, D3DFORMAT Format, D3DDISPLAYMODE * pMode) PURE; \
STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter, D3DDISPLAYMODE * pMode) PURE; \
DECLARE_INTERFACE_(IWineD3D,IUnknown) { IWineD3D_METHODS };
#undef INTERFACE
......@@ -56,6 +62,12 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown) { IWineD3D_METHODS };
#define IWineD3D_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3D methods ***/
#define IWineD3D_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p)
#define IWineD3D_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a)
#define IWineD3D_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a)
#define IWineD3D_GetAdapterModeCount(p,a,b) (p)->lpVtbl->GetAdapterModeCount(p,a,b)
#define IWineD3D_EnumAdapterModes(p,a,b,c,d) (p)->lpVtbl->EnumAdapterModes(p,a,b,c,d)
#define IWineD3D_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b)
#endif
/* Define the main WineD3D entrypoint */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment