Commit 3da999a1 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

d3d8: Move texturing code over to wined3d (based on Oliver Stieber's work).

parent 804cd257
/*
* IDirect3DBaseTexture8 implementation
*
* Copyright 2002 Jason Edmeades
* Copyright 2005 Oliver Stieber
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -19,33 +19,24 @@
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "wine/debug.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
/* IDirect3DBaseTexture8 (Inherited from IUnknown) */
HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface,REFIID riid,LPVOID *ppobj)
{
/* IDirect3DBaseTexture8 IUnknown parts follow: */
HRESULT WINAPI IDirect3DBaseTexture8Impl_QueryInterface(LPDIRECT3DBASETEXTURE8 iface, REFIID riid, LPVOID *ppobj) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : QueryInterface\n", This);
TRACE("(%p) Relay\n" , This);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IDirect3DResource8)
|| IsEqualGUID(riid, &IID_IDirect3DBaseTexture8)) {
IDirect3DBaseTexture8Impl_AddRef(iface);
IUnknown_AddRef(iface);
*ppobj = This;
return D3D_OK;
}
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
return E_NOINTERFACE;
}
......@@ -64,73 +55,95 @@ ULONG WINAPI IDirect3DBaseTexture8Impl_Release(LPDIRECT3DBASETEXTURE8 iface) {
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0)
if (ref == 0) {
IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* IDirect3DBaseTexture8 (Inherited from IDirect3DResource8) */
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8** ppDevice) {
/* IDirect3DBaseTexture8 IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetDevice(LPDIRECT3DBASETEXTURE8 iface, IDirect3DDevice8 **ppDevice) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
/**
* Note Calling this method will increase the internal reference count
* on the IDirect3DDevice8 interface.
*/
IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_GetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid) {
HRESULT WINAPI IDirect3DBaseTexture8Impl_FreePrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This); return D3D_OK;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
DWORD WINAPI IDirect3DBaseTexture8Impl_SetPriority(LPDIRECT3DBASETEXTURE8 iface, DWORD PriorityNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
DWORD WINAPI IDirect3DBaseTexture8Impl_GetPriority(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
}
void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
void WINAPI IDirect3DBaseTexture8Impl_PreLoad(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
TRACE("(%p) Relay\n" , This);
IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
return;
}
D3DRESOURCETYPE WINAPI IDirect3DBaseTexture8Impl_GetType(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
/*TRACE("(%p) : returning %d\n", This, This->ResourceType);*/
return This->ResourceType;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
}
/* IDirect3DBaseTexture8 */
DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
/* IDirect3DBaseTexture8 Interface follow: */
DWORD WINAPI IDirect3DBaseTexture8Impl_SetLOD(LPDIRECT3DBASETEXTURE8 iface, DWORD LODNew) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_SetLOD(This->wineD3DBaseTexture, LODNew);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLOD(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLOD(This->wineD3DBaseTexture);
}
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
DWORD WINAPI IDirect3DBaseTexture8Impl_GetLevelCount(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
TRACE("(%p) : returning %d\n", This, This->levels);
return This->levels;
TRACE("(%p) Relay\n" , This);
return IWineD3DBaseTexture_GetLevelCount(This->wineD3DBaseTexture);
}
static const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
{
IDirect3DBaseTexture8Impl_QueryInterface,
IDirect3DBaseTexture8Impl_AddRef,
......@@ -143,21 +156,22 @@ static const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl =
IDirect3DBaseTexture8Impl_GetPriority,
IDirect3DBaseTexture8Impl_PreLoad,
IDirect3DBaseTexture8Impl_GetType,
IDirect3DBaseTexture8Impl_SetLOD,
IDirect3DBaseTexture8Impl_GetLOD,
IDirect3DBaseTexture8Impl_GetLevelCount,
IDirect3DBaseTexture8Impl_GetLevelCount
};
BOOL WINAPI IDirect3DBaseTexture8Impl_IsDirty(LPDIRECT3DBASETEXTURE8 iface) {
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
return This->Dirty;
return ((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty;
}
BOOL WINAPI IDirect3DBaseTexture8Impl_SetDirty(LPDIRECT3DBASETEXTURE8 iface, BOOL dirty) {
BOOL old;
IDirect3DBaseTexture8Impl *This = (IDirect3DBaseTexture8Impl *)iface;
old = This->Dirty;
This->Dirty = dirty;
old = ((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty;
((IWineD3DBaseTextureImpl*)This->wineD3DBaseTexture)->baseTexture.dirty = dirty;
return old;
}
......@@ -17,6 +17,7 @@
*/
#include "config.h"
#include "initguid.h"
#include <stdarg.h>
......
......@@ -600,23 +600,10 @@ struct IDirect3DVolume8Impl
{
/* IUnknown fields */
const IDirect3DVolume8Vtbl *lpVtbl;
LONG ref;
LONG ref;
/* IDirect3DVolume8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
IUnknown *Container;
D3DVOLUME_DESC myDesc;
BYTE *allocatedMemory;
UINT textureName;
UINT bytesPerPixel;
BOOL lockable;
BOOL locked;
D3DBOX lockedBox;
D3DBOX dirtyBox;
BOOL Dirty;
IWineD3DVolume *wineD3DVolume;
};
/* IUnknown: */
......@@ -848,9 +835,6 @@ extern DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOU
extern void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface);
extern D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface);
/* internal Interfaces */
extern D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface);
/* ---------------------- */
/* IDirect3DVertexBuffer8 */
......@@ -958,6 +942,31 @@ extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBU
extern HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc);
/*****************************************************************************
* IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
*/
typedef struct IWineD3DBaseTextureClass
{
UINT levels;
BOOL dirty;
D3DFORMAT format;
DWORD usage;
UINT textureName;
UINT LOD;
D3DTEXTUREFILTERTYPE filterType;
DWORD states[13];
} IWineD3DBaseTextureClass;
typedef struct IWineD3DBaseTextureImpl
{
/* IUnknown & WineD3DResource Information */
const IWineD3DBaseTextureVtbl *lpVtbl;
IWineD3DResourceClass resource;
IWineD3DBaseTextureClass baseTexture;
} IWineD3DBaseTextureImpl;
/* --------------------- */
/* IDirect3DBaseTexture8 */
/* --------------------- */
......@@ -972,17 +981,7 @@ struct IDirect3DBaseTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/*
*BOOL isManaged;
*DWORD lod;
*/
IWineD3DBaseTexture *wineD3DBaseTexture;
};
/* IUnknown: */
......@@ -1029,19 +1028,7 @@ struct IDirect3DCubeTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DCubeTexture8 fields */
UINT edgeLength;
DWORD usage;
IDirect3DSurface8Impl *surfaces[6][MAX_LEVELS];
IWineD3DCubeTexture *wineD3DCubeTexture;
};
/* IUnknown: */
......@@ -1071,6 +1058,25 @@ extern HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBET
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, UINT Level);
extern HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTURE8 iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect);
/*****************************************************************************
* IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
*/
typedef struct IWineD3DTextureImpl
{
/* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
const IWineD3DTextureVtbl *lpVtbl;
IWineD3DResourceClass resource;
IWineD3DBaseTextureClass baseTexture;
/* IWineD3DTexture */
IWineD3DSurface *surfaces[MAX_LEVELS];
UINT width;
UINT height;
float pow2scalingFactorX;
float pow2scalingFactorY;
} IWineD3DTextureImpl;
/* ----------------- */
/* IDirect3DTexture8 */
......@@ -1091,20 +1097,7 @@ struct IDirect3DTexture8Impl
LONG ref;
/* IDirect3DResourc8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DTexture8 fields */
UINT width;
UINT height;
DWORD usage;
IDirect3DSurface8Impl *surfaces[MAX_LEVELS];
IWineD3DTexture *wineD3DTexture;
};
/* IUnknown: */
......@@ -1154,21 +1147,7 @@ struct IDirect3DVolumeTexture8Impl
LONG ref;
/* IDirect3DResource8 fields */
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture8 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
/* IDirect3DVolumeTexture8 fields */
UINT width;
UINT height;
UINT depth;
DWORD usage;
IDirect3DVolume8Impl *volumes[MAX_LEVELS];
IWineD3DVolumeTexture *wineD3DVolumeTexture;
};
/* IUnknown: */
......@@ -1445,6 +1424,16 @@ extern HRESULT WINAPI IDirect3DDeviceImpl_CreatePixelShader(IDirect3DDevice8Impl
*
* to see how not defined it here
*/
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, D3DPOOL Pool, UINT Level,
IWineD3DSurface **ppSurface, HANDLE *pSharedHandle);
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, D3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) ;
void GetSrcAndOpFromValue(DWORD iValue, BOOL isAlphaArg, GLenum* source, GLenum* operand);
void setupTextureStates(LPDIRECT3DDEVICE8 iface, DWORD Stage, DWORD Flags);
void set_tex_op(LPDIRECT3DDEVICE8 iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
......
......@@ -108,30 +108,6 @@ D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface)
return This->ResourceType;
}
D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
switch (This->ResourceType) {
case D3DRTYPE_SURFACE:
return D3D8_SURFACE(((IDirect3DSurface8Impl*) This))->resource.pool;
case D3DRTYPE_TEXTURE:
return D3D8_SURFACE(((IDirect3DTexture8Impl*) This)->surfaces[0])->resource.pool;
case D3DRTYPE_VOLUME:
return ((IDirect3DVolume8Impl*) This)->myDesc.Pool;
case D3DRTYPE_VOLUMETEXTURE:
return ((IDirect3DVolumeTexture8Impl*) This)->volumes[0]->myDesc.Pool;
case D3DRTYPE_CUBETEXTURE:
return D3D8_SURFACE(((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0])->resource.pool;
case D3DRTYPE_VERTEXBUFFER:
return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
case D3DRTYPE_INDEXBUFFER:
return ((IDirect3DIndexBuffer8Impl*) This)->currentDesc.Pool;
default:
FIXME("(%p) Unrecognized type(%d,%s)\n", This, This->ResourceType, debug_d3dressourcetype(This->ResourceType));
return D3DPOOL_DEFAULT;
}
}
const IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
{
IDirect3DResource8Impl_QueryInterface,
......
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