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 ...@@ -160,7 +160,7 @@ HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTURE9 ifa
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ /* 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.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool; wined3ddesc.Pool = &pDesc->Pool;
......
...@@ -165,7 +165,7 @@ HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFAC ...@@ -165,7 +165,7 @@ HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3DSURFAC
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ /* 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.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool; wined3ddesc.Pool = &pDesc->Pool;
......
...@@ -159,7 +159,7 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT ...@@ -159,7 +159,7 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 iface, UINT
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
/* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ /* 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.Type = &pDesc->Type;
wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Usage = &pDesc->Usage;
wined3ddesc.Pool = &pDesc->Pool; wined3ddesc.Pool = &pDesc->Pool;
......
...@@ -76,11 +76,19 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) { ...@@ -76,11 +76,19 @@ ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
ref = InterlockedDecrement(&This->resource.ref); ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) { if (ref == 0) {
int i,j; int i,j;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
if (This->surfaces[j][i] != NULL) { if (This->surfaces[j][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[j][i], 0, 0);
TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]); TRACE("(%p) : Releasing surface%d %d %p\n", This, j, i, This->surfaces[j][i]);
IWineD3DSurface_Release((IWineD3DSurface *) 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) { ...@@ -122,18 +130,23 @@ DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) { void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
/* Override the IWineD3DResource Preload method */ /* Override the IWineD3DResource Preload method */
unsigned int i,j; unsigned int i,j;
BOOL setGlTextureDesc = FALSE;
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface; IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty); TRACE("(%p) : About to load texture: dirtified(%d)\n", This, This->baseTexture.dirty);
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
IWineD3DCubeTexture_BindTexture(iface); IWineD3DCubeTexture_BindTexture(iface);
ENTER_GL(); ENTER_GL();
/* If were dirty then reload the surfaces */ /* 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 (i = 0; i < This->baseTexture.levels; i++) {
for (j = 0; j < 6; j++) 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 */ /* No longer dirty */
This->baseTexture.dirty = FALSE; This->baseTexture.dirty = FALSE;
......
...@@ -566,9 +566,17 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid ...@@ -566,9 +566,17 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
object->currentDesc.Width = Width; object->currentDesc.Width = Width;
object->currentDesc.Height = Height; object->currentDesc.Height = Height;
object->currentDesc.Level = Level;
object->currentDesc.MultiSampleType = MultiSample; object->currentDesc.MultiSampleType = MultiSample;
object->currentDesc.MultiSampleQuality = MultisampleQuality; 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 */ /* Internal data */
object->pow2Width = pow2Width; object->pow2Width = pow2Width;
object->pow2Height = pow2Height; object->pow2Height = pow2Height;
......
...@@ -60,13 +60,16 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) { ...@@ -60,13 +60,16 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
ULONG ref = InterlockedDecrement(&This->resource.ref); ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %ld\n", This, ref + 1); TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) { if (ref == 0) {
if (This->textureName != 0) { /* release the openGL texture.. */ TRACE("(%p) : cleaning up\n", This);
if (This->glDescription.textureName != 0) { /* release the openGL texture.. */
ENTER_GL(); ENTER_GL();
TRACE("Deleting texture %d\n", This->textureName); TRACE("Deleting texture %d\n", This->glDescription.textureName);
glDeleteTextures(1, &This->textureName); glDeleteTextures(1, &This->glDescription.textureName);
LEAVE_GL(); LEAVE_GL();
} }
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
TRACE("(%p) Released\n", This);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -108,7 +111,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { ...@@ -108,7 +111,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
/* TODO: check for locks */ /* TODO: check for locks */
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL; IWineD3DBaseTexture *baseTexture = NULL;
TRACE("(%p)Checking to see if the container is a base textuer\n", This); TRACE("(%p)Checking to see if the container is a base texture\n", This);
if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == D3D_OK) { if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == D3D_OK) {
TRACE("Passing to conatiner\n"); TRACE("Passing to conatiner\n");
IWineD3DBaseTexture_PreLoad(baseTexture); IWineD3DBaseTexture_PreLoad(baseTexture);
...@@ -119,21 +122,21 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { ...@@ -119,21 +122,21 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
#if 0 /* TODO: context manager support */ #if 0 /* TODO: context manager support */
IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_2D, ENABLED, NOW /* make sure the state is applied now */); IWineD3DContextManager_PushState(This->contextManager, GL_TEXTURE_2D, ENABLED, NOW /* make sure the state is applied now */);
#endif #endif
glEnable(GL_TEXTURE_2D); /* make sure texture support is enabled in this context */ glEnable(This->glDescription.target);/* make sure texture support is enabled in this context */
if (This->currentDesc.Level == 0 && This->textureName == 0) { if (This->glDescription.level == 0 && This->glDescription.textureName == 0) {
glGenTextures(1, &This->textureName); glGenTextures(1, &This->glDescription.textureName);
checkGLcall("glGenTextures"); checkGLcall("glGenTextures");
TRACE("Surface %p given name %d\n", This, This->textureName); TRACE("Surface %p given name %d\n", This, This->glDescription.textureName);
glBindTexture(GL_TEXTURE_2D, This->textureName); glBindTexture(This->glDescription.target, This->glDescription.textureName);
checkGLcall("glBindTexture"); checkGLcall("glBindTexture");
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This, GL_TEXTURE_2D, This->currentDesc.Level); IWineD3DSurface_LoadTexture(iface);
/* This is where we should be reducing the amount of GLMemoryUsed */ /* This is where we should be reducing the amount of GLMemoryUsed */
}else { }else {
if (This->currentDesc.Level == 0) { if (This->glDescription.level == 0) {
glBindTexture(GL_TEXTURE_2D, This->textureName); glBindTexture(This->glDescription.target, This->glDescription.textureName);
checkGLcall("glBindTexture"); checkGLcall("glBindTexture");
IWineD3DSurface_LoadTexture((IWineD3DSurface *) This, GL_TEXTURE_2D, This->currentDesc.Level); IWineD3DSurface_LoadTexture(iface);
} else if (This->textureName != 0) { /* NOTE: the level 0 surface of a mpmapped texture must be loaded first! */ } else if (This->glDescription.textureName != 0) { /* NOTE: the level 0 surface of a mpmapped texture must be loaded first! */
/* assume this is a coding error not a real error for now */ /* assume this is a coding error not a real error for now */
FIXME("Mipmap surface has a glTexture bound to it!\n"); FIXME("Mipmap surface has a glTexture bound to it!\n");
} }
...@@ -142,7 +145,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { ...@@ -142,7 +145,7 @@ void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
/* Tell opengl to try and keep this texture in video ram (well mostly) */ /* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp; GLclampf tmp;
tmp = 0.9f; tmp = 0.9f;
glPrioritizeTextures(1, &This->textureName, &tmp); glPrioritizeTextures(1, &This->glDescription.textureName, &tmp);
} }
/* TODO: disable texture support, if it wastn't enabled when we entered. */ /* TODO: disable texture support, if it wastn't enabled when we entered. */
#if 0 /* TODO: context manager support */ #if 0 /* TODO: context manager support */
...@@ -199,6 +202,33 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC ...@@ -199,6 +202,33 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC
return D3D_OK; return D3D_OK;
} }
void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target){
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : setting textureName %u, target %i\n", This, textureName, target);
if (This->glDescription.textureName == 0 && textureName != 0) {
This->Dirty = TRUE;
IWineD3DSurface_AddDirtyRect(iface, NULL);
}
This->glDescription.textureName = textureName;
This->glDescription.target = target;
}
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription){
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : returning %p\n", This, &This->glDescription);
*glDescription = &This->glDescription;
}
/* TODO: think about moving this down to resource? */
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* This should only be called for sysmem textures, it may be a good idea to extend this to all pools at some point in the futture */
if (This->resource.pool != D3DPOOL_SYSTEMMEM) {
FIXME(" (%p)Attempting to get system memory for a non-system memory texture\n", iface);
}
return (CONST void*)(This->resource.allocatedMemory);
}
HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
...@@ -678,7 +708,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) { ...@@ -678,7 +708,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
/* ****************************************************** /* ******************************************************
IWineD3DSurface Internal (No mapping to directx api) parts follow IWineD3DSurface Internal (No mapping to directx api) parts follow
****************************************************** */ ****************************************************** */
HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl_target, GLenum gl_level) { HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
if (This->inTexture) { if (This->inTexture) {
...@@ -702,23 +732,32 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -702,23 +732,32 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
if (This->inPBuffer) { if (This->inPBuffer) {
ENTER_GL(); ENTER_GL();
if (gl_level != 0) if (This->glDescription.level != 0)
FIXME("Surface in texture is only supported for level 0\n"); FIXME("Surface in texture is only supported for level 0\n");
else if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8 || else if (This->resource.format == WINED3DFMT_P8 || This->resource.format == WINED3DFMT_A8P8 ||
This->resource.format == WINED3DFMT_DXT1 || This->resource.format == WINED3DFMT_DXT3 || This->resource.format == WINED3DFMT_DXT1 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT5) This->resource.format == WINED3DFMT_DXT5)
FIXME("Format %d not supported\n", This->resource.format); FIXME("Format %d not supported\n", This->resource.format);
else { else {
glCopyTexImage2D(gl_target, GLenum prevRead;
0, glGetIntegerv(GL_READ_BUFFER, &prevRead);
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, vcheckGLcall("glGetIntegerv");
This->resource.format), glReadBuffer(GL_BACK);
vcheckGLcall("glReadBuffer");
glCopyTexImage2D(This->glDescription.target,
This->glDescription.level,
This->glDescription.glFormatInternal,
0, 0,
0, 0,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0); 0);
TRACE("Updating target %d\n", gl_target);
checkGLcall("glCopyTexImage2D");
glReadBuffer(prevRead);
vcheckGLcall("glReadBuffer");
TRACE("Updating target %d\n", This->glDescription.target);
This->inTexture = TRUE; This->inTexture = TRUE;
} }
LEAVE_GL(); LEAVE_GL();
...@@ -751,8 +790,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -751,8 +790,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
ENTER_GL(); ENTER_GL();
TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", TRACE("Calling glTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target, This->glDescription.target,
gl_level, This->glDescription.level,
GL_RGBA, GL_RGBA,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
...@@ -760,8 +799,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -760,8 +799,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
surface); surface);
glTexImage2D(gl_target, glTexImage2D(This->glDescription.target,
gl_level, This->glDescription.level,
GL_RGBA, GL_RGBA,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
...@@ -777,14 +816,16 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -777,14 +816,16 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
return D3D_OK; return D3D_OK;
} }
/* TODO: Compressed non-power 2 support */
/* TODO: DXT2 DXT4 support */
if (This->resource.format == WINED3DFMT_DXT1 || if (This->resource.format == WINED3DFMT_DXT1 ||
This->resource.format == WINED3DFMT_DXT3 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT5) { This->resource.format == WINED3DFMT_DXT5) {
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) { if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n", TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
gl_target, This->glDescription.target,
gl_level, This->glDescription.level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
...@@ -793,9 +834,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -793,9 +834,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
ENTER_GL(); ENTER_GL();
GL_EXTCALL(glCompressedTexImage2DARB)(gl_target, GL_EXTCALL(glCompressedTexImage2DARB)(This->glDescription.target,
gl_level, This->glDescription.level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
...@@ -815,20 +856,20 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -815,20 +856,20 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
TRACE("non power of two support\n"); TRACE("non power of two support\n");
ENTER_GL(); ENTER_GL();
TRACE("(%p) Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", This, TRACE("(%p) Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", This,
gl_target, This->glDescription.target,
gl_level, This->glDescription.level,
debug_d3dformat(This->resource.format), debug_d3dformat(This->resource.format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->pow2Width, This->pow2Width,
This->pow2Height, This->pow2Height,
0, 0,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormat,
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glType,
NULL); NULL);
glTexImage2D(gl_target, glTexImage2D(This->glDescription.target,
gl_level, This->glDescription.level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->pow2Width, This->pow2Width,
This->pow2Height, This->pow2Height,
0/*border*/, 0/*border*/,
...@@ -841,14 +882,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -841,14 +882,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
TRACE("(%p) Calling glTexSubImage2D w(%d) h(%d) mem(%p)\n", This, This->currentDesc.Width, This->currentDesc.Height, This->resource.allocatedMemory); TRACE("(%p) Calling glTexSubImage2D w(%d) h(%d) mem(%p)\n", This, This->currentDesc.Width, This->currentDesc.Height, This->resource.allocatedMemory);
/* And map the non-power two data into the top left corner */ /* And map the non-power two data into the top left corner */
glTexSubImage2D( glTexSubImage2D(
gl_target, This->glDescription.target,
gl_level, This->glDescription.level,
0 /* xoffset */, 0 /* xoffset */,
0 /* ysoffset */ , 0 /* ysoffset */ ,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormat,
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glType,
This->resource.allocatedMemory This->resource.allocatedMemory
); );
checkGLcall("glTexSubImage2D"); checkGLcall("glTexSubImage2D");
...@@ -858,26 +899,26 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -858,26 +899,26 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
} else { } else {
TRACE("Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n", TRACE("Calling 2 glTexImage2D %x i=%d, d3dfmt=%s, intfmt=%x, w=%d, h=%d,0=%d, glFmt=%x, glType=%x, Mem=%p\n",
gl_target, This->glDescription.target,
gl_level, This->glDescription.level,
debug_d3dformat(This->resource.format), debug_d3dformat(This->resource.format),
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0, 0,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormat,
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glType,
This->resource.allocatedMemory); This->resource.allocatedMemory);
ENTER_GL(); ENTER_GL();
glTexImage2D(gl_target, glTexImage2D(This->glDescription.target,
gl_level, This->glDescription.level,
D3DFmt2GLIntFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormatInternal,
This->currentDesc.Width, This->currentDesc.Width,
This->currentDesc.Height, This->currentDesc.Height,
0 /* border */, 0 /* border */,
D3DFmt2GLFmt(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glFormat,
D3DFmt2GLType(This->resource.wineD3DDevice, This->resource.format), This->glDescription.glType,
This->resource.allocatedMemory); This->resource.allocatedMemory);
checkGLcall("glTexImage2D"); checkGLcall("glTexImage2D");
LEAVE_GL(); LEAVE_GL();
...@@ -889,7 +930,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl ...@@ -889,7 +930,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl
char buffer[4096]; char buffer[4096];
++gen; ++gen;
if ((gen % 10) == 0) { if ((gen % 10) == 0) {
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, gl_target, gl_level, gen); snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
IWineD3DSurfaceImpl_SaveSnapshot((IWineD3DSurface *) This, buffer); IWineD3DSurfaceImpl_SaveSnapshot((IWineD3DSurface *) This, buffer);
} }
/* /*
...@@ -1073,5 +1114,8 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl = ...@@ -1073,5 +1114,8 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DSurfaceImpl_LoadTexture, IWineD3DSurfaceImpl_LoadTexture,
IWineD3DSurfaceImpl_SaveSnapshot, IWineD3DSurfaceImpl_SaveSnapshot,
IWineD3DSurfaceImpl_SetContainer, IWineD3DSurfaceImpl_SetContainer,
IWineD3DSurfaceImpl_SetPBufferState IWineD3DSurfaceImpl_SetPBufferState,
IWineD3DSurfaceImpl_SetGlTextureDesc,
IWineD3DSurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData
}; };
/* /*
* IDirect3DTexture9 implementation * IWineD3DTexture implementation
* *
* Copyright 2002-2005 Jason Edmeades * Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2005 Raphael Junqueira * Copyright 2002-2005 Raphael Junqueira
...@@ -47,7 +47,6 @@ HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID ...@@ -47,7 +47,6 @@ HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID
ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) { ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref); TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
IUnknown_AddRef(This->resource.parent);
return InterlockedIncrement(&This->resource.ref); return InterlockedIncrement(&This->resource.ref);
} }
...@@ -58,10 +57,14 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) { ...@@ -58,10 +57,14 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
ref = InterlockedDecrement(&This->resource.ref); ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) { if (ref == 0) {
int i; int i;
TRACE("(%p) : Cleaning up\n",This);
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
if (This->surfaces[i] != NULL) { 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 */ /* Because the surfaces were created using a callback we need to release there parent otehrwise we leave the parent hanging */
IUnknown* surfaceParent; 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); IWineD3DSurface_GetParent(This->surfaces[i], &surfaceParent);
IUnknown_Release(surfaceParent); IUnknown_Release(surfaceParent);
IUnknown_Release(surfaceParent); IUnknown_Release(surfaceParent);
...@@ -70,8 +73,6 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) { ...@@ -70,8 +73,6 @@ ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface); IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
} }
return ref; return ref;
} }
...@@ -107,20 +108,28 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) { ...@@ -107,20 +108,28 @@ void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
/* Override the IWineD3DResource PreLoad method */ /* Override the IWineD3DResource PreLoad method */
unsigned int i; unsigned int i;
BOOL setGlTextureDesc = FALSE;
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
TRACE("(%p) : About to load texture\n", This); TRACE("(%p) : About to load texture\n", This);
if (This->baseTexture.textureName == 0) setGlTextureDesc = TRUE;
IWineD3DTexture_BindTexture(iface); IWineD3DTexture_BindTexture(iface);
ENTER_GL(); ENTER_GL();
/* If were dirty then reload the surfaces */ /* 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 (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 */ /* No longer dirty */
This->baseTexture.dirty = FALSE; This->baseTexture.dirty = FALSE;
} else {
TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
} }
LEAVE_GL(); LEAVE_GL();
......
...@@ -600,7 +600,6 @@ extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl; ...@@ -600,7 +600,6 @@ extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
typedef struct _WINED3DSURFACET_DESC typedef struct _WINED3DSURFACET_DESC
{ {
UINT Level;
D3DMULTISAMPLE_TYPE MultiSampleType; D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality; DWORD MultiSampleQuality;
UINT Width; UINT Width;
...@@ -644,6 +643,8 @@ struct IWineD3DSurfaceImpl ...@@ -644,6 +643,8 @@ struct IWineD3DSurfaceImpl
BOOL inTexture; BOOL inTexture;
BOOL inPBuffer; BOOL inPBuffer;
glDescriptor glDescription;
}; };
extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl; extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
......
...@@ -979,10 +979,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource) ...@@ -979,10 +979,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
/* Internally used methods */ /* Internally used methods */
STDMETHOD(CleanDirtyRect)(THIS) PURE; STDMETHOD(CleanDirtyRect)(THIS) PURE;
STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pRect) 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(SaveSnapshot)(THIS_ const char *filename) PURE;
STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE; STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE;
STDMETHOD(SetPBufferState)(THIS_ BOOL inPBuffer, BOOL inTexture) 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 #undef INTERFACE
...@@ -1012,10 +1015,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource) ...@@ -1012,10 +1015,13 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
/*** IWineD3DSurface (Internal, no d3d mapping) methods ***/ /*** IWineD3DSurface (Internal, no d3d mapping) methods ***/
#define IWineD3DSurface_CleanDirtyRect(p) (p)->lpVtbl->CleanDirtyRect(p) #define IWineD3DSurface_CleanDirtyRect(p) (p)->lpVtbl->CleanDirtyRect(p)
#define IWineD3DSurface_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) #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_SaveSnapshot(p,a) (p)->lpVtbl->SaveSnapshot(p,a)
#define IWineD3DSurface_SetContainer(p,a) (p)->lpVtbl->SetContainer(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_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 #endif
/***************************************************************************** /*****************************************************************************
......
...@@ -414,7 +414,7 @@ typedef struct _WINED3DPRESENT_PARAMETERS { ...@@ -414,7 +414,7 @@ typedef struct _WINED3DPRESENT_PARAMETERS {
typedef struct _WINED3DSURFACE_DESC typedef struct _WINED3DSURFACE_DESC
{ {
D3DFORMAT *Format; WINED3DFORMAT *Format;
D3DRESOURCETYPE *Type; D3DRESOURCETYPE *Type;
DWORD *Usage; DWORD *Usage;
D3DPOOL *Pool; D3DPOOL *Pool;
...@@ -674,5 +674,13 @@ typedef struct _WINED3DCAPS { ...@@ -674,5 +674,13 @@ typedef struct _WINED3DCAPS {
} WINED3DCAPS; } WINED3DCAPS;
typedef struct glDescriptor {
UINT textureName;
int level;
int target;
int/*GLenum*/ glFormat;
int/*GLenum*/ glFormatInternal;
int/*GLenum*/ glType;
} glDescriptor;
#endif #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