Commit 13621056 authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Move parameters relating to opengl on the surface structure on to a

glDesciption member. Removed Level and Target from LoadTexture, and reduced the dependency on surface->device. Fixed a couple of compiler warnings in d3d9.
parent 9170cc82
......@@ -160,7 +160,7 @@ HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 ifa
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &pDesc->Format;
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
......
......@@ -165,7 +165,7 @@ HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFAC
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &pDesc->Format;
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
......
......@@ -159,7 +159,7 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT
TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
wined3ddesc.Format = &pDesc->Format;
wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
wined3ddesc.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool;
......
......@@ -76,11 +76,19 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
int i,j;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++) {
if (This->surfaces[j][i] != NULL) {
TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
IWineD3DSurface_Release((IWineD3DSurface *) This->surfaces[j][i]);
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
IUnknown* surfaceParent;
/* Clean out the texture name we gave to the suface so that the surface doesn't try and release it */
IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], 0, 0);
TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
IWineD3DSurface_GetParent(This->surfaces[j][i], &surfaceParent);
IUnknown_Release(surfaceParent);
IUnknown_Release(surfaceParent);
}
}
}
......@@ -122,18 +130,23 @@ DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
/* Override the IWineD3DResource Preload method */
unsigned int i,j;
BOOL setGlTextureDesc = FALSE;
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
IWineD3DCubeTexture_BindTexture(iface);
ENTER_GL();
/* If were dirty then reload the surfaces */
if(This->baseTexture.dirty != FALSE) {
if (This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++)
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i], cube_targets[j], i);
if(setGlTextureDesc)
IWineD3DSurface_SetGlTextureDesc(This->surfaces[j][i], This->baseTexture.textureName, cube_targets[j]);
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This->surfaces[j][i]);
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
......
......@@ -558,17 +558,25 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
return D3DERR_NOTAVAILABLE;
}
}
/** TODO: Check against the maximum texture sizes supported by the video card **/
D3DCREATERESOURCEOBJECTINSTANCE(object,Surface,D3DRTYPE_SURFACE)
object->container = (IUnknown*) This;
object->currentDesc.Width = Width;
object->currentDesc.Height = Height;
object->currentDesc.Level = Level;
object->currentDesc.MultiSampleType = MultiSample;
object->currentDesc.MultiSampleQuality = MultisampleQuality;
/* Setup some glformat defaults */
object->glDescription.glFormat = D3DFmt2GLFmt(This, object->resource.format);
object->glDescription.glFormatInternal = D3DFmt2GLIntFmt(This, object->resource.format);
object->glDescription.glType = D3DFmt2GLType(This, object->resource.format);
object->glDescription.textureName = 0;
object->glDescription.level = Level;
object->glDescription.target = GL_TEXTURE_2D;
/* Internal data */
object->pow2Width = pow2Width;
object->pow2Height = pow2Height;
......
/*
* IDirect3DTexture9 implementation
* IWineD3DTexture implementation
*
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira
......@@ -47,7 +47,6 @@ HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID
ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
IUnknown_AddRef(This->resource.parent);
return InterlockedIncrement(&This->resource.ref);
}
......@@ -58,10 +57,14 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
int i;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) {
if (This->surfaces[i] != NULL) {
/* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
IUnknown* surfaceParent;
/* Clean out the texture name we gave to the suface so that the surface doesn't try and release it */
IWineD3DSurface_SetGlTextureDesc(This->surfaces[i], 0, 0);
IWineD3DSurface_GetParent(This->surfaces[i], &surfaceParent);
IUnknown_Release(surfaceParent);
IUnknown_Release(surfaceParent);
......@@ -70,8 +73,6 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
}
return ref;
}
......@@ -107,20 +108,28 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
/* Override the IWineD3DResource PreLoad method */
unsigned int i;
BOOL setGlTextureDesc = FALSE;
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : About to load texture\n", This);
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
IWineD3DTexture_BindTexture(iface);
ENTER_GL();
/* If were dirty then reload the surfaces */
/* If were dirty then reload the surfaces */
if(This->baseTexture.dirty != FALSE) {
for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DSurface_LoadTexture(This->surfaces[i], GL_TEXTURE_2D, i);
if(setGlTextureDesc)
IWineD3DSurface_SetGlTextureDesc(This->surfaces[i], This->baseTexture.textureName, IWineD3DTexture_GetTextureDimensions(iface));
IWineD3DSurface_LoadTexture(This->surfaces[i]);
}
/* No longer dirty */
This->baseTexture.dirty = FALSE;
} else {
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
}
LEAVE_GL();
......
......@@ -600,7 +600,6 @@ extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
typedef struct _WINED3DSURFACET_DESC
{
UINT Level;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
UINT Width;
......@@ -644,6 +643,8 @@ struct IWineD3DSurfaceImpl
BOOL inTexture;
BOOL inPBuffer;
glDescriptor glDescription;
};
extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
......
......@@ -979,11 +979,14 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
/* Internally used methods */
STDMETHOD(CleanDirtyRect)(THIS) PURE;
STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pRect) PURE;
STDMETHOD(LoadTexture)(THIS_ UINT gl_target, UINT gl_level) PURE;
STDMETHOD(LoadTexture)(THIS) PURE;
STDMETHOD(SaveSnapshot)(THIS_ const char *filename) PURE;
STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE;
STDMETHOD(SetPBufferState)(THIS_ BOOL inPBuffer, BOOL inTexture) PURE;
STDMETHOD_(void,SetGlTextureDesc)(THIS_ UINT textureName, int target) PURE;
STDMETHOD_(void,GetGlDesc)(THIS_ glDescriptor **glDescription) PURE;
STDMETHOD_(CONST void *, GetData)(THIS) PURE;
};
#undef INTERFACE
......@@ -1012,10 +1015,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
/*** IWineD3DSurface (Internal, no d3d mapping) methods ***/
#define IWineD3DSurface_CleanDirtyRect(p) (p)->lpVtbl->CleanDirtyRect(p)
#define IWineD3DSurface_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a)
#define IWineD3DSurface_LoadTexture(p,a,b) (p)->lpVtbl->LoadTexture(p,a,b)
#define IWineD3DSurface_LoadTexture(p) (p)->lpVtbl->LoadTexture(p)
#define IWineD3DSurface_SaveSnapshot(p,a) (p)->lpVtbl->SaveSnapshot(p,a)
#define IWineD3DSurface_SetContainer(p,a) (p)->lpVtbl->SetContainer(p,a)
#define IWineD3DSurface_SetPBufferState(p,a,b) (p)->lpVtbl->SetPBufferState(p,a,b)
#define IWineD3DSurface_SetGlTextureDesc(p,a,b) (p)->lpVtbl->SetGlTextureDesc(p,a,b)
#define IWineD3DSurface_GetGlDesc(p,a) (p)->lpVtbl->GetGlDesc(p,a)
#define IWineD3DSurface_GetData(p) (p)->lpVtbl->GetData(p)
#endif
/*****************************************************************************
......
......@@ -414,12 +414,12 @@ typedef struct _WINED3DPRESENT_PARAMETERS {
typedef struct _WINED3DSURFACE_DESC
{
D3DFORMAT *Format;
WINED3DFORMAT *Format;
D3DRESOURCETYPE *Type;
DWORD *Usage;
D3DPOOL *Pool;
UINT *Size;
D3DMULTISAMPLE_TYPE *MultiSampleType;
DWORD *MultiSampleQuality;
UINT *Width;
......@@ -433,7 +433,7 @@ typedef struct _WINED3DVOLUME_DESC
DWORD *Usage;
D3DPOOL *Pool;
UINT *Size;
UINT *Width;
UINT *Height;
UINT *Depth;
......@@ -674,5 +674,13 @@ typedef struct _WINED3DCAPS {
} WINED3DCAPS;
typedef struct glDescriptor {
UINT textureName;
int level;
int target;
int/*GLenum*/ glFormat;
int/*GLenum*/ glFormatInternal;
int/*GLenum*/ glType;
} glDescriptor;
#endif
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